Skip to content

Commit

Permalink
Rework local dev/test #1196
Browse files Browse the repository at this point in the history
  • Loading branch information
dennissiemensma committed Jun 11, 2024
1 parent 82079d2 commit 5297bc1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.pydevproject/
/.project/
/.idea/*
!/.idea/runConfigurations/*
*.pyc
**/__pycache__
**/.pytest_cache
Expand Down
10 changes: 3 additions & 7 deletions provisioning/container/Containerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ARG DOCS_PYTHON_VERSION="3.12"

FROM python:${APP_PYTHON_VERSION}-alpine AS local-dsmrreader-base
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN apk add --update \
build-base \
Expand All @@ -19,21 +20,16 @@ RUN apk add --update \
openjpeg \
mariadb-dev \
postgresql-client
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
RUN pip install poetry

COPY ./src/ /app/

FROM local-dsmrreader-base AS local-dsmrreader-dev
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
COPY ./src/ /app/
RUN poetry install --with dev --no-root
EXPOSE 8000
ENTRYPOINT ["poetry", "run"]


FROM local-dsmrreader-dev AS local-dsmrreader-test
EXPOSE ""


# -----------------------------------------------------------


Expand Down
22 changes: 6 additions & 16 deletions provisioning/container/compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ services:
target: local-dsmrreader-dev
volumes:
- ./src:/app
- /app/.venv # Prevents mirroring it either direction
- /app/.venv # Prevents mirroring it to host
ports:
- '8000:8000'
depends_on:
dev-dsmr-db:
condition: service_healthy
mosquitto:
condition: service_started
influxdb:
Expand All @@ -33,17 +31,12 @@ services:
restart: 'unless-stopped'
ports:
- '5432:5432'
healthcheck:
test: ["CMD-SHELL", "pg_isready -U dsmrreader"]
interval: 1s
timeout: 5s
retries: 20
env_file:
- provisioning/container/dev.env
volumes:
# Persist database storage between container recreation
- ./.container-data/dev-dsmr-db/:/var/lib/postgresql/
# Only use for restoring DB-backups. E.g.: psql -U dsmrreader -f /run/host/Desktop/dsmrreader-postgresql-backup-Tuesday.sql dsmrreader
# Only use for restoring DB-backups. E.g.: psql -U dbuser -f /run/host/Desktop/dsmrreader-postgresql-backup-Tuesday.sql dsmrreader
- ~/Desktop:/run/host/Desktop/

# http://localhost:10000
Expand Down Expand Up @@ -96,10 +89,7 @@ services:
container_name: tests-dsmr-db
image: postgres:15-alpine
restart: 'unless-stopped'
healthcheck:
test: ["CMD-SHELL", "pg_isready -U dsmrreader"]
interval: 1s
timeout: 5s
retries: 20
env_file:
- provisioning/container/test.env
environment:
POSTGRES_DB: 'test_dsmrreader'
POSTGRES_USER: 'testuser'
POSTGRES_PASSWORD: 'testpasswd'
20 changes: 14 additions & 6 deletions provisioning/container/compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@
services:
tests-dsmr-app:
container_name: tests-dsmr-app

restart: 'no'
build:
context: .
dockerfile: provisioning/container/Containerfile-dev
target: local-dsmrreader-test
target: local-dsmrreader-dev
volumes:
- ./src:/app
depends_on:
tests-dsmr-db:
condition: service_healthy
env_file:
- provisioning/container/test.env
environment:
DJANGO_SETTINGS_MODULE: 'dsmrreader.config.test'
DJANGO_SECRET_KEY: 'automated-tests'
DJANGO_DATABASE_ENGINE: 'django.db.backends.postgresql'
DJANGO_DATABASE_HOST: 'tests-dsmr-db'
DJANGO_DATABASE_PORT: 5432
DJANGO_DATABASE_NAME: 'test_dsmrreader'
DJANGO_DATABASE_USER: 'dbtestuser'
DJANGO_DATABASE_PASSWORD: 'dbtestpasswd'

tests-dsmr-db:
container_name: tests-dsmr-db
Expand All @@ -28,5 +34,7 @@ services:
interval: 1s
timeout: 5s
retries: 20
env_file:
- provisioning/container/test.env
environment:
POSTGRES_DB: 'test_dsmrreader'
POSTGRES_USER: 'dbtestuser'
POSTGRES_PASSWORD: 'dbtestpasswd'
6 changes: 3 additions & 3 deletions provisioning/container/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#######################################################################

### dev-dsmr-app ###
DSMRREADER_LOGLEVEL=DEBUG
DJANGO_SETTINGS_MODULE=dsmrreader.config.development
DJANGO_DATABASE_ENGINE=django.db.backends.postgresql
DJANGO_DATABASE_HOST=dev-dsmr-db
DJANGO_DATABASE_PORT=5432
DJANGO_DATABASE_NAME=dsmrreader
DJANGO_DATABASE_USER=dsmrreader
DJANGO_DATABASE_PASSWORD=postgres-password
DJANGO_DATABASE_USER=dbuser
DJANGO_DATABASE_PASSWORD=dbpassword
DJANGO_SECRET_KEY=localhost-development
DSMRREADER_LOGLEVEL=DEBUG


### dev-dsmr-db ###
Expand Down
20 changes: 0 additions & 20 deletions provisioning/container/test.env

This file was deleted.

0 comments on commit 5297bc1

Please sign in to comment.