Skip to content

Merge pull request #13 from themerous/themerous-patch-4 #29

Merge pull request #13 from themerous/themerous-patch-4

Merge pull request #13 from themerous/themerous-patch-4 #29

Workflow file for this run

name: Docker React App
on:
push:
branches: [ "main" ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm install
- name: Build Next.js app
run: pnpm build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker registry
uses: docker/login-action@v1
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.NAVER_ACESSKEY }}
password: ${{ secrets.NAVER_SECRETKEY }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ secrets.REGISTRY_URL }}/react-app:latest
- name: SSH and deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
docker login -u ${{ secrets.NAVER_ACCESSKEY }} -p ${{ secrets.NAVER_SECRETKEY }} ${{ secrets.REGISTRY_URL }}
docker pull ${{ secrets.REGISTRY_URL }}/react-app:latest
docker stop react-app-container || true
docker rm react-app-container || true
docker run -d -p 80:3000 --name react-app-container ${{ secrets.REGISTRY_URL }}/react-app:latest