1- # define an alias for the specific python version used in this file.
2- FROM docker.io/python:3.11-slim-bookworm AS python
3-
4- # Python build stage
5- FROM python AS python-build-stage
6-
7- # Install apt packages
8- RUN apt-get update && apt-get install --no-install-recommends -y \
9- # dependencies for building Python packages
10- build-essential \
11- # psycopg dependencies
12- libpq-dev
13-
14- # Requirements are installed here to ensure they will be cached.
15- COPY ./requirements .
16-
17- # Create Python Dependency and Sub-Dependency Wheels.
18- RUN pip wheel --wheel-dir /usr/src/app/wheels \
19- -r development.txt
20-
21- # Python 'run' stage
22- FROM python AS python-run-stage
1+ FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim
232
243ENV PYTHONUNBUFFERED=1
254ENV PYTHONDONTWRITEBYTECODE=1
@@ -29,46 +8,38 @@ WORKDIR /app
298ARG NODE_MAJOR=20
309
3110RUN apt-get update \
32- && apt-get install -y ca-certificates curl gnupg \
33- && mkdir -p /etc/apt/keyrings \
34- && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
35- && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
36- && apt-get update \
37- && apt-get install nodejs -y \
38- && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
39- && apt-get clean
40-
41- # devcontainer dependencies and utils
42- RUN apt-get update && apt-get install --no-install-recommends -y \
43- sudo git bash-completion nano ssh
44-
45- # Create devcontainer user and add it to sudoers
11+ && apt-get install -y --no-install-recommends \
12+ # Node.js dependencies
13+ ca-certificates curl gnupg \
14+ # devcontainer dependencies
15+ sudo git bash-completion nano ssh \
16+ # psycopg dependencies
17+ libpq-dev \
18+ wait-for-it \
19+ # Translations dependencies
20+ gettext \
21+ && mkdir -p /etc/apt/keyrings \
22+ && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
23+ && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
24+ && apt-get update \
25+ && apt-get install -y --no-install-recommends nodejs \
26+ # Cleanup
27+ && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
28+ && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
29+ && apt-get clean
30+
31+ # Create devcontainer user
4632RUN groupadd --gid 1000 dev-user \
47- && useradd --uid 1000 --gid dev-user --shell /bin/bash --create-home dev-user \
48- && echo dev-user ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/dev-user \
49- && chmod 0440 /etc/sudoers.d/dev-user
50-
51- # Install required system dependencies
52- RUN apt-get update && apt-get install --no-install-recommends -y \
53- # psycopg dependencies
54- libpq-dev \
55- wait-for-it \
56- # Translations dependencies
57- gettext \
58- # cleaning up unused files
59- && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
60- && rm -rf /var/lib/apt/lists/*
33+ && useradd --uid 1000 --gid dev-user --shell /bin/bash --create-home dev-user \
34+ && echo dev-user ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/dev-user \
35+ && chmod 0440 /etc/sudoers.d/dev-user
6136
62- # All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction
63- # copy python dependency wheels from python-build-stage
64- COPY --from=python-build-stage /usr/src/app/wheels /wheels/
37+ COPY . .
6538
66- # use wheels to install python dependencies
67- RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
68- && rm -rf /wheels/
39+ # Install dependencies
40+ RUN uv sync --locked --only-group dev
6941
7042COPY ./compose/local/django/start /start
71- RUN sed -i 's/\r $//g' /start
7243RUN chmod +x /start
7344
7445CMD ["/start" ]
0 commit comments