Build container images for easy MCP use

This commit is contained in:
Wolfgang Nagele 2026-11-05 10:07:37 -05:00
parent eb294e9b14
commit f19b337d7b
6 changed files with 174 additions and 0 deletions

View file

@ -73,3 +73,10 @@ jobs:
# Pre-releases are for testing and never go live.
if: steps.v.outputs.skip == 'false' && steps.v.outputs.pre == 'false'
run: gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "${{ steps.v.outputs.tag }}" -f tag="${{ steps.v.outputs.tag }}"
- name: Publish the Docker image
# Same pattern as the deploy above: the image is built and pushed from the
# release tag by docker.yml. Pre-releases get one too: an image tag is
# pulled on purpose, so a test image costs nothing.
if: steps.v.outputs.skip == 'false'
run: gh workflow run docker.yml --repo "$GITHUB_REPOSITORY" --ref "${{ steps.v.outputs.tag }}" -f tag="${{ steps.v.outputs.tag }}"

72
.github/workflows/docker.yml vendored Normal file
View file

@ -0,0 +1,72 @@
name: Build and push Docker image
# Every push to main publishes :latest and :<sha>. A release publishes :<version>
# built from its tag: auto-release.yml dispatches this workflow alongside the Pages
# deploy, because releases created with the workflow token do not fire the
# "released" event. Hand-published releases fire it directly.
on:
push:
branches: [main]
release:
types: [released, prereleased]
workflow_dispatch:
inputs:
tag:
description: Existing release tag to build (e.g. v2.10.0); empty builds main
required: false
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || inputs.tag }}
- name: Work out the image tags
id: tags
env:
TAG: ${{ github.event.release.tag_name || inputs.tag }}
run: |
set -euo pipefail
# The image is named after this repository (ghcr.io/<owner>/<repo>, lowercased).
image=ghcr.io/${GITHUB_REPOSITORY,,}
if [ -n "$TAG" ]; then
want="v$(jq -r .version package.json)"
if [ "$TAG" != "$want" ]; then
echo "::error::Release tag $TAG does not match package.json version ($want)"
exit 1
fi
echo "tags=$image:${TAG#v}" >> "$GITHUB_OUTPUT"
else
echo "tags=$image:latest,$image:$GITHUB_SHA" >> "$GITHUB_OUTPUT"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max