|
1 | | -FROM python:3.11-bookworm |
| 1 | +FROM ghcr.io/astral-sh/uv:python3.14-bookworm |
2 | 2 |
|
3 | 3 | ARG postgres_version=14 |
4 | 4 |
|
5 | | -RUN curl -sSL https://install.python-poetry.org | python3 - |
6 | | -ENV PATH "$PATH:/root/.local/bin" |
7 | | - |
| 5 | +# Install Postgres CLI tools |
8 | 6 | RUN apt-get update && apt-get -y full-upgrade && apt-get install -y lsb-release |
9 | 7 | RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' |
10 | 8 | RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - |
11 | 9 | RUN apt-get update |
12 | 10 | RUN apt-get install -y postgresql-client-${postgres_version} |
13 | 11 |
|
14 | | -COPY pyproject.toml poetry.lock ./ |
| 12 | +WORKDIR /app |
| 13 | + |
| 14 | +# Enable bytecode compilation |
| 15 | +ENV UV_COMPILE_BYTECODE=1 |
| 16 | + |
| 17 | +# Copy from the cache instead of linking since it's a mounted volume |
| 18 | +ENV UV_LINK_MODE=copy |
| 19 | + |
| 20 | +# Install the project's dependencies using the lockfile and settings |
| 21 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 22 | + --mount=type=bind,source=uv.lock,target=uv.lock \ |
| 23 | + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ |
| 24 | + uv sync --frozen --no-install-project --no-dev |
| 25 | + |
| 26 | +# Then, add the rest of the project source code and install it |
| 27 | +# Installing separately from its dependencies allows optimal layer caching |
| 28 | +ADD . /app |
| 29 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 30 | + uv sync --frozen --no-dev |
| 31 | + |
| 32 | +# Place executables in the environment at the front of the path |
| 33 | +ENV PATH="/app/.venv/bin:$PATH" |
15 | 34 |
|
16 | | -RUN poetry config virtualenvs.create false |
17 | | -RUN poetry install -n --only main --no-root |
| 35 | +# Reset the entrypoint, don't invoke `uv` |
| 36 | +ENTRYPOINT [] |
18 | 37 |
|
19 | | -COPY . ./ |
20 | | -CMD ["python3.11", "-O", "-m", "src"] |
| 38 | +CMD ["python3.14", "-O", "-m", "src"] |
0 commit comments