Skip to content

Commit f8d3444

Browse files
committed
Adds Dockerfile & GH Actions workflow to publish MCP image
1 parent 8744ce2 commit f8d3444

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to Github Container Registry
2+
3+
on: [push]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
publish-docker-image:
11+
permissions:
12+
contents: read
13+
packages: write
14+
attestations: write
15+
id-token: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Login to GitHub Container Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Convert Repository name to lower case
27+
id: lowercase
28+
run: echo "REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
29+
30+
- name: Build the MCP Docker Image
31+
run: docker build . --tag ghcr.io/${{ env.REPO }}
32+
33+
- name: Run the container
34+
run: docker run ghcr.io/${{ env.REPO }}:latest
35+
36+
- name: Publish to GitHub Container Registry
37+
if: success()
38+
run: docker push ghcr.io/${{ env.REPO }}:latest

Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Taken reference from the following Dockerfile examples:
2+
# * UV Docker Example - https://github.com/astral-sh/uv-docker-example/blob/main/multistage.Dockerfile
3+
# * SQLite MCP Server Dockerfile - https://github.com/modelcontextprotocol/servers/blob/main/src/sqlite/Dockerfile
4+
5+
FROM ghcr.io/astral-sh/uv:0.7-python3.10-bookworm-slim AS builder
6+
7+
# Enable bytecode compilation
8+
ENV UV_COMPILE_BYTECODE=1 \
9+
UV_LINK_MODE=copy \
10+
DIRECTORY=mcp_wordle
11+
12+
# Disable Python downloads, because we want to use the system interpreter
13+
# across both images.
14+
ENV UV_PYTHON_DOWNLOADS=0
15+
16+
WORKDIR /app
17+
18+
RUN --mount=type=cache,target=/root/.cache/uv \
19+
--mount=type=bind,source=uv.lock,target=uv.lock \
20+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
21+
--mount=type=bind,source=.python-version,target=.python-version \
22+
uv sync --frozen --no-install-project --no-dev --no-editable
23+
24+
COPY uv.lock /app
25+
COPY pyproject.toml /app
26+
COPY README.md /app
27+
COPY .python-version /app
28+
ADD ./src/${DIRECTORY} /app/${DIRECTORY}
29+
30+
RUN --mount=type=cache,target=/root/.cache/uv \
31+
uv sync --locked --no-dev
32+
33+
# Then, use a final image without uv
34+
FROM python:3.10-slim-bookworm
35+
36+
WORKDIR /app
37+
38+
# Copy the application from the builder
39+
COPY --from=builder --chown=app:app /app /app
40+
41+
# Place executables in the environment at the front of the path
42+
ENV PATH="/app/.venv/bin:$PATH"
43+
ENV PYTHONPATH=/app
44+
45+
# Comes from 'pyproject.toml'
46+
ENTRYPOINT ["mcp-wordle"]

0 commit comments

Comments
 (0)