ONC-XXXX - Create Docker image on branch push - #2014
Closed
tmy1313 wants to merge 18 commits into
Closed
Conversation
Templated server.xml/context.xml resolve DB credentials from container environment variables via Tomcat's EnvironmentPropertySource, and entrypoint.sh materializes the JWK signing key from an env var at startup. The image itself contains no secrets and is identical across every environment. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Manual workflow_dispatch trigger; builds docker/Dockerfile and pushes to ghcr.io tagged <branch>-<sha> and <branch>-latest. No secrets required at build time. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
workflow_dispatch only appears in the Actions UI once this file exists on the default branch. Adding pull_request lets the workflow be validated on this PR first. Also fixes branch-name resolution for PR events (github.ref_name is '<pr>/merge' there, not the branch name). Must be reverted before merging to the default branch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replaces <branch>-<sha>/<branch>-latest with:
build-<run_number> - immutable, sequential build identifier
sha-<short-sha> - immutable, traces to the exact commit
latest-<branch> - floating pointer to the most recent build from
that branch (latest-development, latest-qa,
latest-staging, latest-production once
triggered from those branches)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Lists every environment variable the secret-free image needs or accepts (DB/JWK required-to-start vars, filesystem-path vars needing a volume mount, environment-dependent non-secret vars, and all 31 properties currently marked SECRET in environment.properties/ email.properties, grouped by feature area). Points at AudaciousInquiry/chpl-build for where real values live today without reproducing any of them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
docker/build-push-action v6 enables build provenance and SBOM attestations by default, each pushing an extra untagged manifest to GHCR per build (2 per run, with no architecture info, cluttering the package version list). Not needed here, so both are turned off. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This reverts commit 1cf2ee3.
Adds push triggers for development, qa, staging, and production so merging into any of them builds and pushes an image tagged latest-<branch>, without needing per-branch copies of the workflow. push triggers are evaluated per-ref and aren't gated by which branch is the repo's default, unlike workflow_dispatch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
No code reads a keyLocation property or local JWK file anymore - JWT verification goes through Cognito's public JWKS URL. Removing the dead entrypoint.sh materialization step and its references in the Dockerfile, README, and server.xml.
.git (177M) and target/ build dirs (chpl-api/target alone is 1.7GB) were being sent to the Docker daemon as build context on every CI push despite never being referenced by docker/Dockerfile.
There was a problem hiding this comment.
Pull request overview
Adds containerization support for chpl-api and automates building/publishing a Tomcat-based Docker image to GHCR on pushes to environment branches.
Changes:
- Added a GitHub Actions workflow to build and push a Docker image to GHCR on pushes to
development,qa,staging, andproduction. - Added a multi-stage Docker build that packages the WAR and runs it on Tomcat, plus Tomcat config files that resolve DB settings from environment variables.
- Added Docker runtime documentation, a
.dockerignore, and a.gitattributesrule intended to enforce LF line endings for a container entrypoint script.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
docker/tomcat-conf/server.xml |
Defines Tomcat server configuration and a JNDI DataSource wired via env var substitution. |
docker/tomcat-conf/context.xml |
Links the global JNDI resource into the webapp context. |
docker/tomcat-conf/catalina.properties |
Enables EnvironmentPropertySource for ${ENV_VAR} placeholder resolution. |
docker/README.md |
Documents required/optional environment variables for running the image. |
docker/Dockerfile |
Builds the WAR with Maven and deploys it into a Tomcat runtime image. |
.github/workflows/docker-publish.yml |
Builds/pushes the image to GHCR with branch/build/SHA tagging. |
.gitattributes |
Adds an LF-ending rule intended for a Docker entrypoint script. |
.dockerignore |
Excludes git metadata, build outputs, and local tooling directories from the Docker build context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
docker/entrypoint.sh was deleted (its only job, materializing JWK_KEY, was dead code) - the eol=lf rule for it is now orphaned.
The workflow publishes a floating latest-<branch> tag; without a concurrency group, two runs for the same branch could race and let an older commit's build finish last, overwriting latest-<branch> with a stale image.
Add a unit-tests job to docker-publish.yml that runs `mvn clean test` on JDK 21, mirroring the Bamboo chpl-build-dev "Run API Unit Tests" job. build-and-push now depends on it via needs, so a broken test suite blocks the image push instead of publishing a broken build.
andlar
reviewed
Jul 23, 2026
| - development | ||
| - qa | ||
| - staging | ||
| - production |
Contributor
There was a problem hiding this comment.
While I think we want to get to PROD eventually, I'd like to make sure we don't touch PROD at all until we're comfortable with the lower environments, so can we take this branch out of the list for now?
Add a compile job that runs `mvn clean package -DskipTests`, the same command docker/Dockerfile's build stage runs, mirroring the "Build API"/CompileApiTask job in the chpl-build-dev Bamboo spec. build-and-push now needs both unit-tests and compile, so a broken build fails fast instead of partway through the slower Docker build.
Scratch commit for testing docker-publish.yml's unit-tests job - will be reverted.
This reverts commit cfb9ae6.
Scratch commit for testing docker-publish.yml's compile job (missing semicolon) - will be reverted.
This reverts commit 1d610f9.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds automated Docker image builds and publishing to GitHub Container Registry (GHCR), along with all supporting Docker/Tomcat configuration needed to run the API in a container.
Changes
GitHub Actions Workflow (
.github/workflows/docker-publish.yml)development,qa,staging, orproductionbranches, as well as on manualworkflow_dispatchbuild-<run_number>— immutable, sequential build identifiersha-<short-sha>— immutable, traces back to the exact commitlatest-<branch>— floating pointer to the most recent build from that branch (e.g.latest-development)Dockerfile (
docker/Dockerfile)maven:3.9-eclipse-temurin-21-alpineto compile and package the WAR, leveraging Docker layer caching for Maven dependencies; Stage 2 deploys totomcat:11.0.23-jdk21docker runtimeEntrypoint (
docker/entrypoint.sh)JWK_KEYenvironment variable into the file path thatchpl-apiexpects, then starts TomcatTomcat Configuration (
docker/tomcat-conf/)server.xml— configures thejdbc/openchplJNDI datasource usingEnvironmentPropertySourceso DB connection details are resolved from container environment variables at startup (no secrets in the file)catalina.properties— enablesEnvironmentPropertySourceso${ENV_VAR}placeholders inserver.xmlare resolved from the environmentcontext.xml— links the globaljdbc/openchplJNDI resource into the webappDocumentation (
docker/README.md)docker runexample.gitattributesdocker/entrypoint.shwitheol=lfto ensure the shell script retains LF line endings on all platforms (a CRLF shebang breaksdocker build/docker runon Windows checkouts)Testing
docker build -t chpl-api:local .docker/README.mdfor the full list)