Class ComposeFileGenerator

java.lang.Object
org.fhirfrog.frog.ant.ig.ComposeFileGenerator

public class ComposeFileGenerator extends Object
Generates a Docker Compose file with two profiles for HAPI FHIR testing.

Profile: bootstrap

Starts a stock postgres:17 and a base HAPI FHIR server (hapiproject/hapi:v8.8.0-1) with the generated application.yaml mounted. HAPI loads all configured IG packages into postgres. Once healthy (detected by HTTP polling in FhirBootstrapTask), the HAPI container is committed as a named image and the postgres database is captured via pg_dump to packages.sql in the output directory.

Profile: test

Starts a fresh postgres:17 with packages.sql mounted at /docker-entrypoint-initdb.d/01-packages.sql so the database is restored automatically on first start. Starts HAPI from the pre-committed snapshot image (${FHIR_FROG_IMAGE}). Fast startup (~60s) because all packages are already present in the restored postgres database.

Health checks

HAPI services use healthcheck: disable: true because the hapiproject/hapi image is distroless and has no shell or curl. HAPI readiness is checked externally by polling /actuator/health via HTTP (see FhirBootstrapTask and the <waitfor> in build.xml).

  • Field Details

  • Constructor Details

    • ComposeFileGenerator

      public ComposeFileGenerator()
  • Method Details

    • generate

      public void generate(Path outputDir, String imageTag, String configRelPath) throws IOException
      Writes docker-compose.yml to outputDir/docker-compose.yml.

      hapi-bootstrap mounts configRelPath (e.g. ./application.yaml) which may contain packageUrl: file://... entries for local #dev/#current packages. hapi-test mounts the -test variant (e.g. ./application-test.yaml) which has those entries stripped — HAPI v8 fetches packageUrl before checking reloadExisting, so it would crash if the packages volume is absent.

      postgres-test mounts ./packages.sql at /docker-entrypoint-initdb.d/01-packages.sql so the database is restored from the bootstrap pg_dump on first container start.

      Parameters:
      outputDir - directory to write the file into (created if absent)
      imageTag - Docker image tag for the committed HAPI snapshot
      configRelPath - relative path from the Compose file to application.yaml
      Throws:
      IOException