Skip to content

Build and push Docker images #55

Build and push Docker images

Build and push Docker images #55

Workflow file for this run

name: Build and push Docker images
on:
workflow_run:
workflows:
- "Gateway Python tests"
types:
- completed
workflow_dispatch:
env:
REGISTRY: docker.io
jobs:
build-and-push:
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success'
permissions:
contents: read
packages: write
id-token: write
attestations: write
strategy:
matrix:
service: [ gateway, scheduler, ripper, migrations ]
include:
- service: gateway
image: cogstacksystems/cogstack-model-gateway
dockerfile: ./cogstack_model_gateway/gateway/Dockerfile
- service: scheduler
image: cogstacksystems/cogstack-model-gateway-scheduler
dockerfile: ./cogstack_model_gateway/scheduler/Dockerfile
- service: ripper
image: cogstacksystems/cogstack-model-gateway-ripper
dockerfile: ./cogstack_model_gateway/ripper/Dockerfile
- service: migrations
image: cogstacksystems/cogstack-model-gateway-migrations
dockerfile: ./cogstack_model_gateway/migrations/Dockerfile
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push ${{ matrix.service }}
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max