[ADMINAPI-1417] - DO NOT MERGE - SPIKE - Investigate database templates setup#387
[ADMINAPI-1417] - DO NOT MERGE - SPIKE - Investigate database templates setup#387DavidJGapCR wants to merge 1 commit into
Conversation
| "IgnoresCertificateErrors": true, | ||
| "adminApiMode": "v2", | ||
| "EncryptionKey": "TDMyNH0lJmo7aDRnNXYoSmAwSXQpV09nbitHSWJTKn0=", | ||
| "SqlServerMinimalBakFile": "./backups/EdFi_Ods_Minimal_Template.bak", |
There was a problem hiding this comment.
The final path where the bak files are downloaded and extracted is something like /var/opt/mssql/data/backups/EdFi_Ods_Minimal_Template.bak
We can probably change this on real implementation
| "EdFi_Admin": "host=localhost;port=5880;username=postgres;password=P@ssw0rd;database=EdFi_Admin;pooling=true", | ||
| "EdFi_Security": "host=localhost;port=5880;username=postgres;password=P@ssw0rd;database=EdFi_Security;pooling=true", | ||
| "EdFi_Ods": "host=localhost;port=5401;username=postgres;password=P@ssw0rd;database=EdFi_Ods;pooling=true", | ||
| "EdFi_Master": "host=localhost;port=5401;username=postgres;password=P@ssw0rd;database=postgres;pooling=true" |
There was a problem hiding this comment.
The master database for pgsql would be postgres
|
|
||
| # Start a new layer so that the above layer can be cached | ||
| FROM base AS build | ||
| ARG MINIMAL_ODS_VERSION |
There was a problem hiding this comment.
These ARG need to be on the environment variables, it is part of the path to download the populated and minimal databases from Azure artefacts.
| echo "Creating and restoring Ods_Minimal_Template..." | ||
| su-exec postgres psql -p "$POSTGRES_PORT" -U "$POSTGRES_USER" \ | ||
| -c "CREATE DATABASE \"Ods_Minimal_Template\";" | ||
| PGPASSWORD="$POSTGRES_PASSWORD" su-exec postgres psql \ |
There was a problem hiding this comment.
Restore minimal database.
| --username="$POSTGRES_USER" \ | ||
| --dbname="Ods_Minimal_Template" \ | ||
| -f /app/backups/EdFi.Ods.Minimal.Template.sql | ||
| su-exec postgres psql -p "$POSTGRES_PORT" -U "$POSTGRES_USER" \ |
There was a problem hiding this comment.
Then make it a template database so we can generate copies from it.
| echo "Creating and restoring Ods_Populated_Template..." | ||
| su-exec postgres psql -p "$POSTGRES_PORT" -U "$POSTGRES_USER" \ | ||
| -c "CREATE DATABASE \"Ods_Populated_Template\";" | ||
| PGPASSWORD="$POSTGRES_PASSWORD" su-exec postgres psql \ |
There was a problem hiding this comment.
Then the same for populated
| services: | ||
| db-ods: | ||
| image: edfialliance/ods-api-db-ods-minimal:${TAG} | ||
| build: |
There was a problem hiding this comment.
instead of using the minimal template directly from docker hub, we generate our own image, where we download the Azure artefact, extract it, etc.
| WORKDIR /app | ||
|
|
||
| # Download and extract Minimal Template for core Ed-Fi Data Model | ||
| RUN umask 0077 && \ |
There was a problem hiding this comment.
Downloads the Azure artefact, extract it, remove the zip, and that is it.
| @@ -0,0 +1,75 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
This init.sh is very different to the mssql approach. Here we need to restore the backup files.
ea8b8ae to
99384e7
Compare
9e4fc29 to
4fd1674
Compare
This PoC contains changes related to how we are going to setup minimal and populated templates on Docker configuration.
For both engines, mssql and pgsql we followed very similar approaches: We download the corresponding Azure artefacts and then extract them:
Since this is a PoC I changed just the single tenant environments for V2. Multitenant environments and V3 are still pending and will be covered on the implementatio ticket.
In order to be able to test this on my environment I setup the databases in Docker, and then I ran the Admin Api from the host machine, in order to be able to debug the code step by step and see how the new data stores (Ods instances) are properly created. I also used the dbinstances.http file.
In relation to supporting multiple data standards, we will talk about that in the review meeting on Wednesday. If necessary we'll create another ticket for the implementation. Admin Api doesn't support multiple data standards at the moment.
UPDATE: