Skip to content

Commit 9577fc7

Browse files
Merge pull request #4489 from open-formulieren/chore/automatically-load-fixtures
Fix docker compose setup for local development
2 parents 67e9534 + d13ae74 commit 9577fc7

7 files changed

+530
-441
lines changed

docker/docker-compose.objects-apis.yml

+29-4
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,53 @@ services:
2020
- open-forms-dev
2121

2222
objecttypes-web:
23-
image: maykinmedia/objecttypes-api:${OBJECTTYPES_VERSION:-2.1.1}
23+
image: maykinmedia/objecttypes-api:${OBJECTTYPES_VERSION:-2.2.0}
2424
environment:
2525
- DJANGO_SETTINGS_MODULE=objecttypes.conf.docker
2626
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
2727
- ALLOWED_HOSTS=*
28+
- USE_X_FORWARDED_HOST=true
2829
- DB_HOST=objects-objecttypes-db
30+
- DB_NAME=objecttypes
31+
- DB_USER=objecttypes
32+
- CACHE_DEFAULT=objects-redis:6379/1
33+
- CACHE_AXES=objects-redis:6379/1
34+
- OBJECTTYPE_SUPERUSER_USERNAME=admin
35+
- OBJECTTYPE_SUPERUSER_PASSWORD=admin
36+
- OBJECTTYPE_SUPERUSER_EMAIL=admin@localhost
37+
- DISABLE_2FA=true
38+
volumes:
39+
# mount fixtures dir to automatically populate the DB
40+
- ./objects-apis/fixtures/objecttypes_api_fixtures.json:/app/fixtures/objecttypes_api_fixtures.json
2941
depends_on:
3042
- objects-objecttypes-db
43+
- objects-redis
3144
networks:
3245
- open-forms-dev
3346

3447
objects-web:
35-
image: maykinmedia/objects-api:${OBJECTS_VERSION:-2.3.0}
48+
image: maykinmedia/objects-api:${OBJECTS_VERSION:-2.3.2}
3649
environment: &objects_web_env
3750
- DJANGO_SETINGS_MODULE=objects.conf.docker
3851
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
3952
- ALLOWED_HOSTS=*
53+
- USE_X_FORWARDED_HOST=true
4054
- DB_HOST=objects-objecttypes-db
55+
- DB_NAME=objects
56+
- DB_USER=objects
57+
- CACHE_DEFAULT=objects-redis:6379/0
58+
- CACHE_AXES=objects-redis:6379/0
4159
- DISABLE_2FA=True
4260
- CELERY_BROKER_URL=redis://objects-redis:6379/0
4361
- CELERY_RESULT_BACKEND=redis://objects-redis:6379/0
4462
- NOTIFICATIONS_DISABLED=True
63+
- OBJECTS_SUPERUSER_USERNAME=admin
64+
- OBJECTS_SUPERUSER_PASSWORD=admin
65+
- OBJECTS_SUPERUSER_EMAIL=admin@localhost
66+
- DISABLE_2FA=true
67+
volumes:
68+
# mount fixtures dir to automatically populate the DB
69+
- ./objects-apis/fixtures/objects_api_fixtures.json:/app/fixtures/objects_api_fixtures.json
4570
depends_on:
4671
- objects-objecttypes-db
4772
- objects-redis
@@ -63,8 +88,8 @@ services:
6388
volumes:
6489
- ./objects-apis/nginx.conf:/etc/nginx/conf.d/default.conf
6590
ports:
66-
- '8001:80'
67-
- '8002:81'
91+
- '8001:8001'
92+
- '8002:8002'
6893
depends_on:
6994
- objects-web
7095
- objecttypes-web

docker/docker-compose.open-zaak.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
- open-forms-dev
2121

2222
openzaak-web.local:
23-
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.11.0}
23+
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.13.0}
2424
environment: &openzaak_web_env
2525
- DJANGO_SETTINGS_MODULE=openzaak.conf.docker
2626
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
@@ -43,6 +43,8 @@ services:
4343
ports:
4444
- 8003:8000
4545
volumes: &openzaak_web_volumes
46+
# mount fixtures dir to automatically populate the DB
47+
- ./open-zaak/fixtures/:/app/fixtures
4648
- media:/app/media # Shared media volume to get access to saved OAS files
4749
- private-media:/app/private-media
4850
depends_on:
@@ -52,7 +54,7 @@ services:
5254
- open-forms-dev
5355

