Skip to content

Build & Deploys video processing images #18

Build & Deploys video processing images

Build & Deploys video processing images #18

name: Build & Deploys video processing images
on:
push:
branches: [ master ]
paths:
- '!faceDetectApp/**'
- '!.yml'
workflow_dispatch:
jobs:
build-deploy-container:
continue-on-error: true
strategy:
matrix:
include:
- architecture: amd64
synonym: "amd64"
runson: ubuntu-latest
- architecture: arm64
synonym: "aarch64"
runson: nvidia-gpu
runs-on: ubuntu-latest
env:
DOCKER_REPO: "totosan"
VIDEO_PATH: "https://youtu.be/8vAnc8apiUM?si=f0JG63YMxwhlVuzQ"
ARCH: ${{ matrix.architecture }}
DAPR_USED: True
RESOURCE_GROUP: "MVPSession"
LOCATION: "westeurope"
CONTAINERAPPS_ENVIRONMENT: "ai-tt-env"
CONTAINERAPPS_NAME: "facedetection-app"
CONTAINERAPPSSERVER_NAME: "facedetection-server"
steps:
- uses: actions/checkout@v3
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Login to docker.io
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PWD }}
- uses: satackey/[email protected]
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
with:
key: facedetection-${{ matrix.architecture }}-{hash}
restore-keys: |
facedetection-${{ matrix.architecture }}-
- name: if, build on Jetson Nano, take different Dockerfile
id: dockerfile
run: |
if [ "${{ matrix.architecture }}" == "arm64" ]; then
if [ "${{ runner.arch }}" != "ARM64" ]; then
echo "::set-output name=filename::Dockerfile-arm64xbuild"
else
echo "::set-output name=filename::Dockerfile-arm64"
fi
else
echo "::set-output name=filename::Dockerfile-${{ matrix.architecture }}"
fi
- name: Build the Docker image
run: |
docker build . --file ./Dockers/${{ steps.dockerfile.outputs.filename }} \
--build-arg VIDEO_PATH=$VIDEO_PATH \
--build-arg DAPR_USED=$DAPR_USED \
--tag $DOCKER_REPO/facedetection:${{ matrix.architecture }}-preview
- name: Push the image
run: |
docker push $DOCKER_REPO/facedetection:${{ matrix.architecture }}-preview
### DEPLOYMENT
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: prepare AZ EXTENSION
if: ${{ env.ARCH == 'amd64' }}
run: az extension add --name containerapp
- name: create CONTAINER APP ENVironment
if: ${{ env.ARCH == 'amd64' }}
run: |
az containerapp env create \
--dapr-instrumentation-key ${{ secrets.APP_INSIGHTS_KEY }} \
--name $CONTAINERAPPS_ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--location $LOCATION \
--logs-workspace-id ${{ secrets.LOG_ANALYTICS_WORKSPACE_CLIENT_ID }} \
--logs-workspace-key ${{ secrets.WSKEY }}
- name: create CONTAINER APP with image running
if: ${{ env.ARCH == 'amd64' }}
run: |
az containerapp create \
--image $DOCKER_REPO/facedetection:$ARCH-preview \
--name $CONTAINERAPPS_NAME \
--resource-group $RESOURCE_GROUP \
--environment $CONTAINERAPPS_ENVIRONMENT \
--secrets "app-insight-key=${{ secrets.APP_INSIGHTS_KEY }}" \
--env-vars "APP_INSIGHTS_KEY=secretref:app-insight-key" \
--ingress external\
--target-port 8080\
--cpu 2.0\
--memory 4.0Gi \
--min-replicas 1 \
--max-replicas 1 \
--enable-dapr \
--dapr-app-port 8080 \
--dapr-app-id faceclient