-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐳 [#4993] Add docker-compose file and fixtures for Referentielijsten
to be used for unittests with VCR and local development
- Loading branch information
Showing
4 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
version: '3.8' | ||
|
||
name: referentielijsten | ||
|
||
services: | ||
referentielijsten-redis: | ||
image: redis:7 | ||
command: ["redis-server", "--appendonly", "yes"] | ||
networks: | ||
- open-forms-dev | ||
|
||
referentielijsten-db: | ||
image: postgres:${PG_VERSION:-14} | ||
environment: | ||
- POSTGRES_HOST_AUTH_METHOD=trust | ||
volumes: | ||
- ./referentielijsten/docker-init-referentielijsten-db/:/docker-entrypoint-initdb.d | ||
- referentielijsten-db:/var/lib/postgresql/data | ||
networks: | ||
- open-forms-dev | ||
|
||
referentielijsten-web.local: | ||
image: maykinmedia/referentielijsten-api:${REFERENTIELIJSTEN_VERSION:-0.2.0} | ||
environment: &referentielijsten_web_env | ||
- DJANGO_SETTINGS_MODULE=referentielijsten.conf.docker | ||
- SECRET_KEY=${SECRET_KEY:-7&3f^bo1(-5($bre4iv-!nt%1xr!b54b&y7+97j5f&ndm_e=lz} | ||
- ALLOWED_HOSTS=referentielijsten-web.local,localhost | ||
- DB_NAME=referentielijsten | ||
- DB_USER=referentielijsten | ||
- DB_HOST=referentielijsten-db | ||
- DISABLE_2FA=true | ||
- IS_HTTPS=no | ||
- CACHE_DEFAULT=referentielijsten-redis:6379/0 | ||
- CACHE_AXES=referentielijsten-redis:6379/0 | ||
- SUBPATH=${SUBPATH:-/} | ||
- DJANGO_SUPERUSER_PASSWORD=admin | ||
ports: | ||
- 8004:8000 | ||
volumes: &referentielijsten_web_volumes | ||
# mount fixtures dir to automatically populate the DB | ||
- ./referentielijsten/fixtures/:/app/fixtures | ||
- media:/app/media # Shared media volume to get access to saved OAS files | ||
- private-media:/app/private-media | ||
depends_on: | ||
- referentielijsten-db | ||
- referentielijsten-redis | ||
networks: | ||
- open-forms-dev | ||
|
||
volumes: | ||
referentielijsten-db: | ||
media: | ||
private-media: | ||
|
||
networks: | ||
open-forms-dev: | ||
name: open-forms-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Referentielijsten API | ||
|
||
The `docker-compose.referentielijsten.yml` compose file is available to run an instance of Referentielijsten API. | ||
|
||
## docker compose | ||
|
||
Start an instance in your local environment from the parent directory: | ||
|
||
```bash | ||
docker compose -f docker-compose.referentielijsten.yml up -d | ||
``` | ||
|
||
This brings up the admin at http://localhost:8004/admin/. You can log in with the `admin` / `admin` | ||
credentials. | ||
|
||
## Load fixtures | ||
|
||
The fixtures in `referentielijsten/fixtures` are automatically loaded when the Referentielijsten container starts. | ||
|
||
## Dump fixtures | ||
|
||
Whenever you make changes in the admin for the tests, you need to dump the fixtures again so that | ||
bringing up the containers the next time (or in other developers' environments) will still have the | ||
same data. | ||
|
||
Dump the fixtures with (in the `docker` directory): | ||
|
||
```bash | ||
docker compose -f docker-compose.referentielijsten.yml run referentielijsten-web.local \ | ||
python src/manage.py dumpdata \ | ||
--indent=4 \ | ||
--output /app/fixtures/referentielijsten_fixtures.json \ | ||
accounts \ | ||
api | ||
``` | ||
|
||
Depending on your OS, you may need to grant extra write permissions: | ||
|
||
```bash | ||
chmod o+rwx ./referentielijsten/fixtures | ||
``` |
5 changes: 5 additions & 0 deletions
5
...erentielijsten/docker-init-referentielijsten-db/0001-docker-init-referentielijsten-db.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE USER referentielijsten; | ||
CREATE DATABASE referentielijsten; | ||
GRANT ALL PRIVILEGES ON DATABASE referentielijsten TO referentielijsten; | ||
-- On Postgres 15+, connect to the database and grant schema permissions. | ||
-- GRANT USAGE, CREATE ON SCHEMA public TO openzaak; |
57 changes: 57 additions & 0 deletions
57
docker/referentielijsten/fixtures/referentielijsten_fixtures.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[ | ||
{ | ||
"model": "accounts.user", | ||
"pk": 1, | ||
"fields": { | ||
"password": "pbkdf2_sha256$600000$DCgCQRA6R57PicaatiWGHU$S65r6Yedgkfv/exr8gFZogpyuCgortmrloq7+LBdnyY=", | ||
"last_login": "2025-01-07T14:17:06.242Z", | ||
"is_superuser": true, | ||
"username": "admin", | ||
"first_name": "", | ||
"last_name": "", | ||
"email": "", | ||
"is_staff": true, | ||
"is_active": true, | ||
"date_joined": "2025-01-07T14:10:46.508Z", | ||
"groups": [], | ||
"user_permissions": [] | ||
} | ||
}, | ||
{ | ||
"model": "api.tabel", | ||
"pk": 1, | ||
"fields": { | ||
"code": "tabel1", | ||
"naam": "Tabel1", | ||
"einddatum_geldigheid": null, | ||
"beheerder_naam": "John Doe", | ||
"beheerder_email": "[email protected]", | ||
"beheerder_afdeling": "", | ||
"beheerder_organisatie": "" | ||
} | ||
}, | ||
{ | ||
"model": "api.item", | ||
"pk": 1, | ||
"fields": { | ||
"tabel": 1, | ||
"code": "option1", | ||
"naam": "Option 1", | ||
"begindatum_geldigheid": "2025-01-07T14:17:53Z", | ||
"einddatum_geldigheid": null, | ||
"aanvullende_gegevens": null | ||
} | ||
}, | ||
{ | ||
"model": "api.item", | ||
"pk": 2, | ||
"fields": { | ||
"tabel": 1, | ||
"code": "option2", | ||
"naam": "Option 2", | ||
"begindatum_geldigheid": "2025-01-07T14:17:59Z", | ||
"einddatum_geldigheid": null, | ||
"aanvullende_gegevens": null | ||
} | ||
} | ||
] |