Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker compose setup for local development #4489

Merged
merged 5 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions docker/docker-compose.objects-apis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,53 @@ services:
- open-forms-dev

objecttypes-web:
image: maykinmedia/objecttypes-api:${OBJECTTYPES_VERSION:-2.1.1}
image: maykinmedia/objecttypes-api:${OBJECTTYPES_VERSION:-2.2.0}
environment:
- DJANGO_SETTINGS_MODULE=objecttypes.conf.docker
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
- ALLOWED_HOSTS=*
- USE_X_FORWARDED_HOST=true
- DB_HOST=objects-objecttypes-db
- DB_NAME=objecttypes
- DB_USER=objecttypes
- CACHE_DEFAULT=objects-redis:6379/1
- CACHE_AXES=objects-redis:6379/1
- OBJECTTYPE_SUPERUSER_USERNAME=admin
- OBJECTTYPE_SUPERUSER_PASSWORD=admin
- OBJECTTYPE_SUPERUSER_EMAIL=admin@localhost
- DISABLE_2FA=true
volumes:
# mount fixtures dir to automatically populate the DB
- ./objects-apis/fixtures/objecttypes_api_fixtures.json:/app/fixtures/objecttypes_api_fixtures.json
depends_on:
- objects-objecttypes-db
- objects-redis
networks:
- open-forms-dev

objects-web:
image: maykinmedia/objects-api:${OBJECTS_VERSION:-2.3.0}
image: maykinmedia/objects-api:${OBJECTS_VERSION:-2.3.2}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the v2.3.2 in the repo. Can we assume that from somewhere else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I had to look at docker hub / git tags too, it's not in the changelog

environment: &objects_web_env
- DJANGO_SETINGS_MODULE=objects.conf.docker
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
- ALLOWED_HOSTS=*
- USE_X_FORWARDED_HOST=true
- DB_HOST=objects-objecttypes-db
- DB_NAME=objects
- DB_USER=objects
- CACHE_DEFAULT=objects-redis:6379/0
- CACHE_AXES=objects-redis:6379/0
- DISABLE_2FA=True
- CELERY_BROKER_URL=redis://objects-redis:6379/0
- CELERY_RESULT_BACKEND=redis://objects-redis:6379/0
- NOTIFICATIONS_DISABLED=True
- OBJECTS_SUPERUSER_USERNAME=admin
- OBJECTS_SUPERUSER_PASSWORD=admin
- OBJECTS_SUPERUSER_EMAIL=admin@localhost
- DISABLE_2FA=true
volumes:
# mount fixtures dir to automatically populate the DB
- ./objects-apis/fixtures/objects_api_fixtures.json:/app/fixtures/objects_api_fixtures.json
depends_on:
- objects-objecttypes-db
- objects-redis
Expand All @@ -63,8 +88,8 @@ services:
volumes:
- ./objects-apis/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- '8001:80'
- '8002:81'
- '8001:8001'
- '8002:8002'
depends_on:
- objects-web
- objecttypes-web
Expand Down
6 changes: 4 additions & 2 deletions docker/docker-compose.open-zaak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
- open-forms-dev

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

celery:
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.11.0}
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.13.0}
environment: *openzaak_web_env
volumes: *openzaak_web_volumes
command: /celery_worker.sh
Expand Down
51 changes: 40 additions & 11 deletions docker/objects-apis/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Objects APIs

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

## docker compose

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

Create a superuser:

```bash
docker compose -f docker-compose.objects-apis.yml exec objecttypes-web src/manage.py createsuperuser
docker compose -f docker-compose.objects-apis.yml exec objects-web src/manage.py createsuperuser
```

This brings up:

