Skip to content

Commit

Permalink
Rework dev containers + Poetry update #1594
Browse files Browse the repository at this point in the history
  • Loading branch information
dennissiemensma committed Dec 3, 2024
1 parent 92b2f99 commit bc70e4d
Show file tree
Hide file tree
Showing 6 changed files with 1,173 additions and 1,063 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/.git/
/.github/
/src/.venv
Containerfile
compose.yml
27 changes: 20 additions & 7 deletions provisioning/container/Containerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ ARG PYTHON_VERSION="3.12"

FROM python:${PYTHON_VERSION}-alpine AS local-dsmrreader-base
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
RUN apk add --update \
build-base \
gcc \
Expand All @@ -17,19 +17,32 @@ RUN apk add --update \
openjpeg \
mariadb-dev \
postgresql-client
RUN pip install pip --upgrade



FROM local-dsmrreader-base AS local-dsmrreader-dev
# The only reason for .venv is the IDE's detection
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
RUN pip install poetry
COPY ./src/ /app/
RUN poetry install --with dev --no-root
ARG POETRY_VERSION="1.8.4"
# Credits to https://www.martinrichards.me/post/python_poetry_docker/
# Also, the only reason for .venv is the IDE's detection
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
RUN pip install poetry==${POETRY_VERSION}

COPY src/pyproject.toml src/poetry.lock /app/
RUN touch README.md
RUN poetry install --with dev --no-root && rm -rf $POETRY_CACHE_DIR

WORKDIR /app
ENTRYPOINT ["poetry", "run"]



FROM local-dsmrreader-base AS local-dsmrreader-docs
WORKDIR /app
COPY ./documentation/ /app/
# Do not use Poetry here, as RTD also directly utilizes PIP instead anyway.
RUN pip install -r /app/requirements.txt
ENTRYPOINT ["mkdocs"]
5 changes: 3 additions & 2 deletions provisioning/container/compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
dev-dsmr-app:
container_name: dev-dsmr-app
restart: 'unless-stopped'
command: '/app/manage.py runserver 0.0.0.0:8000'
command: 'poetry run /app/manage.py runserver 0.0.0.0:8000'
build:
context: .
dockerfile: provisioning/container/Containerfile-dev
Expand All @@ -16,7 +16,8 @@ services:
- ./src:/app
- /app/.venv # Prevents mirroring it to host
ports:
- '8000:8000'
# Use these env vars for your IDE's Python interpreter. Set Python path to /app/.venv/bin/python3 as well.
- '${HOST_DJANGO_PORT:-8000}:${CONTAINER_DJANGO_PORT:-8000}'
depends_on:
dev-dsmr-db:
condition: service_healthy
Expand Down
2 changes: 1 addition & 1 deletion provisioning/container/compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
dockerfile: provisioning/container/Containerfile-dev
target: local-dsmrreader-dev
volumes:
- ./src:/app
- ./src:/app/src
- /app/.venv # Prevents mirroring it to host
depends_on:
tests-dsmr-db:
Expand Down
Loading

0 comments on commit bc70e4d

Please sign in to comment.