Skip to content

Commit 621919a

Browse files
Switch to uv-less final stages
1 parent 4fa1c47 commit 621919a

File tree

4 files changed

+48
-18
lines changed

4 files changed

+48
-18
lines changed

Diff for: src/git/Dockerfile

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use a Python image with uv pre-installed
2-
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS uv
33

44
# Install the project into `/app`
55
WORKDIR /app
@@ -10,22 +10,29 @@ ENV UV_COMPILE_BYTECODE=1
1010
# Copy from the cache instead of linking since it's a mounted volume
1111
ENV UV_LINK_MODE=copy
1212

13-
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
14-
1513
# Install the project's dependencies using the lockfile and settings
1614
RUN --mount=type=cache,target=/root/.cache/uv \
1715
--mount=type=bind,source=uv.lock,target=uv.lock \
1816
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
19-
uv sync --frozen --no-install-project --no-dev
17+
uv sync --frozen --no-install-project --no-dev --no-editable
2018

2119
# Then, add the rest of the project source code and install it
2220
# Installing separately from its dependencies allows optimal layer caching
2321
ADD . /app
2422
RUN --mount=type=cache,target=/root/.cache/uv \
25-
uv sync --frozen --no-dev
23+
uv sync --frozen --no-dev --no-editable
24+
25+
FROM python:3.12-slim-bookworm
26+
27+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
28+
29+
WORKDIR /app
30+
31+
COPY --from=uv /root/.local /root/.local
32+
COPY --from=uv --chown=app:app /app/.venv /app/.venv
2633

2734
# Place executables in the environment at the front of the path
2835
ENV PATH="/app/.venv/bin:$PATH"
2936

3037
# when running the container, add --db-path and a bind mount to the host's db file
31-
ENTRYPOINT ["uv" , "run" , "--directory", ".", "mcp-server-git"]
38+
ENTRYPOINT ["mcp-server-git"]

Diff for: src/sentry/Dockerfile

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use a Python image with uv pre-installed
2-
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS uv
33

44
# Install the project into `/app`
55
WORKDIR /app
@@ -14,16 +14,24 @@ ENV UV_LINK_MODE=copy
1414
RUN --mount=type=cache,target=/root/.cache/uv \
1515
--mount=type=bind,source=uv.lock,target=uv.lock \
1616
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
17-
uv sync --frozen --no-install-project --no-dev
17+
uv sync --frozen --no-install-project --no-dev --no-editable
1818

1919
# Then, add the rest of the project source code and install it
2020
# Installing separately from its dependencies allows optimal layer caching
2121
ADD . /app
2222
RUN --mount=type=cache,target=/root/.cache/uv \
23-
uv sync --frozen --no-dev
23+
uv sync --frozen --no-dev --no-editable
24+
25+
FROM python:3.12-slim-bookworm
26+
27+
WORKDIR /app
28+
29+
COPY --from=uv /root/.local /root/.local
30+
COPY --from=uv --chown=app:app /app/.venv /app/.venv
2431

2532
# Place executables in the environment at the front of the path
2633
ENV PATH="/app/.venv/bin:$PATH"
2734

2835
# when running the container, add --db-path and a bind mount to the host's db file
29-
ENTRYPOINT ["uv" , "run" , "--directory", ".", "mcp-server-sentry"]
36+
ENTRYPOINT ["mcp-server-sentry"]
37+

Diff for: src/sqlite/Dockerfile

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use a Python image with uv pre-installed
2-
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS uv
33

44
# Install the project into `/app`
55
WORKDIR /app
@@ -14,16 +14,24 @@ ENV UV_LINK_MODE=copy
1414
RUN --mount=type=cache,target=/root/.cache/uv \
1515
--mount=type=bind,source=uv.lock,target=uv.lock \
1616
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
17-
uv sync --frozen --no-install-project --no-dev
17+
uv sync --frozen --no-install-project --no-dev --no-editable
1818

1919
# Then, add the rest of the project source code and install it
2020
# Installing separately from its dependencies allows optimal layer caching
2121
ADD . /app
2222
RUN --mount=type=cache,target=/root/.cache/uv \
23-
uv sync --frozen --no-dev
23+
uv sync --frozen --no-dev --no-editable
24+
25+
FROM python:3.12-slim-bookworm
26+
27+
WORKDIR /app
28+
29+
COPY --from=uv /root/.local /root/.local
30+
COPY --from=uv --chown=app:app /app/.venv /app/.venv
2431

2532
# Place executables in the environment at the front of the path
2633
ENV PATH="/app/.venv/bin:$PATH"
2734

2835
# when running the container, add --db-path and a bind mount to the host's db file
29-
ENTRYPOINT ["uv" , "run" , "--directory", ".", "mcp-server-sqlite"]
36+
ENTRYPOINT ["mcp-server-sqlite"]
37+

Diff for: src/time/Dockerfile

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use a Python image with uv pre-installed
2-
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS uv
33

44
# Install the project into `/app`
55
WORKDIR /app
@@ -14,16 +14,23 @@ ENV UV_LINK_MODE=copy
1414
RUN --mount=type=cache,target=/root/.cache/uv \
1515
--mount=type=bind,source=uv.lock,target=uv.lock \
1616
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
17-
uv sync --frozen --no-install-project --no-dev
17+
uv sync --frozen --no-install-project --no-dev --no-editable
1818

1919
# Then, add the rest of the project source code and install it
2020
# Installing separately from its dependencies allows optimal layer caching
2121
ADD . /app
2222
RUN --mount=type=cache,target=/root/.cache/uv \
23-
uv sync --frozen --no-dev
23+
uv sync --frozen --no-dev --no-editable
24+
25+
FROM python:3.12-slim-bookworm
26+
27+
WORKDIR /app
28+
29+
COPY --from=uv /root/.local /root/.local
30+
COPY --from=uv --chown=app:app /app/.venv /app/.venv
2431

2532
# Place executables in the environment at the front of the path
2633
ENV PATH="/app/.venv/bin:$PATH"
2734

2835
# when running the container, add --db-path and a bind mount to the host's db file
29-
ENTRYPOINT ["uv" , "run" , "--directory", ".", "mcp-server-time"]
36+
ENTRYPOINT ["mcp-server-time"]

0 commit comments

Comments
 (0)