- Objecttypes (admin interface is accessible at http://localhost:8001/admin/).
- Objects (admin interface is accessible at http://localhost:8002/admin/).

You can log in with the `admin` / `admin` credentials.

## Load fixtures

Before re-recording the related VCR tests, you must load some fixtures:
The fixtures in `objects-apis/fixtures` are automatically loaded when the containers start.

## 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):

**Object types API**

```bash
docker compose -f docker-compose.objects-apis.yml run objecttypes-web \
python src/manage.py dumpdata \
--indent=4 \
--output /app/fixtures/objecttypes_api_fixtures.json \
core \
token
```

**Objects API**

```bash
docker compose -f docker-compose.objects-apis.yml run objects-web \
python src/manage.py dumpdata \
--indent=4 \
--output /app/fixtures/objects_api_fixtures.json \
core \
token \
zgw_consumers
```

Depending on your OS, you may need to grant extra write permissions:

```bash
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 -
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 -
chmod -R o+rwx ./objects-apis/fixtures
```
195 changes: 98 additions & 97 deletions docker/objects-apis/fixtures/objects_api_fixtures.json
Original file line number Diff line number Diff line change
@@ -1,97 +1,98 @@
[
{
"model": "core.objecttype",
"pk": 1,
"fields": {
"service": 1,
"uuid": "8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
"_name": "Person"
}
},
{
"model": "core.objecttype",
"pk": 2,
"fields": {
"service": 1,
"uuid": "527b8408-7421-4808-a744-43ccb7bdaaa2",
"_name": "File uploads"
}
},
{
"model": "core.objecttype",
"pk": 3,
"fields": {
"service": 1,
"uuid": "f1dde4fe-b7f9-46dc-84ae-429ae49e3705",
"_name": "Geo in data"
}
},
{
"model": "token.tokenauth",
"pk": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
"fields": {
"contact_person": "Admin",
"email": "[email protected]",
"organization": "",
"last_modified": "2023-10-24T08:58:51.291Z",
"created": "2023-10-24T08:58:51.291Z",
"application": "",
"administration": ""
}
},
{
"model": "token.permission",
"pk": 1,
"fields": {
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
"object_type": 1,
"mode": "read_and_write",
"use_fields": false,
"fields": null
}
},
{
"model": "token.permission",
"pk": 2,
"fields": {
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
"object_type": 2,
"mode": "read_and_write",
"use_fields": false,
"fields": null
}
},
{
"model": "token.permission",
"pk": 3,
"fields": {
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
"object_type": 3,
"mode": "read_and_write",
"use_fields": false,
"fields": null
}
},
{
"model": "zgw_consumers.service",
"pk": 1,
"fields": {
"label": "Local objecttypes",
"oas": "https://raw.githubusercontent.com/maykinmedia/objecttypes-api/master/src/objecttypes/api/v2/openapi.yaml",
"oas_file": "",
"uuid": "ee08faa2-4cd1-45f6-ba16-d50872cf5cf2",
"api_type": "orc",
"api_root": "http://objecttypes-web:8000/api/v2/",
"client_id": "",
"secret": "",
"auth_type": "api_key",
"header_key": "Authorization",
"header_value": "Token 171be5abaf41e7856b423ad513df1ef8f867ff48",
"nlx": "",
"user_id": "",
"user_representation": "",
"client_certificate": null,
"server_certificate": null
}
}
]
[
{
"model": "core.objecttype",
"pk": 1,
"fields": {
"service": 1,
"uuid": "8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
"_name": "Person"
}
},
{
"model": "core.objecttype",
"pk": 2,
"fields": {
"service": 1,
"uuid": "527b8408-7421-4808-a744-43ccb7bdaaa2",
"_name": "File uploads"
}
},
{
"model": "core.objecttype",
"pk": 3,
"fields": {
"service": 1,
"uuid": "f1dde4fe-b7f9-46dc-84ae-429ae49e3705",
"_name": "Geo in data"
}
},
{
"model": "token.tokenauth",
"pk": 1,
"fields": {
"token": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
"contact_person": "Admin",
"email": "[email protected]",
"organization": "",
"last_modified": "2023-10-24T08:58:51.291Z",
"created": "2023-10-24T08:58:51.291Z",
"application": "",
"administration": ""
}
},
{
"model": "token.permission",
"pk": 1,
"fields": {
"token_auth": 1,
"object_type": 1,
"mode": "read_and_write",
"use_fields": false,
"fields": null
}
},
{
"model": "token.permission",
"pk": 2,
"fields": {
"token_auth": 1,
"object_type": 2,
"mode": "read_and_write",
"use_fields": false,
"fields": null
}
},
{
"model": "token.permission",
"pk": 3,
"fields": {
"token_auth": 1,
"object_type": 3,
"mode": "read_and_write",
"use_fields": false,
"fields": null
}
},
{
"model": "zgw_consumers.service",
"pk": 1,
"fields": {
"label": "Local objecttypes",
"oas": "https://raw.githubusercontent.com/maykinmedia/objecttypes-api/master/src/objecttypes/api/v2/openapi.yaml",
"oas_file": "",
"uuid": "ee08faa2-4cd1-45f6-ba16-d50872cf5cf2",
"api_type": "orc",
"api_root": "http://objecttypes-web:8000/api/v2/",
"client_id": "",
"secret": "",
"auth_type": "api_key",
"header_key": "Authorization",
"header_value": "Token 171be5abaf41e7856b423ad513df1ef8f867ff48",
"nlx": "",
"user_id": "",
"user_representation": "",
"client_certificate": null,
"server_certificate": null
}
}
]
Loading
Loading