Skip to content

Docker Build and Publish #16

Docker Build and Publish

Docker Build and Publish #16

name: Docker Build and Publish
on:
push:
tags:
- 'v*'
paths:
- 'cmd/**'
- 'internal/**'
- 'pkg/**'
- 'deploy/docker/**'
- 'go.mod'
- 'go.sum'
workflow_dispatch:
inputs:
branch:
description: 'Branch to build from'
required: true
default: 'main'
version:
description: 'Version tag for the image'
required: true
default: 'latest'
env:
DOCKER_HUB_USERNAME: ifuryst
ALIYUN_REGISTRY: registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch || github.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Login to Docker Hub
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Login to GitHub Container Registry
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Aliyun Container Registry
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v3
with:
registry: ${{ env.ALIYUN_REGISTRY }}
username: ${{ secrets.ALIYUN_USERNAME }}
password: ${{ secrets.ALIYUN_PASSWORD }}
- name: Build and push allinone image
uses: docker/build-push-action@v5
with:
context: .
file: deploy/docker/allinone/Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
${{ env.DOCKER_HUB_USERNAME }}/mcp-gateway-allinone:${{ github.event.inputs.version || github.ref_name }}
ghcr.io/${{ github.repository }}/allinone:${{ github.event.inputs.version || github.ref_name }}
${{ env.ALIYUN_REGISTRY }}/mcp-gateway-allinone:${{ github.event.inputs.version || github.ref_name }}
- name: Build and push apiserver image
uses: docker/build-push-action@v5
with:
context: .
file: deploy/docker/multi/apiserver/Dockerfile
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
platforms: linux/amd64,linux/arm64
tags: |
${{ env.DOCKER_HUB_USERNAME }}/mcp-gateway-apiserver:latest
${{ env.DOCKER_HUB_USERNAME }}/mcp-gateway-apiserver:${{ github.ref_name }}
ghcr.io/${{ github.repository }}/apiserver:latest
ghcr.io/${{ github.repository }}/apiserver:${{ github.ref_name }}
${{ env.ALIYUN_REGISTRY }}/mcp-gateway-apiserver:latest
${{ env.ALIYUN_REGISTRY }}/mcp-gateway-apiserver:${{ github.ref_name }}
- name: Build and push mcp-gateway image
uses: docker/build-push-action@v5
with:
context: .
file: deploy/docker/multi/mcp-gateway/Dockerfile
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
platforms: linux/amd64,linux/arm64
tags: |
${{ env.DOCKER_HUB_USERNAME }}/mcp-gateway-mcp-gateway:latest
${{ env.DOCKER_HUB_USERNAME }}/mcp-gateway-mcp-gateway:${{ github.ref_name }}
ghcr.io/${{ github.repository }}/mcp-gateway:latest
ghcr.io/${{ github.repository }}/mcp-gateway:${{ github.ref_name }}
${{ env.ALIYUN_REGISTRY }}/mcp-gateway-mcp-gateway:latest
${{ env.ALIYUN_REGISTRY }}/mcp-gateway-mcp-gateway:${{ github.ref_name }}
- name: Build and push mock-user-svc image
uses: docker/build-push-action@v5
with:
context: .
file: deploy/docker/multi/mock-user-svc/Dockerfile
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
platforms: linux/amd64,linux/arm64
tags: |
${{ env.DOCKER_HUB_USERNAME }}/mcp-gateway-mock-user-svc:latest
${{ env.DOCKER_HUB_USERNAME }}/mcp-gateway-mock-user-svc:${{ github.ref_name }}
ghcr.io/${{ github.repository }}/mock-user-svc:latest
ghcr.io/${{ github.repository }}/mock-user-svc:${{ github.ref_name }}
${{ env.ALIYUN_REGISTRY }}/mcp-gateway-mock-user-svc:latest
${{ env.ALIYUN_REGISTRY }}/mcp-gateway-mock-user-svc:${{ github.ref_name }}