2
2
# update the contributor guide, which can be found at
3
3
# pydis_site/apps/content/resources/guides/pydis-guides/contributing/site.md
4
4
# Thank you!
5
- FROM ghcr.io/owl-corp/python-poetry-base:3.11 -slim
5
+ ARG python_version=3.13 -slim
6
6
7
- # Allow service to handle stops gracefully
8
- STOPSIGNAL SIGQUIT
7
+ FROM python:$python_version AS builder
8
+ COPY --from=ghcr.io/astral-sh/uv:0.7 /uv /bin/
9
9
10
- # Copy the project files into working directory
11
- WORKDIR /app
10
+ ENV UV_COMPILE_BYTECODE=1 \
11
+ UV_LINK_MODE=copy
12
+
13
+ # Install project dependencies with build tools available
14
+ WORKDIR /build
15
+
16
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
17
+ && python -m venv .venv
18
+
19
+ RUN --mount=type=cache,target=/root/.cache/uv \
20
+ --mount=type=bind,source=uv.lock,target=uv.lock \
21
+ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
22
+ uv sync --frozen --no-dev
12
23
13
- # Install project dependencies
14
- COPY pyproject.toml poetry.lock ./
15
- RUN poetry install --only main
24
+ FROM python:$python_version
25
+
26
+ # Allow service to handle stops gracefully
27
+ STOPSIGNAL SIGQUIT
16
28
17
29
# Set Git SHA environment variable
18
30
ARG git_sha="development"
19
31
ENV GIT_SHA=$git_sha
20
32
33
+ # Install dependencies from build cache
34
+ # .venv not put in /app so that it doesn't conflict with the dev
35
+ # volume we use to avoid rebuilding image every code change locally
36
+ COPY --from=builder /build /build
37
+ COPY --from=builder /bin/uv /bin/uv
38
+ ENV PATH="/build/.venv/bin:$PATH"
39
+
21
40
# Copy the source code in last to optimize rebuilding the image
41
+ WORKDIR /app
22
42
COPY . .
23
43
24
44
# Set dummy variables so collectstatic can load settings.py
@@ -31,15 +51,15 @@ RUN \
31
51
SECRET_KEY=dummy_value \
32
52
DATABASE_URL=postgres://localhost \
33
53
METRICITY_DB_URL=postgres://localhost \
34
- poetry run python manage.py collectstatic --noinput --clear
54
+ uv run python manage.py collectstatic --noinput --clear
35
55
36
56
# Build static files if we are doing a static build
37
57
ARG STATIC_BUILD=false
38
58
RUN if [ $STATIC_BUILD = "TRUE" ] ; \
39
- then SECRET_KEY=dummy_value poetry run python manage.py distill-local build --traceback --force ; \
59
+ then SECRET_KEY=dummy_value uv run python manage.py distill-local build --traceback --force ; \
40
60
fi
41
61
42
- ENTRYPOINT ["poetry " , "run" ]
62
+ ENTRYPOINT ["uv " , "run" ]
43
63
CMD ["gunicorn" , "--preload" , "-b" , "0.0.0.0:8000" , \
44
64
"pydis_site.wsgi:application" , "-w" , "2" , "--statsd-host" , \
45
65
"graphite.default.svc.cluster.local:8125" , "--statsd-prefix" , "site" , \
0 commit comments