Skip to content

Commit 8aa6271

Browse files
committed
Initial changes to introduce Chainguard images
1 parent 9e0bb14 commit 8aa6271

File tree

2 files changed

+111
-2
lines changed

2 files changed

+111
-2
lines changed

Dockerfile.chainguard

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
FROM cgr.dev/nhs.net/node:25.2-dev AS asset_builder
2+
3+
USER root
4+
WORKDIR /app
5+
6+
COPY package.json package-lock.json rollup.config.js ./
7+
COPY . .
8+
RUN npm ci
9+
RUN npm run compile
10+
11+
12+
FROM cgr.dev/nhs.net/python:3.14-dev AS python_base
13+
14+
ENV PYTHONDONTWRITEBYTECODE=1 \
15+
PYTHONUNBUFFERED=1 \
16+
VIRTUAL_ENV=/app/.venv \
17+
PATH="/app/.venv/bin:$PATH" \
18+
USER=app
19+
20+
RUN addgroup --gid 1000 --system ${USER} \
21+
&& adduser --uid 1000 --system ${USER} --ingroup ${USER}
22+
23+
FROM python_base AS builder
24+
25+
WORKDIR /app
26+
27+
ENV POETRY_NO_INTERACTION=1 \
28+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
29+
POETRY_VIRTUALENVS_CREATE=1 \
30+
POETRY_CACHE_DIR=/tmp/poetry_cache
31+
32+
COPY pyproject.toml poetry.lock ./
33+
RUN pip install poetry
34+
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR
35+
36+
# Chainguard/Wolfi base doesn't support Playwright's apt-based dependency installer,
37+
# so use a Debian slim image for the development stage where Playwright runs.
38+
FROM python:3.14.1-slim AS development
39+
40+
ARG UID=1000
41+
ENV USER=app
42+
ENV APP_DIR=/app
43+
RUN addgroup --gid $UID --system ${USER} \
44+
&& adduser --uid $UID --system ${USER} --ingroup ${USER} \
45+
&& mkdir -p ${APP_DIR} \
46+
&& chown ${USER}:${USER} ${APP_DIR}
47+
48+
ENV VIRTUAL_ENV=${APP_DIR}/.venv
49+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
50+
51+
USER root
52+
WORKDIR ${APP_DIR}
53+
54+
# Install system dependencies needed for Playwright
55+
RUN apt-get update && apt-get install -y \
56+
fonts-liberation \
57+
libasound2 \
58+
libatk-bridge2.0-0 \
59+
libatk1.0-0 \
60+
libatspi2.0-0 \
61+
libcups2 \
62+
libdbus-1-3 \
63+
libdrm2 \
64+
libexpat1 \
65+
libgbm1 \
66+
libglib2.0-0 \
67+
libgtk-3-0 \
68+
libnspr4 \
69+
libnss3 \
70+
libx11-6 \
71+
libxcomposite1 \
72+
libxdamage1 \
73+
libxext6 \
74+
libxfixes3 \
75+
libxrandr2 \
76+
libxss1 \
77+
libxtst6 \
78+
xdg-utils \
79+
&& rm -rf /var/lib/apt/lists/*
80+
81+
ENV POETRY_NO_INTERACTION=1 \
82+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
83+
POETRY_VIRTUALENVS_CREATE=1 \
84+
POETRY_CACHE_DIR=/tmp/poetry_cache \
85+
PLAYWRIGHT_BROWSERS_PATH=${APP_DIR}/browsers
86+
87+
COPY pyproject.toml poetry.lock ./
88+
RUN pip install poetry
89+
RUN poetry install --no-root && rm -rf $POETRY_CACHE_DIR
90+
RUN poetry run playwright install --with-deps chromium
91+
92+
USER ${USER}
93+
COPY --chown=${USER}:${USER} . .
94+
95+
FROM python_base
96+
97+
USER ${USER}
98+
WORKDIR /app
99+
100+
COPY --from=builder --chown=${USER}:${USER} ${VIRTUAL_ENV} ${VIRTUAL_ENV}
101+
COPY --chown=${USER}:${USER} ./lung_cancer_screening /app/lung_cancer_screening
102+
COPY --from=asset_builder --chown=${USER}:${USER} /app/lung_cancer_screening/assets/compiled /app/lung_cancer_screening/assets/compiled
103+
COPY --chown=${USER}:${USER} manage.py ./
104+
105+
RUN python ./manage.py collectstatic --noinput
106+
107+
EXPOSE 8000
108+
109+
CMD ["/app/.venv/bin/gunicorn", "--bind", "0.0.0.0:8000", "lung_cancer_screening.wsgi"]

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
web:
55
build:
66
context: .
7-
dockerfile: Dockerfile
7+
dockerfile: Dockerfile.chainguard
88
target: development
99
command: python manage.py runserver 0.0.0.0:8000
1010
ports:
@@ -23,7 +23,7 @@ services:
2323
asset_builder:
2424
build:
2525
context: .
26-
dockerfile: Dockerfile
26+
dockerfile: Dockerfile.chainguard
2727
target: asset_builder
2828
command: npm run watch
2929
volumes:

0 commit comments

Comments
 (0)