Skip to content

Refactor Dockerfiles for serverless functions #15

Refactor Dockerfiles for serverless functions

Refactor Dockerfiles for serverless functions #15

name: Docker Build and Push Serverless
on:
push:
branches: [ "main" ]
paths:
- 'serverless/**'
- 'api/**'
- 'scripts/**'
- '.github/workflows/**'
pull_request:
branches: [ "main" ]
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
service:
- image-to-video
- text-to-image
- inpainting
- outpainting
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
file: serverless/${{ matrix.service }}/Dockerfile
push: true
tags: ${{secrets.DOCKER_USERNAME }}/picpilot_${{ matrix.service }}:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
notify:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Check build status
run: |
if [ "${{ needs.build-and-push.result }}" == "success" ]; then
echo "All images built and pushed successfully"
else
echo "Some builds failed, check the logs"
exit 1
fi