Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Python
**/__pycache__
.venv
**/.venv

# Django
**/.env
Expand Down
25 changes: 13 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR
# Alpine doesn't support playwright
FROM python:3.13.7-slim AS development

# Set up user like python_base does
ENV UID=1000
ENV USER=app
RUN addgroup --gid 1000 --system ${USER} \
&& adduser --uid 1000 --system ${USER} --ingroup ${USER} --home /home/${USER} \
&& mkdir -p /home/${USER} \
&& chown ${USER}:${USER} /home/${USER}

ENV HOME=/home/${USER}
ENV APP_DIR=/app
RUN addgroup --gid $UID --system ${USER} \
&& adduser --uid $UID --system ${USER} --ingroup ${USER} \
&& mkdir -p ${APP_DIR} \
&& chown ${USER}:${USER} ${APP_DIR}

ENV VIRTUAL_ENV=/app/.venv
ENV PATH="/app/.venv/bin:$PATH"
ENV VIRTUAL_ENV=${APP_DIR}/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

USER root
WORKDIR /app
WORKDIR ${APP_DIR}

# Install system dependencies needed for Playwright
RUN apt-get update && apt-get install -y \
Expand Down Expand Up @@ -79,11 +78,13 @@ RUN apt-get update && apt-get install -y \

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache \
PLAYWRIGHT_BROWSERS_PATH=${APP_DIR}/browsers

COPY pyproject.toml poetry.lock ./
RUN pip install poetry
RUN poetry install --no-root
RUN poetry install --no-root && rm -rf $POETRY_CACHE_DIR
RUN poetry run playwright install --with-deps chromium

USER ${USER}
Expand Down
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ services:
depends_on:
- db
volumes:
- ./lung_cancer_screening:/app/lung_cancer_screening
- ./:/app
- venv:/app/.venv
- playwright_browsers:/app/browsers
restart: unless-stopped

asset_builder:
Expand Down Expand Up @@ -44,3 +46,5 @@ services:
volumes:
postgres_data:
redis_data:
venv:
playwright_browsers:
3 changes: 2 additions & 1 deletion makefiles/dev.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.PHONY: dev-run dev-up dev-down dev-logs dev-shell dev-migrate dev-makemigrations dev-clean dev-test

DOCKER_COMPOSE_CMD = docker compose
UID=$(shell id -u)
DOCKER_COMPOSE_CMD = env UID=$(UID) docker compose

dev-build:
$(DOCKER_COMPOSE_CMD) build
Expand Down
Loading