|
1 |
| -# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile |
2 | 1 | # Use a Python image with uv pre-installed
|
3 | 2 | FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS uv
|
4 | 3 |
|
5 |
| -# Set the working directory in the container |
| 4 | +# Install the project into `/app` |
6 | 5 | WORKDIR /app
|
7 | 6 |
|
8 | 7 | # Enable bytecode compilation
|
9 | 8 | ENV UV_COMPILE_BYTECODE=1
|
10 | 9 |
|
11 |
| -# Copy the necessary project files |
12 |
| -COPY pyproject.toml uv.lock /app/ |
| 10 | +# Copy from the cache instead of linking since it's a mounted volume |
| 11 | +ENV UV_LINK_MODE=copy |
13 | 12 |
|
14 |
| -# Install the project's dependencies using the lockfile |
| 13 | +# Install the project's dependencies using the lockfile and settings |
15 | 14 | RUN --mount=type=cache,target=/root/.cache/uv \
|
| 15 | + --mount=type=bind,source=uv.lock,target=uv.lock \ |
| 16 | + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ |
16 | 17 | uv sync --frozen --no-install-project --no-dev --no-editable
|
17 | 18 |
|
18 |
| -# Add the rest of the project source code and install it |
19 |
| -COPY src /app/src |
20 |
| - |
| 19 | +# Then, add the rest of the project source code and install it |
| 20 | +# Installing separately from its dependencies allows optimal layer caching |
| 21 | +ADD . /app |
21 | 22 | RUN --mount=type=cache,target=/root/.cache/uv \
|
22 | 23 | uv sync --frozen --no-dev --no-editable
|
23 | 24 |
|
24 |
| -# Runtime base |
25 | 25 | FROM python:3.12-slim-bookworm
|
26 | 26 |
|
27 | 27 | WORKDIR /app
|
28 |
| - |
| 28 | + |
29 | 29 | COPY --from=uv /root/.local /root/.local
|
30 |
| -COPY --from=uv /app/.venv /app/.venv |
| 30 | +COPY --from=uv --chown=app:app /app/.venv /app/.venv |
31 | 31 |
|
32 |
| -# Set environment variable for Python path |
| 32 | +# Place executables in the environment at the front of the path |
33 | 33 | ENV PATH="/app/.venv/bin:$PATH"
|
34 | 34 |
|
35 |
| -# Default command to run the server |
| 35 | +# when running the container, add --db-path and a bind mount to the host's db file |
36 | 36 | ENTRYPOINT ["mcp-server-rabbitmq"]
|
0 commit comments