fix: update input size for FaceDetector and enable TensorRT caching i… #48
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: Docker Build and Publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| jobs: | |
| detect-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| main: ${{ steps.filter.outputs.main }} | |
| inference: ${{ steps.filter.outputs.inference }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| filters: | | |
| main: | |
| - 'main_api/**' | |
| inference: | |
| - 'inference_api/**' | |
| build-and-push-main-api: | |
| needs: detect-changes | |
| if: ${{ needs.detect-changes.outputs.main == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata for main_api | |
| id: meta_main | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ secrets.DOCKERHUB_USERNAME }}/main_api | |
| tags: | | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=sha,format=short | |
| type=semver,pattern={{version}} | |
| - name: Build and push main_api | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: ./main_api | |
| file: ./main_api/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta_main.outputs.tags }} | |
| labels: ${{ steps.meta_main.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-and-push-inference-cpu: | |
| needs: detect-changes | |
| if: ${{ needs.detect-changes.outputs.inference == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata for inference_api (CPU) | |
| id: meta_cpu | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ secrets.DOCKERHUB_USERNAME }}/inference_api | |
| tags: | | |
| type=raw,value=cpu-latest,enable={{is_default_branch}} | |
| type=sha,format=short,prefix=cpu- | |
| type=semver,pattern=cpu-{{version}} | |
| - name: Build and push inference_api (CPU) | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: ./inference_api | |
| file: ./inference_api/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta_cpu.outputs.tags }} | |
| labels: ${{ steps.meta_cpu.outputs.labels }} | |
| cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/inference_api:buildcache-cpu | |
| cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/inference_api:buildcache-cpu,mode=max | |
| build-and-push-inference-gpu: | |
| needs: detect-changes | |
| if: ${{ needs.detect-changes.outputs.inference == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata for inference_api (GPU) | |
| id: meta_gpu | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ secrets.DOCKERHUB_USERNAME }}/inference_api | |
| tags: | | |
| type=raw,value=gpu-latest,enable={{is_default_branch}} | |
| type=sha,format=short,prefix=gpu- | |
| type=semver,pattern=gpu-{{version}} | |
| - name: Build and push inference_api (GPU) | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: ./inference_api | |
| file: ./inference_api/Dockerfile.gpu | |
| push: true | |
| tags: ${{ steps.meta_gpu.outputs.tags }} | |
| labels: ${{ steps.meta_gpu.outputs.labels }} | |
| cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/inference_api:buildcache-gpu | |
| cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/inference_api:buildcache-gpu,mode=max | |
| deploy-all: | |
| needs: [build-and-push-main-api, build-and-push-inference-gpu] | |
| if: | | |
| always() && | |
| (needs.build-and-push-main-api.result != 'failure' && needs.build-and-push-main-api.result != 'cancelled') && | |
| (needs.build-and-push-inference-gpu.result != 'failure' && needs.build-and-push-inference-gpu.result != 'cancelled') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Generate .env from Infisical | |
| run: | | |
| curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | sudo -E bash | |
| sudo apt-get install -y infisical | |
| export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id="${{ secrets.INFISICAL_MACHINE_IDENTITY_CLIENT_ID }}" --client-secret="${{ secrets.INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET }}" --plain --silent) | |
| infisical export --projectId="${{ secrets.INFISICAL_PROJECT_ID }}" --env=prod --format=dotenv > .env | |
| - name: Prepare configs for VM | |
| run: | | |
| mkdir -p rabbitmq | |
| cp config/rabbitmq/rabbitmq.conf rabbitmq/rabbitmq.conf | |
| - name: Fix permissions on GCP VM before SCP | |
| uses: appleboy/ssh-action@v1.2.3 | |
| with: | |
| host: ${{ secrets.GCP_VM_IP }} | |
| username: github-actions | |
| key: ${{ secrets.GCP_SSH_PRIVATE_KEY }} | |
| script: | | |
| sudo mkdir -p /app | |
| sudo chown -R github-actions:github-actions /app | |
| - name: Copy Compose and configs to VM | |
| uses: appleboy/scp-action@v1 | |
| with: | |
| host: ${{ secrets.GCP_VM_IP }} | |
| username: github-actions | |
| key: ${{ secrets.GCP_SSH_PRIVATE_KEY }} | |
| source: "docker-compose.yml,rabbitmq/rabbitmq.conf,.env" | |
| target: "/app" | |
| - name: Deploy to Google Cloud VM | |
| uses: appleboy/ssh-action@v1.2.3 | |
| with: | |
| host: ${{ secrets.GCP_VM_IP }} | |
| username: github-actions | |
| key: ${{ secrets.GCP_SSH_PRIVATE_KEY }} | |
| script: | | |
| cd /app | |
| sudo docker compose pull | |
| sudo docker compose up -d |