Skip to content

Commit c07a28f

Browse files
committed
Migrate docker setup to uv
1 parent c1ee6b3 commit c07a28f

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

backend/.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ LICENSE
1515
**/__pycache__/
1616
tests/
1717
postgres/
18+
19+
# uv
20+
.venv

backend/Dockerfile

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11
FROM pennlabs/django-base:b269ea1613686b1ac6370154debbb741b012de1a-3.11
2+
ARG DEPENDENCY_MANAGER="uv"
23

34
LABEL maintainer="Penn Labs"
45

6+
# Install build dependencies
7+
RUN apt-get update && apt-get install --no-install-recommends -y gcc libpq-dev libc-dev curl \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Install uv
11+
# Download the latest installer
12+
ADD https://astral.sh/uv/0.6.0/install.sh /uv-installer.sh
13+
14+
RUN echo "5464b06094b6363861b99cd60a010892e52fc2a7503b7594419828e74afecfe6 /uv-installer.sh" | sha256sum -c
15+
16+
# Run the installer then remove it
17+
RUN sh /uv-installer.sh && rm /uv-installer.sh
18+
19+
# Ensure the installed binary is on the `PATH`
20+
ENV PATH="/root/.local/bin/:$PATH"
21+
522
# Copy project dependencies
623
COPY Pipfile* /app/
24+
COPY pyproject.toml /app/
25+
COPY uv.lock /app/
26+
27+
# Install project dependencies using pipenv if pipenv enabled
28+
RUN if [ "$DEPENDENCY_MANAGER" = "pipenv" ]; then pipenv install --system; fi
729

8-
# Install project dependencies
9-
RUN pipenv install --system
30+
# Install project dependencies if using uv if uv enabled
31+
RUN if [ "$DEPENDENCY_MANAGER" = "uv" ]; then uv sync --frozen --no-dev --no-install-project --python $(which python); fi
32+
# Make installed binaries available for POSIX compliant scripts
33+
ENV PATH="/app/.venv/bin:$PATH"
34+
# Patch for scripts that use a hard-coded path to uwsgi (django-run)
35+
RUN if [ "$DEPENDENCY_MANAGER" = "uv" ]; then cp /app/.venv/bin/uwsgi /usr/local/bin/uwsgi; fi
36+
# Patch for scripts that use a hard-coded path to gunicorn (asgi-run)
37+
RUN if [ "$DEPENDENCY_MANAGER" = "uv" ]; then cp /app/.venv/bin/gunicorn /usr/local/bin/gunicorn; fi
38+
# Patch for scripts that use a hard-coded path to python (django-run, asgi-run)
39+
ENV PYTHONPATH="/app/.venv/lib/python3.11/site-packages/:$PYTHONPATH"
1040

1141
# Copy project files
1242
COPY . /app/

0 commit comments

Comments
 (0)