-
Notifications
You must be signed in to change notification settings - Fork 562
feat(MCP): Add Docker image and release publishing #7694
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
65657c2
implement http oauth resource server
khvn26 6431750
feat(MCP): Add Docker image and release publishing
khvn26 92f1166
ci(MCP): Publish image to ECR on release
khvn26 14db47c
ci(MCP): Publish image to staging ECR on push to main
khvn26 8b7ef03
Merge branch 'main' into feat/mcp-docker
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| name: MCP Build Docker Image and Publish | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - mcp/** | ||
| - .github/workflows/mcp-docker-build-publish.yml | ||
| - .github/workflows/.reusable-docker-build.yml | ||
| - .github/workflows/.reusable-docker-publish.yml | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - mcp/** | ||
| - .github/workflows/mcp-docker-build-publish.yml | ||
| - .github/workflows/.reusable-docker-build.yml | ||
| - .github/workflows/.reusable-docker-publish.yml | ||
| release: | ||
| types: | ||
| - released | ||
|
|
||
| jobs: | ||
| docker-build-mcp: | ||
| name: Build MCP Image | ||
| uses: ./.github/workflows/.reusable-docker-build.yml | ||
| with: | ||
| file: mcp/Dockerfile | ||
| image-name: flagsmith-mcp | ||
| # On pull requests, validate the build without pushing to the registry. | ||
| ephemeral: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| # Publish to Docker Hub | ||
|
|
||
| docker-publish-mcp: | ||
| needs: [docker-build-mcp] | ||
| uses: ./.github/workflows/.reusable-docker-publish.yml | ||
| if: github.event_name == 'release' | ||
| with: | ||
| source-images: ${{ needs.docker-build-mcp.outputs.image }} | ||
| target-images: flagsmith/flagsmith-mcp | ||
| secrets: inherit | ||
|
|
||
| # Publish to Quay.io | ||
|
|
||
| docker-publish-quay-mcp: | ||
|
khvn26 marked this conversation as resolved.
|
||
| needs: [docker-build-mcp] | ||
| uses: ./.github/workflows/.reusable-docker-publish.yml | ||
| if: github.event_name == 'release' | ||
| with: | ||
| target-registry-url: quay.io | ||
| docker-username: ${{ vars.QUAY_PUBLISH_USERNAME }} | ||
| docker-password-secret-name: QUAY_PUBLISH_PASSWORD | ||
| source-images: ${{ needs.docker-build-mcp.outputs.image }} | ||
| target-images: quay.io/${{ vars.QUAY_ORGANISATION_NAME }}/flagsmith-mcp | ||
| secrets: inherit | ||
|
|
||
| # Publish to staging Amazon ECR on every push to main | ||
|
|
||
| docker-publish-ecr-staging-mcp: | ||
|
khvn26 marked this conversation as resolved.
|
||
| name: Publish MCP image to staging ECR | ||
| needs: [docker-build-mcp] | ||
| if: github.event_name == 'push' | ||
| runs-on: depot-ubuntu-latest | ||
| # The OIDC role trusts jobs running in the staging environment. | ||
| environment: staging | ||
| permissions: | ||
| contents: read | ||
| packages: read | ||
| id-token: write | ||
| steps: | ||
| - name: Cloning repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| sparse-checkout: depot.json | ||
| sparse-checkout-cone-mode: false | ||
|
|
||
| - name: Login to Github Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ vars.MCP_ECR_GITHUB_ROLE_ARN }} | ||
| aws-region: eu-west-2 | ||
|
|
||
| - name: Login to Amazon ECR | ||
| uses: aws-actions/amazon-ecr-login@v1 | ||
|
|
||
| - name: Docker metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ vars.MCP_ECR_REPOSITORY_URL }} | ||
| tags: | | ||
| type=ref,event=branch | ||
| type=sha | ||
|
|
||
| # Setup Docker buildx with Depot builder so imagetools have access to Depot cache | ||
| - uses: depot/use-action@v1 | ||
|
|
||
| - name: Publish Image | ||
| uses: kphrx/docker-buildx-imagetools-action@v0.1.2 | ||
| with: | ||
| sources: ${{ needs.docker-build-mcp.outputs.image }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
|
|
||
| # Publish to production Amazon ECR on release | ||
|
|
||
| docker-publish-ecr-mcp: | ||
| name: Publish MCP image to ECR | ||
| needs: [docker-build-mcp] | ||
| if: github.event_name == 'release' | ||
| runs-on: depot-ubuntu-latest | ||
| # The OIDC role trusts jobs running in the production environment. | ||
| environment: production | ||
| permissions: | ||
| contents: read | ||
| packages: read | ||
| id-token: write | ||
| steps: | ||
| - name: Cloning repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| sparse-checkout: depot.json | ||
| sparse-checkout-cone-mode: false | ||
|
|
||
| - name: Login to Github Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ vars.MCP_ECR_GITHUB_ROLE_ARN }} | ||
| aws-region: eu-west-2 | ||
|
|
||
| - name: Login to Amazon ECR | ||
| uses: aws-actions/amazon-ecr-login@v1 | ||
|
|
||
| - name: Docker metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ vars.MCP_ECR_REPOSITORY_URL }} | ||
| tags: | | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
|
|
||
| # Setup Docker buildx with Depot builder so imagetools have access to Depot cache | ||
| - uses: depot/use-action@v1 | ||
|
|
||
| - name: Publish Image | ||
| uses: kphrx/docker-buildx-imagetools-action@v0.1.2 | ||
| with: | ||
| sources: ${{ needs.docker-build-mcp.outputs.image }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Flagsmith MCP server image. | ||
| # | ||
| # To build locally from the repo root: | ||
| # $ docker build -f mcp/Dockerfile -t flagsmith-mcp:dev . | ||
|
|
||
| ARG CI_COMMIT_SHA=dev | ||
|
|
||
| # Pin runtimes versions | ||
| ARG PYTHON_VERSION=3.13 | ||
| ARG UV_VERSION=0.11.18 | ||
|
|
||
| FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv | ||
| FROM cgr.dev/chainguard/wolfi-base:latest AS wolfi-base | ||
|
|
||
| # * build [wolfi-base] | ||
| FROM wolfi-base AS build | ||
| WORKDIR /build | ||
|
|
||
| ARG PYTHON_VERSION | ||
| RUN apk add build-base \ | ||
| python-${PYTHON_VERSION} \ | ||
| python-${PYTHON_VERSION}-dev | ||
|
|
||
| COPY --from=uv /uv /usr/local/bin/uv | ||
|
|
||
| ENV UV_PROJECT_ENVIRONMENT=/build/.venv \ | ||
| UV_PYTHON_PREFERENCE=only-system \ | ||
| UV_PYTHON=python${PYTHON_VERSION} \ | ||
| UV_LINK_MODE=copy \ | ||
| UV_COMPILE_BYTECODE=1 \ | ||
| UV_CACHE_DIR=/root/.cache/uv | ||
|
|
||
| # Resolve dependencies first so the layer is cached independently of source changes. | ||
| COPY mcp/pyproject.toml mcp/uv.lock ./ | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| uv sync --frozen --no-dev --no-install-project | ||
|
|
||
| # Install the project itself as a non-editable wheel into the venv. | ||
| COPY mcp/README.md ./ | ||
| COPY mcp/src ./src | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| uv sync --frozen --no-dev --no-editable | ||
|
|
||
| # * runtime [wolfi-base] | ||
| FROM wolfi-base AS runtime | ||
|
|
||
| # Install Python and make it available to the venv's entrypoints. | ||
| ARG PYTHON_VERSION | ||
| RUN apk add python-${PYTHON_VERSION} && \ | ||
| mkdir /build/ && ln -s /usr/local/ /build/.venv | ||
|
|
||
| COPY --from=build /build/.venv/ /usr/local/ | ||
|
|
||
| ARG CI_COMMIT_SHA | ||
| RUN echo ${CI_COMMIT_SHA} > /CI_COMMIT_SHA | ||
|
|
||
| ENV TRANSPORT=http \ | ||
| FASTMCP_HOST=0.0.0.0 \ | ||
| FASTMCP_PORT=8000 | ||
|
|
||
| EXPOSE 8000 | ||
|
|
||
| USER nobody | ||
|
|
||
| ENTRYPOINT ["flagsmith-mcp"] | ||
|
|
||
| HEALTHCHECK --interval=10s --timeout=3s --retries=3 --start-period=10s \ | ||
| CMD ["python", "-c", "import os,urllib.request; urllib.request.urlopen(f\"http://127.0.0.1:{os.environ['FASTMCP_PORT']}/health\", timeout=2)"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.