Skip to content

Commit 97a9d85

Browse files
committed
Dependencies/docker to uv
Corrected dockerfile to copy uv over from build step Probably fine, right? (I forgot how to dockerfile, please forgive me)
1 parent 140a39b commit 97a9d85

File tree

5 files changed

+820
-1375
lines changed

5 files changed

+820
-1375
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ repos:
1515
- id: ruff
1616
name: ruff
1717
description: This hook runs ruff within our project's environment.
18-
entry: poetry run ruff check --force-exclude
18+
entry: uv run ruff check --force-exclude
1919
language: system
2020
types: [python]

Dockerfile

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,43 @@
22
# update the contributor guide, which can be found at
33
# pydis_site/apps/content/resources/guides/pydis-guides/contributing/site.md
44
# Thank you!
5-
FROM ghcr.io/owl-corp/python-poetry-base:3.11-slim
5+
ARG python_version=3.13-slim
66

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/
99

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
1223

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
1628

1729
# Set Git SHA environment variable
1830
ARG git_sha="development"
1931
ENV GIT_SHA=$git_sha
2032

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+
2140
# Copy the source code in last to optimize rebuilding the image
41+
WORKDIR /app
2242
COPY . .
2343

2444
# Set dummy variables so collectstatic can load settings.py
@@ -31,15 +51,15 @@ RUN \
3151
SECRET_KEY=dummy_value \
3252
DATABASE_URL=postgres://localhost \
3353
METRICITY_DB_URL=postgres://localhost \
34-
poetry run python manage.py collectstatic --noinput --clear
54+
uv run python manage.py collectstatic --noinput --clear
3555

3656
# Build static files if we are doing a static build
3757
ARG STATIC_BUILD=false
3858
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 ; \
4060
fi
4161

42-
ENTRYPOINT ["poetry", "run"]
62+
ENTRYPOINT ["uv", "run"]
4363
CMD ["gunicorn", "--preload", "-b", "0.0.0.0:8000", \
4464
"pydis_site.wsgi:application", "-w", "2", "--statsd-host", \
4565
"graphite.default.svc.cluster.local:8125", "--statsd-prefix", "site", \

0 commit comments

Comments
 (0)