Skip to content

[ADMINAPI-1417] - DO NOT MERGE - SPIKE - Investigate database templates setup#387

Draft
DavidJGapCR wants to merge 1 commit into
mainfrom
ADMINAPI-1417-2
Draft

[ADMINAPI-1417] - DO NOT MERGE - SPIKE - Investigate database templates setup#387
DavidJGapCR wants to merge 1 commit into
mainfrom
ADMINAPI-1417-2

Conversation

@DavidJGapCR

@DavidJGapCR DavidJGapCR commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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:

  1. Then, for mssql we just extract them because based on the approached followed, what the user configures on the AppSettings is a path to a set of bak files, in the code these files will be restored.
  2. But for pgsql the approach is different, we generate a copy from a template database, which means that once the Azure artefact is extracted, we also restore it.

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:

  1. Based on comments I changed the approach. Instead of downloading the template databases from Azure artefacts, the user will be responsible for providing those files from the host.
  2. Based on conversation with Stephen, we do not need to support multiple data standards.

"IgnoresCertificateErrors": true,
"adminApiMode": "v2",
"EncryptionKey": "TDMyNH0lJmo7aDRnNXYoSmAwSXQpV09nbitHSWJTKn0=",
"SqlServerMinimalBakFile": "./backups/EdFi_Ods_Minimal_Template.bak",

@DavidJGapCR DavidJGapCR Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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" \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Then the same for populated

services:
db-ods:
image: edfialliance/ods-api-db-ods-minimal:${TAG}
build:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 && \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Downloads the Azure artefact, extract it, remove the zip, and that is it.

@@ -0,0 +1,75 @@
#!/bin/bash

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This init.sh is very different to the mssql approach. Here we need to restore the backup files.

@DavidJGapCR DavidJGapCR changed the title [ADMINAPI-1417] - SPIKE - Investigate database templates setup [ADMINAPI-1417] - DO NOT MERGE - SPIKE - Investigate database templates setup Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant