[Hotfix] 모델 다운로드 시 메모르 직시 해제로 OOM방지 #3
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
| # =========================================== | |
| # PIILOT AI Server CI/CD 파이프라인 | |
| # =========================================== | |
| # main 브랜치에 push되면 자동으로 실행됩니다. | |
| # | |
| # 흐름: | |
| # 1. 코드 체크아웃 | |
| # 2. Docker 이미지 빌드 (Dockerfile 사용) | |
| # 3. DockerHub에 이미지 push | |
| # 4. appspec.yml + deploy.sh를 zip으로 묶어 S3에 업로드 | |
| # 5. CodeDeploy에 배포 명령 | |
| # =========================================== | |
| name: Deploy AI Server | |
| on: | |
| push: | |
| branches: [main] | |
| env: | |
| DOCKERHUB_REPO: chanee29/piilot-ai | |
| S3_BUCKET: piilot-codedeploy-revisions | |
| CODEDEPLOY_APP: piilot | |
| CODEDEPLOY_GROUP: piilot-ec2a | |
| AWS_REGION: ap-northeast-2 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1단계: 코드 가져오기 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 2단계: Docker Buildx 설정 (빌드 캐시 지원) | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # 3단계: DockerHub 로그인 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| # 4단계: Docker 이미지 빌드 + DockerHub에 push | |
| # latest 태그: 항상 최신 버전을 가리킴 | |
| # SHA 태그: 특정 커밋으로 롤백할 때 사용 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ env.DOCKERHUB_REPO }}:latest | |
| ${{ env.DOCKERHUB_REPO }}:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # 5단계: AWS 자격증명 설정 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| # 6단계: CodeDeploy용 배포 번들 생성 | |
| - name: Create CodeDeploy revision bundle | |
| run: | | |
| mkdir -p codedeploy-bundle/scripts | |
| cp appspec.yml codedeploy-bundle/ | |
| cp scripts/deploy.sh codedeploy-bundle/scripts/ | |
| chmod +x codedeploy-bundle/scripts/deploy.sh | |
| cd codedeploy-bundle | |
| zip -r ../revision.zip . | |
| # 7단계: S3에 번들 업로드 | |
| - name: Upload revision to S3 | |
| run: | | |
| aws s3 cp revision.zip \ | |
| s3://${{ env.S3_BUCKET }}/ai-server/${{ github.sha }}.zip | |
| # 8단계: CodeDeploy에 배포 명령 | |
| - name: Trigger CodeDeploy deployment | |
| run: | | |
| aws deploy create-deployment \ | |
| --application-name ${{ env.CODEDEPLOY_APP }} \ | |
| --deployment-group-name ${{ env.CODEDEPLOY_GROUP }} \ | |
| --s3-location \ | |
| bucket=${{ env.S3_BUCKET }},key=ai-server/${{ github.sha }}.zip,bundleType=zip \ | |
| --deployment-config-name CodeDeployDefault.AllAtOnce \ | |
| --description "AI Server deploy from commit ${{ github.sha }}" |