Skip to content

Add Apache license

Add Apache license #25

Workflow file for this run

# SPDX-FileCopyrightText: © 2025 StreamKit Contributors
#
# SPDX-License-Identifier: MPL-2.0
name: Docker Build and Publish
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: "Image tag to publish (defaults to sha-<short>)"
required: false
default: ""
push:
description: "Push to GHCR (disable for build-only smoke test)"
required: false
default: true
type: boolean
build_cpu:
description: "Build CPU image"
required: false
default: true
type: boolean
build_gpu:
description: "Build GPU image"
required: false
default: true
type: boolean
build_demo:
description: "Build demo image"
required: false
default: true
type: boolean
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-cpu:
name: Build CPU Image
if: ${{ github.event_name == 'push' || inputs.build_cpu }}
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: meta
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION_INPUT='${{ inputs.tag }}'
if [[ -n "${VERSION_INPUT}" ]]; then
VERSION="${VERSION_INPUT}"
else
VERSION="sha-${GITHUB_SHA::12}"
fi
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Building version: ${VERSION}"
{
echo "tags<<EOF"
echo "${REGISTRY}/${IMAGE_NAME}:${VERSION}"
if [[ "${GITHUB_REF}" == refs/tags/* ]] && [[ "$VERSION" != *-* ]]; then
echo "${REGISTRY}/${IMAGE_NAME}:latest"
fi
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build and push CPU image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name == 'push' || inputs.push }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/mnt/docker-cache
cache-to: type=local,dest=/mnt/docker-cache,mode=max
platforms: linux/amd64
provenance: false
build-gpu:
name: Build GPU Image
if: ${{ github.event_name == 'push' || inputs.build_gpu }}
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: meta
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION_INPUT='${{ inputs.tag }}'
if [[ -n "${VERSION_INPUT}" ]]; then
VERSION="${VERSION_INPUT}"
else
VERSION="sha-${GITHUB_SHA::12}"
fi
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Building version: ${VERSION}"
{
echo "tags<<EOF"
echo "${REGISTRY}/${IMAGE_NAME}:${VERSION}-gpu"
if [[ "${GITHUB_REF}" == refs/tags/* ]] && [[ "$VERSION" != *-* ]]; then
echo "${REGISTRY}/${IMAGE_NAME}:latest-gpu"
fi
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build and push GPU image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.gpu
push: ${{ github.event_name == 'push' || inputs.push }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/mnt/docker-cache
cache-to: type=local,dest=/mnt/docker-cache,mode=max
platforms: linux/amd64
provenance: false
build-demo:
name: Build Demo Image
if: ${{ github.event_name == 'push' || inputs.build_demo }}
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: meta
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION_INPUT='${{ inputs.tag }}'
if [[ -n "${VERSION_INPUT}" ]]; then
VERSION="${VERSION_INPUT}"
else
VERSION="sha-${GITHUB_SHA::12}"
fi
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Building version: ${VERSION}"
{
echo "tags<<EOF"
echo "${REGISTRY}/${IMAGE_NAME}:${VERSION}-demo"
if [[ "${GITHUB_REF}" == refs/tags/* ]] && [[ "$VERSION" != *-* ]]; then
echo "${REGISTRY}/${IMAGE_NAME}:latest-demo"
fi
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build and push Demo image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.demo
push: ${{ github.event_name == 'push' || inputs.push }}
tags: ${{ steps.meta.outputs.tags }}
secrets: |
hf_token=${{ secrets.HF_TOKEN }}
cache-from: type=local,src=/mnt/docker-cache
cache-to: type=local,dest=/mnt/docker-cache,mode=max
platforms: linux/amd64
provenance: false