fix: nginx 수정 #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: [deploy] | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/Hydrogen | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
id: cache | |
with: | |
path: node_modules | |
key: npm-packages-${{ hashFiles('**/package-lock.json') }} | |
- name: Install Dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: npm install | |
- name: Build | |
run: CI=false npm run build | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile.prod # Dockerfile.prod 경로 지정 | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/syluv:latest | |
- name: Pull and restart Docker Container | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
key: ${{ secrets.SSH_KEY }} | |
port: 22 | |
timeout: 60s | |
script: | | |
echo "Pulling latest Docker image" | |
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/syulv | |
echo "Stopping existing Docker container" | |
sudo docker stop syluvFrontend || true | |
sudo docker rm syluvFrontend || true | |
echo "Starting new Docker container" | |
sudo docker run -d --rm --name syluvFrontend -p 80:80 -p 443:443 ${{ secrets.DOCKERHUB_USERNAME }}/syluv |