Skip to content

Commit 6254abd

Browse files
committed
WIP
1 parent 014d02a commit 6254abd

File tree

4 files changed

+64
-10
lines changed

4 files changed

+64
-10
lines changed

Dockerfile.chainguard

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
USER root
21+
RUN addgroup --gid 1000 --system ${USER} \
22+
&& adduser --uid 1000 --system ${USER} --ingroup ${USER}
23+
24+
25+
FROM python_base AS builder
26+
27+
USER root
28+
WORKDIR /app
29+
30+
ENV POETRY_NO_INTERACTION=1 \
31+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
32+
POETRY_VIRTUALENVS_CREATE=1 \
33+
POETRY_CACHE_DIR=/tmp/poetry_cache
34+
35+
COPY pyproject.toml poetry.lock ./
36+
RUN pip install poetry
37+
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR
38+
39+
40+
FROM python_base
41+
42+
USER ${USER}
43+
WORKDIR /app
44+
45+
COPY --from=builder --chown=${USER}:${USER} ${VIRTUAL_ENV} ${VIRTUAL_ENV}
46+
COPY --chown=${USER}:${USER} ./lung_cancer_screening /app/lung_cancer_screening
47+
COPY --from=asset_builder --chown=${USER}:${USER} /app/lung_cancer_screening/assets/compiled /app/lung_cancer_screening/assets/compiled
48+
COPY --chown=${USER}:${USER} manage.py ./
49+
50+
RUN python ./manage.py collectstatic --noinput
51+
52+
EXPOSE 8000
53+
54+
ENTRYPOINT ["/app/.venv/bin/gunicorn", "--bind", "0.0.0.0:8000", "lung_cancer_screening.wsgi"]

Dockerfile.dev

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Alpine doesn't support playwright
2-
FROM python:3.14.1-slim AS development
2+
FROM python:3.14.1-slim
33

44
ARG UID=1000
55
ENV USER=app
@@ -55,3 +55,5 @@ RUN poetry run playwright install --with-deps chromium
5555

5656
USER ${USER}
5757
COPY --chown=${USER}:${USER} . .
58+
59+
CMD ["/usr/bin/python", "manage.py", "runserver", "0.0.0.0:8000"]

docker-compose.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@ services:
44
web:
55
build:
66
context: .
7-
dockerfile: Dockerfile.dev
8-
target: development
9-
command: python manage.py runserver 0.0.0.0:8000
7+
dockerfile: Dockerfile.chainguard
108
ports:
119
- "8000:8000"
1210
env_file:
1311
- .env
1412
depends_on:
1513
- db
1614
- asset_builder
17-
volumes:
18-
- ./:/app
19-
- venv:/app/.venv
20-
- playwright_browsers:/app/browsers
15+
# volumes:
16+
# - ./:/app
17+
# - venv:/app/.venv
18+
# - playwright_browsers:/app/browsers
2119
restart: unless-stopped
2220

2321
asset_builder:

makefiles/dev.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ dev-logs:
1919
$(DOCKER_COMPOSE_CMD) logs -f
2020

2121
dev-shell:
22-
$(DOCKER_COMPOSE_CMD) run --rm web bash
22+
$(DOCKER_COMPOSE_CMD) run --rm --entrypoint /bin/sh web
2323

2424
dev-migrate:
25-
$(DOCKER_COMPOSE_CMD) run --rm web python manage.py migrate
25+
$(DOCKER_COMPOSE_CMD) run --rm --entrypoint /usr/bin/python web manage.py migrate
2626

2727
dev-makemigrations:
2828
$(DOCKER_COMPOSE_CMD) run --rm web python manage.py makemigrations

0 commit comments

Comments
 (0)