Skip to content

Commit

Permalink
🐳 [#18] Add Open Zaak to compose stack
Browse files Browse the repository at this point in the history
* Switched DB image to a version with postgis for Open Zaak
* Added (default) Open Zaak 1.14 to compose (web, celery)
* Wired up the DB initialiation scripts to create the OZ
  db
* Set up dependencies with redis/DB
* Added host.docker.internal gateway to extra hosts
  • Loading branch information
sergei-maertens committed Sep 18, 2024
1 parent acbab87 commit 5d2c15a
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 3 deletions.
55 changes: 52 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,66 @@

services:
db:
image: postgres:${PG_VERSION:-16}
image: postgis/postgis:${PG_VERSION:-16-master}
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
- ./docker/init-db.sql:/docker-entrypoint-initdb.d/init_db.sql
- ./docker/open-zaak/db/0001-init-open-zaak-db.sql:/docker-entrypoint-initdb.d/0001-init-open-zaak-db.sql
- ./docker/open-zaak/db/0002-extensions.sh:/docker-entrypoint-initdb.d/0002-extensions.sh
- db:/var/lib/postgresql/data

redis:
image: redis:6
image: redis:7
command: ["redis-server", "--appendonly", "yes"]
volumes:
- redis-data:/data

openzaak-web:
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.14.0}
environment: &openzaak_web_env
- DJANGO_SETTINGS_MODULE=openzaak.conf.docker
- SECRET_KEY=${SECRET_KEY:-django-insecure-^#9nzgn*@-@0szv+$$)6th!i+$$ks^+bt@&ejcgzqt==7af(a(u3}
- ALLOWED_HOSTS=openzaak-web,host.docker.internal,localhost
- DB_NAME=openzaak
- DB_USER=openzaak
- DB_HOST=db
- IS_HTTPS=no
- CACHE_DEFAULT=redis:6379/1
- CACHE_AXES=redis:6379/1
- SUBPATH=${SUBPATH:-/}
- OPENZAAK_SUPERUSER_USERNAME=admin
- DJANGO_SUPERUSER_PASSWORD=admin
- OPENZAAK_SUPERUSER_EMAIL=admin@localhost
- DISABLE_2FA=true
- CELERY_BROKER_URL=redis://redis:6379/2
- CELERY_RESULT_BACKEND=redis://redis:6379/2
- NOTIFICATIONS_DISABLED=true
- JWT_EXPIRY=99999999999 # Roughly 3170 years. This is required for tests with time frozen to work
- CELERY_WORKER_CONCURRENCY=${CELERY_WORKER_CONCURRENCY:-2}
volumes: &openzaak_web_volumes
# mount fixtures dir to automatically populate the DB
- ./docker/open-zaak/fixtures/:/app/fixtures
- oz-media:/app/media # Shared media volume to get access to saved OAS files
- oz-private-media:/app/private-media
depends_on:
- db
- redis
- openzaak-celery
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- 8001:8000

openzaak-celery:
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.14.0}
environment: *openzaak_web_env
volumes: *openzaak_web_volumes
command: /celery_worker.sh
depends_on:
- db
- redis

web: &web_build
build:
context: .
Expand Down Expand Up @@ -62,6 +109,8 @@ services:

volumes:
db:
redis-data:
oz-media:
oz-private-media:
log:
media:
redis-data:
45 changes: 45 additions & 0 deletions docker/open-zaak/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Open Zaak docker configuration

This directory contains supporting configuration and infrastructure to run Open Zaak
via `docker compose`.

You need Docker Engine v20.10 or newer for the documented setup to work.

## Spinning up the services

In the root of the project, spin up Open Zaak via `compose`:

```bash
docker compose up --detach openzaak-web # or just `docker compose up` to bring everything up
```

Open Zaak binds to port 8001 on the host system.

## Accessing the admin environment

Open your browser and navigate to http://localhost:8001/admin/, where you can log in
with the credentials `admin` / `admin`.

## Dumping the fixture

The service automatically loads the fixtures provided in the `fixtures` directory. When
making changes in the web interface to the configuration, you must update these
fixtures:

```bash
# from the root of the repository
docker compose run openzaak-web \
python src/manage.py dumpdata \
--indent=4 \
--output /app/fixtures/configuration.json \
authorizations.applicatie \
vng_api_common.jwtsecret \
config \
catalogi
```

Depending on your OS and local user ID, you may need to grant additional write permissions:

```bash
chmod -R o+rwx ./docker/open-zaak/fixtures
```
2 changes: 2 additions & 0 deletions docker/open-zaak/db/0001-init-open-zaak-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE USER openzaak;
CREATE DATABASE openzaak WITH OWNER openzaak;
7 changes: 7 additions & 0 deletions docker/open-zaak/db/0002-extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "openzaak" <<-EOSQL
CREATE EXTENSION postgis;
CREATE EXTENSION pg_trgm;
EOSQL
1 change: 1 addition & 0 deletions docker/open-zaak/fixtures/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]

0 comments on commit 5d2c15a

Please sign in to comment.