|
1 | 1 | FROM pennlabs/django-base:b269ea1613686b1ac6370154debbb741b012de1a-3.11
|
| 2 | +ARG DEPENDENCY_MANAGER="uv" |
2 | 3 |
|
3 | 4 | LABEL maintainer="Penn Labs"
|
4 | 5 |
|
| 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 | + |
5 | 22 | # Copy project dependencies
|
6 | 23 | 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 |
7 | 29 |
|
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" |
10 | 40 |
|
11 | 41 | # Copy project files
|
12 | 42 | COPY . /app/
|
|
0 commit comments