fix: fronted Dockerfile (#101) #3
Workflow file for this run
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: 프론트엔드 배포 | |
on: | |
push: | |
branches: [main] | |
paths: | |
- "packages/frontend/**" | |
- "packages/shared/**" | |
permissions: | |
contents: read | |
checks: write | |
pull-requests: write | |
jobs: | |
push_to_registry: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 코드 체크아웃 | |
uses: actions/checkout@v3 | |
- name: NCP 컨테이너 레지스트리 로그인 | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ secrets.CONTAINER_REGISTRY_URL }} | |
username: ${{ secrets.NCP_ACCESS_KEY }} | |
password: ${{ secrets.NCP_SECRET_KEY }} | |
- name: 도커 이미지 빌드 및 푸시 (Blue) | |
id: docker-build-blue | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./packages/frontend/Dockerfile | |
push: true | |
tags: ${{ secrets.CONTAINER_REGISTRY_URL }}/frontend:latest | |
pull_from_registry: | |
runs-on: ubuntu-latest | |
needs: push_to_registry | |
steps: | |
- name: SSH로 서버 접속 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SERVER_SSH_PORT }} | |
script: | | |
# NCP 컨테이너 레지스트리 로그인 | |
docker login -u ${{ secrets.NCP_ACCESS_KEY }} -p ${{ secrets.NCP_SECRET_KEY }} ${{ secrets.CONTAINER_REGISTRY_URL }} | |
# 새로운 이미지 pull | |
docker pull ${{ secrets.CONTAINER_REGISTRY_URL }}/frontend:latest | |
# 기존 컨테이너 중지 및 제거 | |
docker stop frontend || true | |
docker rm frontend || true | |
# 새 컨테이너 실행 | |
docker run -d --name frontend --network product_network -p 80:80 ${{ secrets.CONTAINER_REGISTRY_URL }}/frontend:latest | |
# 헬스체크 (선택사항) | |
sleep 5 | |
if ! curl -f http://localhost:80/health; then | |
echo "Warning: Health check failed after deployment" | |
fi |