fix(Dockerfile) : 빌드시점에 추가 #19
This file contains hidden or 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: Front Production Server (main) | |
| on: | |
| push: | |
| branches: | |
| - main # main 브랜치에 push가 발생하면 실행 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Setup SSH | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.LIGHTSAIL_PROD_SSH_KEY }}" > ~/.ssh/id_ed25519 | |
| chmod 600 ~/.ssh/id_ed25519 | |
| ssh-keyscan -H ${{ secrets.LIGHTSAIL_PROD_HOST }} >> ~/.ssh/known_hosts | |
| echo "SSH 설정 완료" | |
| - name: Deploy to server | |
| run: | | |
| ssh -i ~/.ssh/id_ed25519 ${{ secrets.LIGHTSAIL_PROD_USER }}@${{ secrets.LIGHTSAIL_PROD_HOST }} << EOF | |
| # 용량 확보를 위해 도커 컨테이너, 이미지 먼저 정리 | |
| echo "사용하지 않는 컨테이너, 이미지, 네트워크 정리 중 (볼륨제외)..." | |
| sudo docker system prune -a -f | |
| # 디렉토리 없으면 생성 | |
| if [ ! -d "$HOME/front/study-platform-client-prod" ]; then | |
| mkdir -p "$HOME/front/study-platform-client-prod" | |
| echo "디렉토리 생성 완료" | |
| fi | |
| cd ~/front/study-platform-client-prod | |
| # git 저장소 없으면 clone, 있으면 fetch + reset (덮어쓰기) | |
| if [ ! -d ".git" ]; then | |
| git clone git@github.com:code-zero-to-one/study-platform-client.git . | |
| echo "Git clone 완료" | |
| else | |
| git fetch origin | |
| git reset --hard origin/main | |
| echo "Git fetch & reset 완료" | |
| fi | |
| git fetch origin | |
| git checkout main | |
| git pull origin main | |
| echo ".env 파일 생성" | |
| echo "NEXT_PUBLIC_API_BASE_URL=${{ secrets.NEXT_PUBLIC_API_PROD_BASE_URL }}" > .env | |
| echo "NEXT_PUBLIC_GTM_ID=${{ secrets.NEXT_PUBLIC_GTM_ID }}" >> .env | |
| echo "도커 컴포즈 재시작" | |
| sudo docker stop study-platform-client-prod-frontend-1 | |
| sudo docker rm study-platform-client-prod-frontend-1 | |
| sudo docker compose up -d --build | |
| echo "운영 서버 배포 완료" | |
| EOF |