Skip to content

Build and push docker images #8

Build and push docker images

Build and push docker images #8

Workflow file for this run

name: Build and push docker images
on:
workflow_call:
inputs:
release-tag:
description: Release tag to add to images
required: false
type: string
default: ''
workflow_dispatch:
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_BASE: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
component: [backend, ingester]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}/${{ matrix.component }}
tags: |
type=ref,event=branch
type=sha,format=short
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=${{ inputs.release-tag }},enable=${{ inputs.release-tag != '' }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
file: ./${{ matrix.component }}.dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max