Skip to content

Build and publish Docker images #1

Build and publish Docker images

Build and publish Docker images #1

Workflow file for this run

name: Build and publish Docker images
on:
workflow_dispatch:
inputs:
image_tag:
description: Additional image tag to publish
required: true
default: latest
type: string
permissions:
contents: read
packages: write
concurrency:
group: publish-docker-images
cancel-in-progress: false
jobs:
build:
name: Build ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: backend
dockerfile: python/backend/Dockerfile
- name: scalars
dockerfile: python/scalars_service/Dockerfile
- name: object-storage
dockerfile: python/object_storage/Dockerfile
- name: web
dockerfile: apps/web/Dockerfile
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare image name
id: image
shell: bash
env:
IMAGE_TAG: ${{ inputs.image_tag }}
run: |
if [[ ! "$IMAGE_TAG" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]]; then
echo "Invalid Docker image tag: $IMAGE_TAG" >&2
exit 1
fi
echo "name=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/experiment-tracker-${{ matrix.name }}" >> "$GITHUB_OUTPUT"
echo "tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: |
${{ steps.image.outputs.name }}:${{ steps.image.outputs.tag }}
${{ steps.image.outputs.name }}:${{ github.sha }}
cache-from: type=gha,scope=${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.name }}