Feat : docker compose 명령어 수정 #207
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: Deploy to GCP Compute Engine | |
| on: | |
| push: | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Create FCM key file | |
| run: | | |
| mkdir -p src/main/resources | |
| echo '${{ secrets.FCM_SERVICE_ACCOUNT }}' > src/main/resources/tinybite_fcm.json | |
| - name: Build JAR | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew clean bootJar -x test | |
| cp $(ls build/libs/*.jar | grep -v plain | head -n 1) app.jar | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_TOKEN }} | |
| - name: Build & Push Docker image | |
| run: | | |
| IMAGE=${{ env.REGISTRY }}/${GITHUB_REPOSITORY,,}:latest | |
| docker build -t $IMAGE . | |
| docker push $IMAGE | |
| - name: Create .env file | |
| run: printf "%s" "${{ secrets.ENV_FILE }}" > .env | |
| - name: Copy files to Compute Engine | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_KEY }} | |
| port: 22 | |
| source: ".env,docker-compose.common.yml,nginx/" | |
| target: "/home/ubuntu/tinybite/" | |
| - name: Deploy on Compute Engine | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_KEY }} | |
| port: 22 | |
| script: | | |
| set -e | |
| cd /home/ubuntu/tinybite | |
| echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io \ | |
| -u ${{ github.actor }} --password-stdin | |
| echo "📦 이미지 pull 중..." | |
| docker-compose -f docker/docker-compose.common.yml pull | |
| echo "🚀 컨테이너 재시작..." | |
| docker-compose -f docker/docker-compose.common.yml up -d | |
| echo "🧹 정리 중..." | |
| docker image prune -f | |
| echo "✅ 배포 완료" |