From 619caf135d44bf194ad935e576422632983b4484 Mon Sep 17 00:00:00 2001 From: Soap Date: Tue, 12 Nov 2024 22:41:26 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20FE=20=EB=AF=B8=EB=A6=AC=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20=EB=B0=B0=ED=8F=AC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#112?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-fe-preview.yml | 47 +++++++++++++++++++++++++ backend/resources/nginx.conf | 43 +++++++++++----------- 2 files changed, 69 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/deploy-fe-preview.yml diff --git a/.github/workflows/deploy-fe-preview.yml b/.github/workflows/deploy-fe-preview.yml new file mode 100644 index 00000000..2941c7ac --- /dev/null +++ b/.github/workflows/deploy-fe-preview.yml @@ -0,0 +1,47 @@ +name: Deploy Frontend Preview + +on: + push: + branches: + - develop + paths: + - "frontend/**" + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check if commit message contains 'preview' + id: check_commit + run: | + if [[ "${{ github.event.head_commit.message }}" == *"preview"* ]]; then + echo "Commit message contains 'preview'" + echo "deploy=true" >> $GITHUB_ENV + else + echo "Commit message does not contain 'preview'" + echo "deploy=false" >> $GITHUB_ENV + fi + + - name: Build React App + if: env.deploy == 'true' + env: + VITE_AXIOS_PROD_BASE_URL: ${{ secrets.VITE_AXIOS_PROD_BASE_URL }} + VITE_GOOGLE_MAPS_API_KEY: ${{ secrets.VITE_GOOGLE_MAPS_API_KEY }} + VITE_GOOGLE_MAPS_ID: ${{ secrets.VITE_GOOGLE_MAPS_ID }} + run: | + cd ${{ github.workspace }}/frontend + yarn install + yarn build + + - name: Deploy to Nginx Server + if: env.deploy == 'true' + uses: appleboy/scp-action@master + with: + host: ${{ secrets.NCP_SERVER_HOST }} + username: ${{ secrets.NCP_SERVER_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + source: "frontend/dist/*" + target: "/usr/share/nginx/html/preview" diff --git a/backend/resources/nginx.conf b/backend/resources/nginx.conf index 13be93c5..149f1256 100644 --- a/backend/resources/nginx.conf +++ b/backend/resources/nginx.conf @@ -18,8 +18,8 @@ http { listen 443 ssl; server_name dailyroad.site www.dailyroad.site; - ssl_certificate /etc/letsencrypt/live/dailyroad.site/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/dailyroad.site/privkey.pem; + ssl_certificate /etc/letsencrypt/live/dailyroad.site-0001/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/dailyroad.site-0001/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; @@ -27,23 +27,6 @@ http { location / { try_files $uri $uri/ /index.html =404; } - - # NestJS API 요청 처리 (추후논의) - location /api/ { - rewrite ^/api/(.*) /$1 break; - proxy_pass http://localhost:8080; - - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Prefix /api; - proxy_set_header X-Forwarded-Host $http_x_forwarded_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-NginX-Proxy true; - proxy_set_header X-Forwarded-Proto $scheme; - - proxy_pass_request_body on; - proxy_method $request_method; - } } # API 서브도메인 @@ -51,8 +34,8 @@ http { listen 443 ssl; server_name api.dailyroad.site; - ssl_certificate /etc/letsencrypt/live/dailyroad.site/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/dailyroad.site/privkey.pem; + ssl_certificate /etc/letsencrypt/live/dailyroad.site-0001/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/dailyroad.site-0001/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; @@ -88,4 +71,22 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } } + + # Preview 서브도메인 + server { + listen 443 ssl; + server_name preview.dailyroad.site; + + root /usr/share/nginx/html/preview/frontend/dist; + + ssl_certificate /etc/letsencrypt/live/dailyroad.site-0001/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/dailyroad.site-0001/privkey.pem; + + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!aNULL:!MD5; + + location / { + try_files $uri $uri/ /index.html =404; + } + } }