Skip to content

Commit 1c85d1f

Browse files
committed
refactor: rework dockerfile to use system python
1 parent 4989d6f commit 1c85d1f

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Dockerfile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1+
# https://github.com/astral-sh/uv-docker-example/blob/c16a61fb3e6ab568ac58d94b73a7d79594a5d570/Dockerfile
12
FROM python:3.13-slim
23

3-
EXPOSE 8000
4-
54
WORKDIR /app
65

7-
RUN apt-get update && apt-get install -y gcc libpq-dev
6+
ENV PATH="/app/.venv/bin:$PATH"
7+
ENV UV_COMPILE_BYTECODE=1
8+
ENV UV_LINK_MODE=copy
9+
ENV UV_PROJECT_ENVIRONMENT=/usr/local
810

911
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
1012

11-
COPY . .
12-
13-
ENV PYTHONUNBUFFERED=1
13+
# Install the project's dependencies using the lockfile and settings
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 \
17+
uv sync --frozen --no-install-project --no-dev
1418

15-
RUN uv sync --no-dev --locked
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
22+
RUN --mount=type=cache,target=/root/.cache/uv \
23+
uv sync --frozen --no-dev
1624

17-
CMD ["uv", "run", "--locked", "--no-dev", "python", "-m", "stac_auth_proxy"]
25+
CMD ["python", "-m", "stac_auth_proxy"]

0 commit comments

Comments
 (0)