dev-mcps/publish-images.sh

37 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# Builds the MCP images for amd64 and arm64 and pushes them to Docker Hub, tagged with this
# repository's commit hash and "latest". Usage: ./publish-images.sh [image ...] (default: all five)
#
# The tag names a commit, so the working tree must be clean: an image built from uncommitted code
# would carry a hash that does not describe it.
set -eu
cd "$(dirname "$0")"
REGISTRY="${REGISTRY:-luciolelii}"
PLATFORMS="${PLATFORMS:-linux/amd64,linux/arm64}"
BUILDER="${BUILDER:-mcp-publisher}"
ALL="coding-agent-mcp dev-server-mcp browser-mcp minio-mcp postgres-mcp"
if [ -n "$(git status --porcelain)" ]; then
echo "The working tree is not clean; commit or stash first, so the tag describes what was built." >&2
exit 1
fi
TAG="$(git rev-parse --short HEAD)"
# A multi-platform build needs a builder that can run both architectures; Docker's default one
# cannot push a multi-platform image.
docker buildx inspect "$BUILDER" >/dev/null 2>&1 \
|| docker buildx create --name "$BUILDER" --driver docker-container --bootstrap
for image in ${*:-$ALL}; do
[ -f "$image/Dockerfile" ] || { echo "No such image: $image" >&2; exit 1; }
echo "==> $REGISTRY/$image:$TAG ($PLATFORMS)"
docker buildx build --builder "$BUILDER" --platform "$PLATFORMS" \
-t "$REGISTRY/$image:$TAG" -t "$REGISTRY/$image:latest" \
--push "$image"
done
echo
echo "Published with tag $TAG. To deploy it, set MCP_IMAGE_TAG=$TAG in the deployment repository."