Skip to content

Commit

Permalink
update secrets to vars and add nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanmomo committed Jan 4, 2024
1 parent 464289a commit 878ed4b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ on:
jobs:
deployment:
runs-on: ubuntu-latest
environment: dl-backend-env

env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_IMAGE_VERSION: dev-latest
DOCKER_IMAGE_NAME: dl-official-website-backend
Expand Down Expand Up @@ -47,10 +48,10 @@ jobs:
uses: appleboy/ssh-action@master
if: contains(github.ref, 'dev')
with:
host: ${{ secrets.DEV_SERVER_HOST }} #服务器ip地址
username: ${{ secrets.DEV_SERVER_USERNAME }} #服务器ssh用户名
host: ${{ vars.DEV_SERVER_HOST }} #服务器ip地址
username: ${{ vars.DEV_SERVER_USERNAME }} #服务器ssh用户名
password: ${{ secrets.DEV_SSH_PRIVATE_KEY }} #服务器ssh密码
port: ${{ secrets.DEV_PORT }} # 服务器ssh端口(默认22)
port: ${{ vars.DEV_PORT }} # 服务器ssh端口(默认22)
script: |
cd /root/Official-website-backend
docker compose pull
Expand All @@ -60,10 +61,10 @@ jobs:
uses: appleboy/ssh-action@master
if: contains(github.ref, 'main')
with:
host: ${{ secrets.PROD_SERVER_HOST }} #服务器ip地址
username: ${{ secrets.PROD_SERVER_USERNAME }} #服务器ssh用户名
host: ${{ vars.PROD_SERVER_HOST }} #服务器ip地址
username: ${{ vars.PROD_SERVER_USERNAME }} #服务器ssh用户名
password: ${{ secrets.PROD_SSH_PRIVATE_KEY }} #服务器ssh密码
port: ${{ secrets.PROD_PORT }} # 服务器ssh端口(默认22)
port: ${{ vars.PROD_PORT }} # 服务器ssh端口(默认22)
script: |
cd /root/Official-website-backend
docker compose pull
Expand Down
15 changes: 15 additions & 0 deletions deploy/docker-compose-dependency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ services:
- ./mysql_volume:/var/lib/mysql
#- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql

nginx:
image: nginx:stable-alpine
container_name: nginx
restart: always
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- ./nginx.conf:/etc/nginx/nginx.conf
- ./conf:/etc/nginx/conf.d
- ./dist:/usr/share/nginx/html
- ./log:/var/log/nginx

networks:
network:
driver: bridge
Expand Down
24 changes: 24 additions & 0 deletions deploy/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
events {
worker_connections 4096; ## Default: 1024
}

http {
server {
listen 80;
listen [::]:80;
server_name _;

location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
24 changes: 0 additions & 24 deletions nginx-not-use.conf

This file was deleted.

0 comments on commit 878ed4b

Please sign in to comment.