feat: 언론사 이미지 캐싱 도입 #54
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ develop ] | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 코드 체크아웃 | |
| uses: actions/checkout@v3 | |
| - name: Docker Buildx 설정 | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Docker Hub 로그인 | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Docker 이미지 빌드 및 푸시 | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| imfact/imfact-backend:latest | |
| imfact/imfact-backend:${{ github.sha }} | |
| # cache-from: type=registry,ref=imfact/imfact-backend:latest | |
| # cache-to: type=inline | |
| no-cache: true | |
| - name: EC2 배포 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| docker pull imfact/imfact-backend:latest | |
| docker stop imfact || true | |
| docker rm imfact || true | |
| docker run -d \ | |
| --name imfact \ | |
| --network host \ | |
| -e AWS_REGION=${{ secrets.AWS_REGION }} \ | |
| -e AWS_OPENSEARCH_ENDPOINT=${{ secrets.AWS_OPENSEARCH_ENDPOINT }} \ | |
| -e AWS_S3_BUCKET_USER-IMAGES=${{ secrets.AWS_S3_BUCKET_USER_IMAGES }} \ | |
| --restart unless-stopped \ | |
| imfact/imfact-backend:latest | |
| docker image prune -af | |
| - name: 배포 확인 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| echo "=== 컨테이너 상태 ===" | |
| docker ps | grep imfact | |
| echo "=== 최근 로그 ===" | |
| docker logs --tail 50 imfact |