Skip to content

Commit

Permalink
Merge pull request #3859 from open-formulieren/feature/3688-phase1-do…
Browse files Browse the repository at this point in the history
…cker

 [#3688] Phase 1 - Add docker compose for objecttypes API
  • Loading branch information
sergei-maertens authored Feb 13, 2024
2 parents 0f31d3f + 1ad7b79 commit d3ce2c2
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docker/docker-compose.objects-apis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3'

services:
db:
image: postgres:${PG_VERSION:-14}
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
- ./objects-apis/docker-init-objecttypes-api-db.sql:/docker-entrypoint-initdb.d/init_db.sql
- objects-apis-db:/var/lib/postgresql/data
networks:
- open-forms-dev

objecttypes-web:
image: maykinmedia/objecttypes-api:${OBJECTTYPES_VERSION:-2.1.1}
environment:
- DJANGO_SETTINGS_MODULE=objecttypes.conf.docker
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
- ALLOWED_HOSTS=*
ports:
- 8001:8000
depends_on:
- db
networks:
- open-forms-dev

volumes:
objects-apis-db:

networks:
open-forms-dev:
name: open-forms-dev
29 changes: 29 additions & 0 deletions docker/objects-apis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Objects APIs

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

(For now, only Objecttypes is available).

## docker compose

Start an instance in your local environment from the parent directory:

```bash
docker compose -f docker-compose.objects-apis.yml up -d
```

Create a super user:

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

This brings up Objecttypes, the admin interface is accessible at http://localhost:8001/admin/.

## Load fixtures

Before re-recording the related VCR tests, you must load some fixtures:

```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 -
```
5 changes: 5 additions & 0 deletions docker/objects-apis/docker-init-objecttypes-api-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE USER objecttypes;
CREATE DATABASE objecttypes;
GRANT ALL PRIVILEGES ON DATABASE objecttypes TO objecttypes;
-- On Postgres 15+, connect to the database and grant schema permissions.
-- GRANT USAGE, CREATE ON SCHEMA public TO objecttypes;
188 changes: 188 additions & 0 deletions docker/objects-apis/fixtures/objecttypes_api_fixtures.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
[
{
"model": "core.objecttype",
"pk": 1,
"fields": {
"uuid": "8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
"name": "Person",
"name_plural": "Persons",
"description": "",
"data_classification": "open",
"maintainer_organization": "",
"maintainer_department": "",
"contact_person": "",
"contact_email": "",
"source": "",
"update_frequency": "unknown",
"provider_organization": "",
"documentation_url": "",
"labels": {},
"created_at": "2023-10-24",
"modified_at": "2024-02-08",
"allow_geometry": true
}
},
{
"model": "core.objecttype",
"pk": 2,
"fields": {
"uuid": "3edfdaf7-f469-470b-a391-bb7ea015bd6f",
"name": "Tree",
"name_plural": "Trees",
"description": "",
"data_classification": "confidential",
"maintainer_organization": "",
"maintainer_department": "",
"contact_person": "",
"contact_email": "",
"source": "",
"update_frequency": "unknown",
"provider_organization": "",
"documentation_url": "",
"labels": {},
"created_at": "2024-02-08",
"modified_at": "2024-02-08",
"allow_geometry": true
}
},
{
"model": "core.objectversion",
"pk": 1,
"fields": {
"object_type": 1,
"version": 1,
"created_at": "2023-10-24",
"modified_at": "2024-02-08",
"published_at": "2024-02-08",
"json_schema": {
"$id": "https://example.com/person.schema.json",
"type": "object",
"title": "Person",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"age": {
"type": "integer",
"minimum": 0,
"description": "Age in years which must be equal to or greater than zero."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"firstName": {
"type": "string",
"description": "The person's first name."
}
}
},
"status": "published"
}
},
{
"model": "core.objectversion",
"pk": 2,
"fields": {
"object_type": 1,
"version": 2,
"created_at": "2024-02-08",
"modified_at": "2024-02-08",
"published_at": "2024-02-08",
"json_schema": {
"$id": "https://example.com/person.schema.json",
"type": "object",
"title": "Person",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"age": {
"type": "integer",
"minimum": 18,
"description": "Age in years which must be equal to or greater than 18."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"firstName": {
"type": "string",
"description": "The person's first name."
}
}
},
"status": "published"
}
},
{
"model": "core.objectversion",
"pk": 3,
"fields": {
"object_type": 1,
"version": 3,
"created_at": "2024-02-08",
"modified_at": "2024-02-08",
"published_at": "2024-02-08",
"json_schema": {
"$id": "https://example.com/person.schema.json",
"type": "object",
"title": "Person",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"age": {
"type": "integer",
"minimum": 18,
"description": "Age in years which must be equal to or greater than 18."
},
"country": {
"type": "string",
"description": "The person's current country."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"firstName": {
"type": "string",
"description": "The person's first name."
}
}
},
"status": "draft"
}
},
{
"model": "core.objectversion",
"pk": 4,
"fields": {
"object_type": 2,
"version": 1,
"created_at": "2024-02-08",
"modified_at": "2024-02-08",
"published_at": "2024-02-08",
"json_schema": {
"$id": "https://example.com/tree.schema.json",
"type": "object",
"title": "Tree",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"height": {
"type": "integer",
"description": "The height of the tree."
}
}
},
"status": "published"
}
},
{
"model": "token.tokenauth",
"pk": "171be5abaf41e7856b423ad513df1ef8f867ff48",
"fields": {
"contact_person": "Admin",
"email": "[email protected]",
"organization": "",
"last_modified": "2023-10-24T08:56:26.955Z",
"created": "2023-10-24T08:56:26.955Z",
"application": "",
"administration": ""
}
}
]

0 comments on commit d3ce2c2

Please sign in to comment.