Skip to content

[ADMINAPI-1416] Switch to Docker Hardened Image for PostgreSQL - #415

Open
jpardogrowthaccelerationpartners wants to merge 10 commits into
mainfrom
ADMINAPI-1416
Open

[ADMINAPI-1416] Switch to Docker Hardened Image for PostgreSQL#415
jpardogrowthaccelerationpartners wants to merge 10 commits into
mainfrom
ADMINAPI-1416

Conversation

@jpardogrowthaccelerationpartners

@jpardogrowthaccelerationpartners jpardogrowthaccelerationpartners commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

PR Summary

Objective

Migrate the Admin API PostgreSQL database to a Docker Hardened Image, maintaining functional compatibility with the Ed-Fi legacy bootstrap and improving the maintainability of the Docker/CI workflow.

Main Changes

1. Admin PGSQL DB (runtime/local)

  • Updated the database to use a hardened image.

  • Incorporated legacy bootstrap (base structure) before Admin API migrations.

  • Adjusted build paths and contexts.

  • Fixed startup to run bootstrap and migrations sequentially.

2. Admin PGSQL DB (published images)

  • Updated published Dockerfiles for V2/V3.

  • Configured script consumption from the shared folder.

  • Integrated the shared build context into publish pipelines.

3. Script Centralization

  • Logic was consolidated into shared scripts (entrypoint + migrations).

  • Duplication was eliminated in versioned folders V2/V3.

4. Docker Publish/Analysis Pipelines

  • Shared context was added to publish/prerelease workflows.

  • The PR workflow for published db-admin/pgsql builds was adjusted with a shared context.

5. E2E PGSQL Pipelines

  • Docker Hub authentication was added to the four E2E PGSQL workflows (V2/V3, single/multi-tenant) before docker compose up.

  • This enables pulling dhi.io/postgres:16 in CI.

Expected Result

  • Database hardening for PostgreSQL in the Admin API.

  • Full Bootstrap implementation of EdFi_Admin and EdFi_Security before incremental migrations.

  • Reduced script duplication and improved maintainability.

  • Pipelines ready for authentication required by hardened images.

PR Impact

  • Files modified: 14
  • Changes: 224 inserts, 111 deletes
  • Branch: ADMINAPI-1416
  • Main commit: 70b5813

Local Validation Note

To properly validate the DB Admin initialization, it is recommended to rebuild without caching and reinitialize the db-admin volume.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🔍 Vulnerabilities of development:latest

📦 Image Reference development:latest
digestsha256:d84beb64684b8ba8d96591574640cd3f80ae742b608c0d25d91c1d560f21e88c
vulnerabilitiescritical: 0 high: 1 medium: 3 low: 4 unspecified: 1
platformlinux/amd64
size102 MB
packages468
📦 Base Image alpine:3.22
also known as
  • 3.22.3
digestsha256:e0baf8c394150ac5a14925e179100519f5e37c53547f647acbd9f8eb3e5c4528
vulnerabilitiescritical: 2 high: 14 medium: 8 low: 3
critical: 0 high: 1 medium: 1 low: 0 musl 1.2.5-r10 (apk)

pkg:apk/alpine/musl@1.2.5-r10?os_name=alpine&os_version=3.22

high : CVE--2026--40200

Affected range<1.2.5-r12
Fixed version1.2.5-r12
EPSS Score0.166%
EPSS Percentile6th percentile
Description

medium : CVE--2026--6042

Affected range<1.2.5-r11
Fixed version1.2.5-r11
EPSS Score0.236%
EPSS Percentile15th percentile
Description
critical: 0 high: 0 medium: 1 low: 1 zlib 1.3.1-r2 (apk)

pkg:apk/alpine/zlib@1.3.1-r2?os_name=alpine&os_version=3.22

medium : CVE--2026--22184

Affected range<1.3.2-r0
Fixed version1.3.2-r0
EPSS Score0.381%
EPSS Percentile31st percentile
Description

low : CVE--2026--27171

Affected range<1.3.2-r0
Fixed version1.3.2-r0
EPSS Score0.218%
EPSS Percentile12th percentile
Description
critical: 0 high: 0 medium: 1 low: 0 busybox 1.37.0-r20 (apk)

pkg:apk/alpine/busybox@1.37.0-r20?os_name=alpine&os_version=3.22

medium : CVE--2025--60876

Affected range<=1.37.0-r20
Fixed versionNot Fixed
EPSS Score0.285%
EPSS Percentile21st percentile
Description
critical: 0 high: 0 medium: 0 low: 3 libxml2 2.13.9-r1 (apk)

pkg:apk/alpine/libxml2@2.13.9-r1?os_name=alpine&os_version=3.22

low : CVE--2026--0989

Affected range<=2.13.9-r1
Fixed versionNot Fixed
EPSS Score0.438%
EPSS Percentile36th percentile
Description

low : CVE--2025--8732

Affected range<=2.13.9-r1
Fixed versionNot Fixed
EPSS Score0.202%
EPSS Percentile10th percentile
Description

low : CVE--2026--11979

Affected range<=2.13.9-r1
Fixed versionNot Fixed
EPSS Score0.148%
EPSS Percentile5th percentile
Description
critical: 0 high: 0 medium: 0 low: 0 unspecified: 1lz4 1.10.0-r0 (apk)

pkg:apk/alpine/lz4@1.10.0-r0?os_name=alpine&os_version=3.22

unspecified : CVE--2025--62813

Affected range<=1.10.0-r0
Fixed versionNot Fixed
EPSS Score0.018%
EPSS Percentile3rd percentile
Description

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Test Results

   15 files     15 suites   1m 10s ⏱️
1 815 tests 1 801 ✅ 14 💤 0 ❌
4 267 runs  4 229 ✅ 38 💤 0 ❌

Results for commit 679b43e.

♻️ This comment has been updated with latest results.

@jpardogrowthaccelerationpartners jpardogrowthaccelerationpartners changed the title [AC-582] Switch to Docker Hardened Image for PostgreSQL [ADMINAPI-1416] Switch to Docker Hardened Image for PostgreSQL Jul 30, 2026
@jpardogrowthaccelerationpartners
jpardogrowthaccelerationpartners marked this pull request as ready for review July 31, 2026 16:21
Comment thread Docker/V2/db.pgsql.admin.Dockerfile
Comment thread Docker/Settings/V2/DB-Admin/pgsql/Dockerfile Outdated
Comment thread Docker/Settings/V2/DB-Admin/pgsql/Dockerfile Outdated
Comment thread Docker/Settings/V3/DB-Admin/pgsql/Dockerfile Outdated
Comment thread Docker/Settings/V3/DB-Admin/pgsql/Dockerfile Outdated
Comment thread Docker/Settings/V3/DB-Admin/pgsql/Dockerfile
Comment thread Docker/V2/db.pgsql.admin.Dockerfile Outdated
Comment thread Docker/V2/db.pgsql.admin.Dockerfile Outdated
Comment thread Docker/V2/db.pgsql.admin.Dockerfile
Comment thread Docker/V3/db.pgsql.admin.Dockerfile Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A helpful note from Claude (Sonnet 5):

Likely double execution of bootstrap + migration scripts. Docker/Settings/shared/DB-Admin/pgsql/entrypoint.sh backgrounds the original postgres entrypoint ($ORIGINAL_ENTRYPOINT "$@" &), waits for pg_isready, then explicitly runs:

sh "$BASE_BOOTSTRAP_SCRIPT"   # /docker-entrypoint-initdb.d/1-init-database.sh
sh "$MIGRATIONS_SCRIPT"       # /docker-entrypoint-initdb.d/3-run-adminapi-migrations.sh

But both of those files are also copied into /docker-entrypoint-initdb.d/, which the stock Postgres docker-entrypoint.sh auto-processes on first init (during its temp-server phase, before the real server starts listening — i.e., before pg_isready on 127.0.0.1 can succeed). That means by the time this wrapper's pg_isready loop exits, the standard mechanism has already run both scripts once, and the wrapper then runs them a second time.

The added create_db_if_missing guard in run-adminapi-migrations.sh suggests the author ran into exactly this collision and patched around it for the CREATE DATABASE step — but the actual DDL/DML in the migration .sql files and in 1-init-database.sh (inherited from the legacy image, not something this PR controls) aren't necessarily idempotent. Worth explicitly verifying (and the PR's own "rebuild without caching, reinitialize volume" note hints this hasn't been fully clean-room tested). Recommend either:

  • Removing the files from /docker-entrypoint-initdb.d/ and only invoking them manually from the wrapper, or
  • Confirming (and documenting) that both scripts are safely re-runnable.


USER root
RUN wget -nv -O /tmp/EdFi_AdminApi_Scripts.zip "https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi/nuget/packages/EdFi.Suite3.ODS.AdminApi/versions/${VERSION}/content" && \
RUN apk add --no-cache dos2unix=7.5.2-r0 unzip=6.0-r14 wget=1.24.5-r0 && \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The older version used unzip=6.0-r15, can we restore that?

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.

I was getting an error while building with that version, so I uninstalled it. I'm going to try running it again to see if it was just a glitch that day.

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.

I verified the matrix: Alpine 3.20 only has unzip 6.0-r14, while 3.21 and 3.22 have 6.0-r15. I’m applying the safe fix now by pinning unzip to r14 in the V2 and V3 settings Dockerfiles that still use Alpine 3.20.

I’ve patched both settings files; now I’m verifying there are no remaining r15 pins in the DB-Admin pgsql Dockerfiles and that the diff is clean.

Yes. I checked it directly in containers:

alpine:3.20 has unzip-6.0-r14 only
alpine:3.21 has unzip-6.0-r15
alpine:3.22 has unzip-6.0-r15
alpine:edge has unzip-6.0-r16
Since your Dockerfiles are pinned to alpine:3.20, I applied the compatible fix:

Changed unzip=6.0-r15 to unzip=6.0-r14 in Dockerfile:21
Changed unzip=6.0-r15 to unzip=6.0-r14 in Dockerfile:21
This should clear the current apk constraint error while keeping your sha256 image pinning requirement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we move all of these Bruno script changes to a separate PR, instead of mixing them in with the base image hardening?

@jpardogrowthaccelerationpartners jpardogrowthaccelerationpartners Aug 3, 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.

Thinking about it, I think it's better to leave it here because if I put them in another PR we wouldn't be able to merge this one since the test check wouldn't pass.

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.

2 participants