f3e97d6c44
Deploy / deploy (push) Successful in 15s
- DB_DATA_DIR 기본값 /data/postgres -> ./data/postgres (다른 스택과 동일하게 프로젝트 폴더 하위에 생성) - data/ gitignore 추가 - deploy: backend/frontend를 매 배포마다 force-recreate - DB 교체 시 스키마 미동기화, nginx 낡은 upstream 캐시 문제 방지 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
53 lines
1.8 KiB
YAML
53 lines
1.8 KiB
YAML
# main 브랜치에 push 되면 배포 서버의 러너가 영구 배포 디렉터리에서
|
|
# git pull 후 이미지를 빌드하고 컨테이너를 재기동합니다.
|
|
#
|
|
# 사전 준비 (배포 서버에서 1회):
|
|
# 1. act_runner를 host 모드 라벨 "deploy"로 등록 (러너 계정: deploy)
|
|
# 2. 영구 배포 디렉터리 준비:
|
|
# git clone https://git.wandergo.net/partnership/report.git ~/stacks/_clients/report
|
|
# 해당 디렉터리에 .env 와 frontend/.env.production 을 생성 (chmod 600)
|
|
#
|
|
# .env 는 gitignore 대상이라 git 작업에 영향받지 않고 서버에 유지됩니다.
|
|
|
|
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
env:
|
|
DEPLOY_DIR: /home/deploy/stacks/_clients/report
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: deploy
|
|
steps:
|
|
- name: Pull latest code
|
|
run: |
|
|
cd "$DEPLOY_DIR"
|
|
git remote set-url origin "https://gitea-actions:${{ github.token }}@git.wandergo.net/partnership/report.git"
|
|
git fetch origin main
|
|
git reset --hard origin/main
|
|
|
|
- name: Check env files exist
|
|
run: |
|
|
cd "$DEPLOY_DIR"
|
|
test -f .env || { echo "ERROR: $DEPLOY_DIR/.env 가 없습니다"; exit 1; }
|
|
test -f frontend/.env.production || { echo "ERROR: frontend/.env.production 이 없습니다"; exit 1; }
|
|
|
|
- name: Build images
|
|
run: |
|
|
cd "$DEPLOY_DIR"
|
|
docker compose build backend frontend
|
|
|
|
- name: Restart containers
|
|
run: |
|
|
cd "$DEPLOY_DIR"
|
|
docker compose up -d
|
|
# backend/frontend는 항상 새로 기동: DB 교체 시 스키마 재동기화,
|
|
# nginx의 낡은 upstream IP 캐시 방지
|
|
docker compose up -d --no-deps --force-recreate backend frontend
|
|
|
|
- name: Prune dangling images
|
|
run: docker image prune -f
|