Skip to content

Commit 0496634

Browse files
committed
Update Dockerfile to use uv
1 parent ba7fc3b commit 0496634

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

Dockerfile

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
1-
FROM --platform=linux/amd64 ghcr.io/owl-corp/python-poetry-base:3.12-slim
1+
ARG python_version=3.12-slim
2+
3+
FROM python:$python_version AS builder
4+
COPY --from=ghcr.io/astral-sh/uv:0.7 /uv /bin/
5+
6+
ENV UV_COMPILE_BYTECODE=1 \
7+
UV_LINK_MODE=copy
8+
9+
# Install project dependencies with build tools available
10+
WORKDIR /build
11+
RUN pip install --no-cache-dir --upgrade pip setuptools wheel virtualenv \
12+
&& python -m virtualenv .venv
13+
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-dev
18+
19+
# -------------------------------------------------------------------------------
20+
21+
FROM python:$python_version
222

323
# Define Git SHA build argument for sentry
424
ARG git_sha="development"
525
ENV GIT_SHA=$git_sha
626

7-
# Install project dependencies
8-
WORKDIR /bot
9-
COPY pyproject.toml poetry.lock ./
10-
RUN poetry install --without dev
27+
# Install dependencies from build cache
28+
# .venv not put in /app so that it doesn't conflict with the dev
29+
# volume we use to avoid rebuilding image every code change locally
30+
COPY --from=builder /build /build
31+
ENV PATH="/build/.venv/bin:$PATH"
1132

1233
# Copy the source code in last to optimize rebuilding the image
34+
WORKDIR /bot
1335
COPY . .
1436

15-
ENTRYPOINT ["poetry"]
16-
CMD ["run", "python", "-m", "bot"]
37+
ENTRYPOINT ["python", "-m"]
38+
CMD ["bot"]

0 commit comments

Comments
 (0)