Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,33 @@ jobs:
- name: Checkout source
uses: actions/checkout@v3

- 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 the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
- name: Build and push mcp-gateway multi-arch image
uses: docker/build-push-action@v5
with:
dotnet-version: '8.x'

- name: Restore dependencies
run: dotnet restore dotnet/Microsoft.McpGateway.sln --runtime linux-x64

- name: Publish and push the mcp-gateway container image
run: dotnet publish dotnet/Microsoft.McpGateway.Service/src/Microsoft.McpGateway.Service.csproj --configuration Release --no-restore /p:PublishProfile=github.pubxml /p:ContainerRepository=${{ github.repository_owner }}/mcp-gateway

- name: Publish and push the tool-gateway container image
run: dotnet publish dotnet/Microsoft.McpGateway.Tools/src/Microsoft.McpGateway.Tools.csproj --configuration Release --no-restore /p:PublishProfile=github.pubxml /p:ContainerRepository=${{ github.repository_owner }}/tool-gateway
context: .
file: ./dotnet/Microsoft.McpGateway.Service/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository_owner }}/mcp-gateway:latest
Comment on lines +35 to +42
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build action doesn't configure Docker layer caching, which can significantly improve build times, especially for multi-architecture builds. Consider adding cache-from and cache-to parameters to leverage GitHub Actions cache. For example:

cache-from: type=gha
cache-to: type=gha,mode=max

This will cache Docker layers between builds and speed up subsequent builds.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Docker image is only tagged with latest, which makes it difficult to track versions and roll back if needed. Consider adding versioning tags based on git SHA, tag, or semantic version. For example, you could add tags like ghcr.io/${{ github.repository_owner }}/mcp-gateway:${{ github.sha }} or use docker/metadata-action to automatically generate appropriate tags.

Copilot uses AI. Check for mistakes.

- name: Build and push tool-gateway multi-arch image
uses: docker/build-push-action@v5
with:
context: .
file: ./dotnet/Microsoft.McpGateway.Tools/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository_owner }}/tool-gateway:latest
Comment on lines +44 to +51
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build action doesn't configure Docker layer caching, which can significantly improve build times, especially for multi-architecture builds. Consider adding cache-from and cache-to parameters to leverage GitHub Actions cache. For example:

cache-from: type=gha
cache-to: type=gha,mode=max

This will cache Docker layers between builds and speed up subsequent builds.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Docker image is only tagged with latest, which makes it difficult to track versions and roll back if needed. Consider adding versioning tags based on git SHA, tag, or semantic version. For example, you could add tags like ghcr.io/${{ github.repository_owner }}/tool-gateway:${{ github.sha }} or use docker/metadata-action to automatically generate appropriate tags.

Copilot uses AI. Check for mistakes.
33 changes: 33 additions & 0 deletions dotnet/Microsoft.McpGateway.Service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

# Copy solution and project files
COPY dotnet/Directory.Packages.props dotnet/
COPY dotnet/Microsoft.McpGateway.sln dotnet/
COPY dotnet/Microsoft.McpGateway.Management/src/Microsoft.McpGateway.Management.csproj dotnet/Microsoft.McpGateway.Management/src/
COPY dotnet/Microsoft.McpGateway.Service/src/Microsoft.McpGateway.Service.csproj dotnet/Microsoft.McpGateway.Service/src/

# Restore dependencies
RUN dotnet restore dotnet/Microsoft.McpGateway.Service/src/Microsoft.McpGateway.Service.csproj

# Copy the rest of the source code
COPY dotnet/Microsoft.McpGateway.Management/src dotnet/Microsoft.McpGateway.Management/src/
COPY dotnet/Microsoft.McpGateway.Service/src dotnet/Microsoft.McpGateway.Service/src/

# Build and publish the application
WORKDIR /src/dotnet/Microsoft.McpGateway.Service/src
RUN dotnet publish Microsoft.McpGateway.Service.csproj -c Release -o /app/publish --no-restore
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project file specifies <Platforms>x64</Platforms>, which may conflict with ARM64 builds. While dotnet publish without an explicit runtime identifier can auto-detect the target platform in Docker, this constraint might cause build issues or prevent proper ARM64 compilation. Consider either removing this constraint or adding explicit runtime identifier arguments to the publish command (e.g., --runtime linux-arm64 for ARM64 builds). Alternatively, you could verify that the multi-arch build actually produces native ARM64 binaries rather than running x64 binaries through emulation.

Copilot uses AI. Check for mistakes.

# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
Comment on lines +23 to +24
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Docker container is running as root user, which poses a security risk. The sample Dockerfiles in this repository (e.g., sample-servers/mcp-example/Dockerfile:4-24) create and switch to a non-root user. Consider adding a similar security measure by creating a non-root user and switching to it before the ENTRYPOINT.

Copilot uses AI. Check for mistakes.

# Copy published application from build stage
COPY --from=build /app/publish .

# Expose port
EXPOSE 8000

# Set entrypoint
ENTRYPOINT ["dotnet", "Microsoft.McpGateway.Service.dll"]
33 changes: 33 additions & 0 deletions dotnet/Microsoft.McpGateway.Tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

# Copy solution and project files
COPY dotnet/Directory.Packages.props dotnet/
COPY dotnet/Microsoft.McpGateway.sln dotnet/
COPY dotnet/Microsoft.McpGateway.Management/src/Microsoft.McpGateway.Management.csproj dotnet/Microsoft.McpGateway.Management/src/
COPY dotnet/Microsoft.McpGateway.Tools/src/Microsoft.McpGateway.Tools.csproj dotnet/Microsoft.McpGateway.Tools/src/

# Restore dependencies
RUN dotnet restore dotnet/Microsoft.McpGateway.Tools/src/Microsoft.McpGateway.Tools.csproj

# Copy the rest of the source code
COPY dotnet/Microsoft.McpGateway.Management/src dotnet/Microsoft.McpGateway.Management/src/
COPY dotnet/Microsoft.McpGateway.Tools/src dotnet/Microsoft.McpGateway.Tools/src/

# Build and publish the application
WORKDIR /src/dotnet/Microsoft.McpGateway.Tools/src
RUN dotnet publish Microsoft.McpGateway.Tools.csproj -c Release -o /app/publish --no-restore
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project file specifies <Platforms>x64</Platforms>, which may conflict with ARM64 builds. While dotnet publish without an explicit runtime identifier can auto-detect the target platform in Docker, this constraint might cause build issues or prevent proper ARM64 compilation. Consider either removing this constraint or adding explicit runtime identifier arguments to the publish command (e.g., --runtime linux-arm64 for ARM64 builds). Alternatively, you could verify that the multi-arch build actually produces native ARM64 binaries rather than running x64 binaries through emulation.

Copilot uses AI. Check for mistakes.

# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
Comment on lines +23 to +24
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Docker container is running as root user, which poses a security risk. The sample Dockerfiles in this repository (e.g., sample-servers/mcp-example/Dockerfile:4-24) create and switch to a non-root user. Consider adding a similar security measure by creating a non-root user and switching to it before the ENTRYPOINT.

Copilot uses AI. Check for mistakes.

# Copy published application from build stage
COPY --from=build /app/publish .

# Expose port
EXPOSE 8000

# Set entrypoint
ENTRYPOINT ["dotnet", "Microsoft.McpGateway.Tools.dll"]
Loading