5456
celery:
55-
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.11.0}
57+
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.13.0}
5658
environment: *openzaak_web_env
5759
volumes: *openzaak_web_volumes
5860
command: /celery_worker.sh

docker/objects-apis/README.md

+40-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Objects APIs
22

3-
The `docker-compose.objects-apis.yml` compose file is available to run an instance of the Objects and Objecttypes API.
3+
The `docker-compose.objects-apis.yml` compose file is available to run an instance of the Objects
4+
and Objecttypes API.
45

56
## docker compose
67

@@ -10,22 +11,50 @@ Start an instance in your local environment from the parent directory:
1011
docker compose -f docker-compose.objects-apis.yml up -d
1112
```
1213

13-
Create a superuser:
14-
15-
```bash
16-
docker compose -f docker-compose.objects-apis.yml exec objecttypes-web src/manage.py createsuperuser
17-
docker compose -f docker-compose.objects-apis.yml exec objects-web src/manage.py createsuperuser
18-
```
19-
2014
This brings up:
15+
2116
- Objecttypes (admin interface is accessible at http://localhost:8001/admin/).
2217
- Objects (admin interface is accessible at http://localhost:8002/admin/).
2318

19+
You can log in with the `admin` / `admin` credentials.
20+
2421
## Load fixtures
2522

26-
Before re-recording the related VCR tests, you must load some fixtures:
23+
The fixtures in `objects-apis/fixtures` are automatically loaded when the containers start.
24+
25+
## Dump fixtures
26+
27+
Whenever you make changes in the admin for the tests, you need to dump the fixtures again so that
28+
bringing up the containers the next time (or in other developers' environments) will still have the
29+
same data.
30+
31+
Dump the fixtures with (in the `docker` directory):
32+
33+
**Object types API**
34+
35+
```bash
36+
docker compose -f docker-compose.objects-apis.yml run objecttypes-web \
37+
python src/manage.py dumpdata \
38+
--indent=4 \
39+
--output /app/fixtures/objecttypes_api_fixtures.json \
40+
core \
41+
token
42+
```
43+
44+
**Objects API**
45+
46+
```bash
47+
docker compose -f docker-compose.objects-apis.yml run objects-web \
48+
python src/manage.py dumpdata \
49+
--indent=4 \
50+
--output /app/fixtures/objects_api_fixtures.json \
51+
core \
52+
token \
53+
zgw_consumers
54+
```
55+
56+
Depending on your OS, you may need to grant extra write permissions:
2757

2858
```bash
29-
cat objects-apis/fixtures/objecttypes_api_fixtures.json | docker compose -f docker-compose.objects-apis.yml exec -T objecttypes-web src/manage.py loaddata --format=json -
30-
cat objects-apis/fixtures/objects_api_fixtures.json | docker compose -f docker-compose.objects-apis.yml exec -T objects-web src/manage.py loaddata --format=json -
59+
chmod -R o+rwx ./objects-apis/fixtures
3160
```
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,98 @@
1-
[
2-
{
3-
"model": "core.objecttype",
4-
"pk": 1,
5-
"fields": {
6-
"service": 1,
7-
"uuid": "8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
8-
"_name": "Person"
9-
}
10-
},
11-
{
12-
"model": "core.objecttype",
13-
"pk": 2,
14-
"fields": {
15-
"service": 1,
16-
"uuid": "527b8408-7421-4808-a744-43ccb7bdaaa2",
17-
"_name": "File uploads"
18-
}
19-
},
20-
{
21-
"model": "core.objecttype",
22-
"pk": 3,
23-
"fields": {
24-
"service": 1,
25-
"uuid": "f1dde4fe-b7f9-46dc-84ae-429ae49e3705",
26-
"_name": "Geo in data"
27-
}
28-
},
29-
{
30-
"model": "token.tokenauth",
31-
"pk": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
32-
"fields": {
33-
"contact_person": "Admin",
34-
"email": "admin@example.com",
35-
"organization": "",
36-
"last_modified": "2023-10-24T08:58:51.291Z",
37-
"created": "2023-10-24T08:58:51.291Z",
38-
"application": "",
39-
"administration": ""
40-
}
41-
},
42-
{
43-
"model": "token.permission",
44-
"pk": 1,
45-
"fields": {
46-
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
47-
"object_type": 1,
48-
"mode": "read_and_write",
49-
"use_fields": false,
50-
"fields": null
51-
}
52-
},
53-
{
54-
"model": "token.permission",
55-
"pk": 2,
56-
"fields": {
57-
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
58-
"object_type": 2,
59-
"mode": "read_and_write",
60-
"use_fields": false,
61-
"fields": null
62-
}
63-
},
64-
{
65-
"model": "token.permission",
66-
"pk": 3,
67-
"fields": {
68-
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
69-
"object_type": 3,
70-
"mode": "read_and_write",
71-
"use_fields": false,
72-
"fields": null
73-
}
74-
},
75-
{
76-
"model": "zgw_consumers.service",
77-
"pk": 1,
78-
"fields": {
79-
"label": "Local objecttypes",
80-
"oas": "https://raw.githubusercontent.com/maykinmedia/objecttypes-api/master/src/objecttypes/api/v2/openapi.yaml",
81-
"oas_file": "",
82-
"uuid": "ee08faa2-4cd1-45f6-ba16-d50872cf5cf2",
83-
"api_type": "orc",
84-
"api_root": "http://objecttypes-web:8000/api/v2/",
85-
"client_id": "",
86-
"secret": "",
87-
"auth_type": "api_key",
88-
"header_key": "Authorization",
89-
"header_value": "Token 171be5abaf41e7856b423ad513df1ef8f867ff48",
90-
"nlx": "",
91-
"user_id": "",
92-
"user_representation": "",
93-
"client_certificate": null,
94-
"server_certificate": null
95-
}
96-
}
97-
]
1+
[
2+
{
3+
"model": "core.objecttype",
4+
"pk": 1,
5+
"fields": {
6+
"service": 1,
7+
"uuid": "8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
8+
"_name": "Person"
9+
}
10+
},
11+
{
12+
"model": "core.objecttype",
13+
"pk": 2,
14+
"fields": {
15+
"service": 1,
16+
"uuid": "527b8408-7421-4808-a744-43ccb7bdaaa2",
17+
"_name": "File uploads"
18+
}
19+
},
20+
{
21+
"model": "core.objecttype",
22+
"pk": 3,
23+
"fields": {
24+
"service": 1,
25+
"uuid": "f1dde4fe-b7f9-46dc-84ae-429ae49e3705",
26+
"_name": "Geo in data"
27+
}
28+
},
29+
{
30+
"model": "token.tokenauth",
31+
"pk": 1,
32+
"fields": {
33+
"token": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
34+
"contact_person": "Admin",
35+
"email": "admin@example.com",
36+
"organization": "",
37+
"last_modified": "2023-10-24T08:58:51.291Z",
38+
"created": "2023-10-24T08:58:51.291Z",
39+
"application": "",
40+
"administration": ""
41+
}
42+
},
43+
{
44+
"model": "token.permission",
45+
"pk": 1,
46+
"fields": {
47+
"token_auth": 1,
48+
"object_type": 1,
49+
"mode": "read_and_write",
50+
"use_fields": false,
51+
"fields": null
52+
}
53+
},
54+
{
55+
"model": "token.permission",
56+
"pk": 2,
57+
"fields": {
58+
"token_auth": 1,
59+
"object_type": 2,
60+
"mode": "read_and_write",
61+
"use_fields": false,
62+
"fields": null
63+
}
64+
},
65+
{
66+
"model": "token.permission",
67+
"pk": 3,
68+
"fields": {
69+
"token_auth": 1,
70+
"object_type": 3,
71+
"mode": "read_and_write",
72+
"use_fields": false,
73+
"fields": null
74+
}
75+
},
76+
{
77+
"model": "zgw_consumers.service",
78+
"pk": 1,
79+
"fields": {
80+
"label": "Local objecttypes",
81+
"oas": "https://raw.githubusercontent.com/maykinmedia/objecttypes-api/master/src/objecttypes/api/v2/openapi.yaml",
82+
"oas_file": "",
83+
"uuid": "ee08faa2-4cd1-45f6-ba16-d50872cf5cf2",
84+
"api_type": "orc",
85+
"api_root": "http://objecttypes-web:8000/api/v2/",
86+
"client_id": "",
87+
"secret": "",
88+
"auth_type": "api_key",
89+
"header_key": "Authorization",
90+
"header_value": "Token 171be5abaf41e7856b423ad513df1ef8f867ff48",
91+
"nlx": "",
92+
"user_id": "",
93+
"user_representation": "",
94+
"client_certificate": null,
95+
"server_certificate": null
96+
}
97+
}
98+
]

0 commit comments

Comments
 (0)