1- FROM node:18.17 .0-bullseye-slim AS static_files
1+ FROM node:22.18 .0-bullseye-slim AS static_files
22
33WORKDIR /code
44ENV PATH=/code/node_modules/.bin:$PATH
@@ -7,7 +7,17 @@ RUN npm install --silent
77COPY frontend/ /code/
88RUN npm run build
99
10- FROM python:3.12-slim-bullseye AS base
10+ FROM ghcr.io/astral-sh/uv:python3.13-bookworm AS base
11+
12+ # Enable bytecode compilation
13+ ENV UV_COMPILE_BYTECODE=1
14+
15+ # Copy from the cache instead of linking since it's a mounted volume
16+ ENV UV_LINK_MODE=copy
17+
18+ # Use a custom VIRTUAL_ENV with uv to avoid conflicts with local developer's
19+ # .venv/ while running tests in Docker
20+ ENV VIRTUAL_ENV=/venv
1121
1222# Create a group and user to run our app
1323ARG APP_USER=appuser
@@ -32,27 +42,28 @@ RUN set -ex \
3242 && apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \
3343 && rm -rf /var/lib/apt/lists/*
3444
35- # Copy in your requirements file
36- # ADD requirements.txt /requirements.txt
37-
38- # OR, if you're using a directory for your requirements, copy everything (comment out the above and uncomment this if so):
39- ADD requirements /requirements
40-
4145# Install build deps, then run `pip install`, then remove unneeded build deps all in a single step.
4246# Correct the path to your production requirements file, if needed.
43- RUN set -ex \
47+ ARG UV_OPTS="--no-dev --group deploy"
48+ RUN --mount=type=cache,target=/root/.cache/uv \
49+ --mount=type=bind,source=uv.lock,target=uv.lock \
50+ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
51+ set -ex \
4452 && BUILD_DEPS=" \
4553 build-essential \
4654 libpcre3-dev \
4755 libpq-dev \
4856 git-core \
4957 " \
5058 && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
51- && pip install -U -q pip-tools \
52- && pip- sync requirements/base/base.txt requirements/deploy/deploy.txt \
59+ && uv venv $VIRTUAL_ENV \
60+ && uv sync --active --locked --no-install-project $UV_OPTS \
5361 && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
5462 && rm -rf /var/lib/apt/lists/*
5563
64+ # Add uv venv to PATH
65+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
66+
5667FROM base AS deploy
5768
5869# Copy your application code to the container (make sure you create a .dockerignore file if any large files or directories should be excluded)
@@ -98,7 +109,7 @@ ENTRYPOINT ["/code/docker-entrypoint.sh"]
98109# Start uWSGI
99110CMD ["newrelic-admin" , "run-program" , "uwsgi" , "--single-interpreter" , "--enable-threads" , "--show-config" ]
100111
101- FROM python:3.12-slim-bullseye AS dev
112+ FROM ghcr.io/astral-sh/uv:python3.13-bookworm AS dev
102113
103114ARG USERNAME=appuser
104115ARG USER_UID=1000
@@ -153,8 +164,10 @@ RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/
153164 # docker
154165 && curl https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor | tee /etc/apt/trusted.gpg.d/docker.gpg >/dev/null \
155166 && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \
156- # nodejs
157- && sh -c 'echo "deb https://deb.nodesource.com/node_18.x $(lsb_release -cs) main" > /etc/apt/sources.list.d/nodesource.list' \
167+ # nodejs (https://github.com/nodesource/distributions/wiki/Repository-Manual-Installation#debian-systems)
168+ && mkdir -p /etc/apt/keyrings \
169+ && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
170+ && sh -c 'echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" > /etc/apt/sources.list.d/nodesource.list' \
158171 && wget --quiet -O- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
159172 # PostgreSQL
160173 && sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
0 commit comments