From aee7b769f199f2ec243a188b914e6fba8d9dd9ec Mon Sep 17 00:00:00 2001 From: spelech <28486500+spelech@users.noreply.github.com> Date: Fri, 21 Aug 2026 21:59:46 +0000 Subject: [PATCH] feat(docker): add batteries-included Docker image variant for STDIO Update Dockerfile with multi-stage targets for runtime and runtime-full, pre-installing Node.js, Python 3, uv, and bun in the full variant. Update docker-publish.yml workflow to build and push both standard and -full tags. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- .github/workflows/docker-publish.yml | 41 +++++++++++++++++++++++----- Dockerfile | 22 +++++++++++++-- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f73f94e..3f4b164 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -38,8 +38,8 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta + - name: Extract metadata (tags, labels) for standard Docker image + id: meta-standard uses: docker/metadata-action@v6 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} @@ -51,15 +51,42 @@ jobs: type=ref,event=branch type=sha + - name: Extract metadata (tags, labels) for full Docker image + id: meta-full + uses: docker/metadata-action@v6 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + suffix=-full,onlatest=true + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }} + type=ref,event=branch + type=sha + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - - name: Build and push Docker image + - name: Build and push standard Docker image + uses: docker/build-push-action@v7 + with: + context: . + target: runtime + push: true + tags: ${{ steps.meta-standard.outputs.tags }} + labels: ${{ steps.meta-standard.outputs.labels }} + cache-from: type=gha,scope=runtime + cache-to: type=gha,mode=max,scope=runtime + + - name: Build and push full Docker image uses: docker/build-push-action@v7 with: context: . + target: runtime-full push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + tags: ${{ steps.meta-full.outputs.tags }} + labels: ${{ steps.meta-full.outputs.labels }} + cache-from: type=gha,scope=runtime-full + cache-to: type=gha,mode=max,scope=runtime-full diff --git a/Dockerfile b/Dockerfile index 42ecffc..08c99f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,8 @@ COPY . ./ COPY --from=frontend-build /wwwroot ./wwwroot RUN dotnet publish mcp-router.csproj -c Release -o /app -# Stage 3: Final runtime image -FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final +# Stage 3: Standard runtime image +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime WORKDIR /app # Install native dependencies for SQLite / SQLCipher bundle if any @@ -42,3 +42,21 @@ ENV ASPNETCORE_URLS=http://+:8080 \ # Run the app ENTRYPOINT ["dotnet", "mcp-router.dll"] + +# Stage 4: "Batteries-Included" full runtime image for STDIO backends +FROM runtime AS runtime-full + +# Install Python 3, Node.js, npm, ca-certificates, and curl +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3 \ + python3-pip \ + python3-venv \ + nodejs \ + npm \ + ca-certificates \ + curl \ + && rm -rf /var/lib/apt/lists/* + +# Copy pre-compiled uv and bun binaries from official images +COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv +COPY --from=oven/bun:latest /usr/local/bin/bun /usr/local/bin/bun