Skip to content

Commit ad97e9d

Browse files
committed
Use playwright for acceptance testing
Playwright does not run on alpine linux therefore python slim must be used for the development image
1 parent 93bcf11 commit ad97e9d

File tree

6 files changed

+175
-9
lines changed

6 files changed

+175
-9
lines changed

Dockerfile

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,62 @@ COPY pyproject.toml poetry.lock ./
3232
RUN pip install poetry
3333
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR
3434

35-
FROM builder AS development
35+
# Alpine doesn't support playwright
36+
FROM python:3.13.5-slim AS development
3637

37-
USER ${USER}
38-
WORKDIR /app
38+
# Set up user like python_base does
39+
ENV USER=app
40+
RUN addgroup --gid 1000 --system ${USER} \
41+
&& adduser --uid 1000 --system ${USER} --ingroup ${USER} --home /home/${USER} \
42+
&& mkdir -p /home/${USER} \
43+
&& chown ${USER}:${USER} /home/${USER}
3944

40-
COPY --chown=${USER}:${USER} . .
45+
ENV HOME=/home/${USER}
46+
47+
ENV VIRTUAL_ENV=/app/.venv
48+
ENV PATH="/app/.venv/bin:$PATH"
4149

4250
USER root
51+
WORKDIR /app
4352

44-
RUN chown ${USER}:${USER} .
45-
RUN poetry install
53+
# Install system dependencies needed for Playwright
54+
RUN apt-get update && apt-get install -y \
55+
fonts-liberation \
56+
libasound2 \
57+
libatk-bridge2.0-0 \
58+
libatk1.0-0 \
59+
libatspi2.0-0 \
60+
libcups2 \
61+
libdbus-1-3 \
62+
libdrm2 \
63+
libexpat1 \
64+
libgbm1 \
65+
libglib2.0-0 \
66+
libgtk-3-0 \
67+
libnspr4 \
68+
libnss3 \
69+
libx11-6 \
70+
libxcomposite1 \
71+
libxdamage1 \
72+
libxext6 \
73+
libxfixes3 \
74+
libxrandr2 \
75+
libxss1 \
76+
libxtst6 \
77+
xdg-utils \
78+
&& rm -rf /var/lib/apt/lists/*
79+
80+
ENV POETRY_NO_INTERACTION=1 \
81+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
82+
POETRY_VIRTUALENVS_CREATE=1
83+
84+
COPY pyproject.toml poetry.lock ./
85+
RUN pip install poetry
86+
RUN poetry install --no-root
87+
RUN poetry run playwright install
4688

4789
USER ${USER}
90+
COPY --chown=${USER}:${USER} . .
4891

4992
FROM python_base
5093

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ services:
1313
- .env
1414
depends_on:
1515
- db
16+
volumes:
17+
- ./lung_cancer_screening:/app/lung_cancer_screening
1618
restart: unless-stopped
1719

1820
asset_builder:

makefiles/dev.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dev-logs:
1818
$(DOCKER_COMPOSE_CMD) logs -f
1919

2020
dev-shell:
21-
$(DOCKER_COMPOSE_CMD) run web sh
21+
$(DOCKER_COMPOSE_CMD) run web bash
2222

2323
dev-migrate:
2424
$(DOCKER_COMPOSE_CMD) run --rm web python manage.py migrate

poetry.lock

Lines changed: 121 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package-mode = false
1818

1919
[tool.poetry.group.dev.dependencies]
2020
ruff = "^0.12.5"
21+
playwright = "^1.55.0"
2122

2223
[build-system]
2324
requires = ["poetry-core>=2.0.0,<3.0.0"]

scripts/tests/unit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ cd "$(git rev-parse --show-toplevel)"
1717
# tests from here. If you want to run other test suites, see the predefined
1818
# tasks in scripts/test.mk.
1919

20-
docker compose run web poetry run python manage.py test
20+
docker compose run --rm web poetry run python manage.py test

0 commit comments

Comments
 (0)