-
Notifications
You must be signed in to change notification settings - Fork 55
Configure multi-architecture Docker builds (amd64/arm64) #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0f699be
a3af5c3
8caec50
13b9573
eaa9cac
9c593e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
||
|
|
||
| - 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
|
||
| 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 | ||
|
||
|
|
||
| # Runtime stage | ||
| FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime | ||
| WORKDIR /app | ||
|
Comment on lines
+23
to
+24
|
||
|
|
||
| # Copy published application from build stage | ||
| COPY --from=build /app/publish . | ||
|
|
||
| # Expose port | ||
| EXPOSE 8000 | ||
|
|
||
| # Set entrypoint | ||
| ENTRYPOINT ["dotnet", "Microsoft.McpGateway.Service.dll"] | ||
| 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 | ||
|
||
|
|
||
| # Runtime stage | ||
| FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime | ||
| WORKDIR /app | ||
|
Comment on lines
+23
to
+24
|
||
|
|
||
| # Copy published application from build stage | ||
| COPY --from=build /app/publish . | ||
|
|
||
| # Expose port | ||
| EXPOSE 8000 | ||
|
|
||
| # Set entrypoint | ||
| ENTRYPOINT ["dotnet", "Microsoft.McpGateway.Tools.dll"] | ||
There was a problem hiding this comment.
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-fromandcache-toparameters to leverage GitHub Actions cache. For example:This will cache Docker layers between builds and speed up subsequent builds.