Skip to content
Operate

Deploy

Run the engine in production with Docker Compose, Kubernetes (Helm) or Terraform on AWS, Azure and Google Cloud.

On this page

The engine is self-hosted: it runs in your network, next to the systems it connects. Pick the path closest to the infrastructure you already run.

PathUse it whenWhere
Docker Composeone server, or a trialapps/engine/docker-compose.yml
Kubernetes (Helm)you run Kubernetesapps/engine/helm/medhook-engine
Terraformyou want the cloud resources built for youapps/engine/terraform/
Air-gapped bundlethe host has no internet accessapps/engine/scripts/bundle-airgap.sh
GKE release bundleproduction in your own Google Cloud projectsee Install

For production in your own Google Cloud project, follow Install: it mirrors a release into your registry and deploys it with Cloud Build. To change versions later, see Upgrade and roll back.

Every path runs the same services: the engine, PostgreSQL, Redis, Medplum, the MLLP listener, Prometheus and Grafana, plus an optional IPsec VPN sidecar. On GKE, Cloud VPN takes the sidecar's place.

Docker Compose

For production, layer docker-compose.prod.yml on the base file. It reads the secrets from Docker secrets files instead of .env, and turns root-secret tokens off.

bash
mkdir -p secrets && chmod 700 secrets
openssl rand -hex 32 > secrets/encryption_master_key.txt
openssl rand -hex 64 > secrets/engine_auth_secret.txt
chmod 600 secrets/*.txt

docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
docker compose ps
bash scripts/smoke-test.sh

Put the license issued by 1Putt in secrets/license_key.txt the same way, and remove SKIP_LICENSE_VALIDATION from .env.

Kubernetes

The Helm chart in apps/engine/helm/medhook-engine deploys the same stack, with values for ingress, persistent volumes, secrets and autoscaling. It needs Helm 3.10 or later and Kubernetes 1.25 or later. Start from values.production.yaml; engine.rootTokenEnabled is false by default.

bash
cd apps/engine/helm
helm lint medhook-engine/
helm upgrade --install medhook-engine medhook-engine/ \
  -f medhook-engine/values.yaml \
  -f medhook-engine/values.production.yaml \
  -n medhook --create-namespace

To give a sending system its own MLLP port, TLS or commit ACKs, add mllp.listeners. See MLLP listeners. If a webhook trigger answers with a step's output (response.mode: destination), set the ingress or load balancer idle timeout above that trigger's wait, up to 60 seconds.

Folders for the Local File adapter

The Local File adapter and the file pickup trigger read and write only inside the folders listed in FILE_ADAPTER_ROOTS. With none listed, they refuse every path. On Kubernetes, mount each folder from an existing PersistentVolumeClaim (an NFS, Filestore or SMB CSI volume) with fileAdapter.mounts. The chart mounts it into the engine and adds its mountPath to FILE_ADAPTER_ROOTS.

yaml
fileAdapter:
  mounts:
    - name: inbound # lowercase letters, digits and -
      mountPath: /mnt/medhook/inbound
      existingClaim: interface-inbound
      readOnly: false # true: a pickup can read files but not move them

The chart refuses to render a mountPath of /, a system folder such as /etc or /tmp, or one of the engine's own paths. An explicit engine.env.FILE_ADAPTER_ROOTS wins over the mounts. On Docker Compose, mount the volume into the engine service and set FILE_ADAPTER_ROOTS yourself, as a comma-separated list of absolute paths. See Local File.

Your own adapters

Adapters you build with the adapter SDK load at startup from a derived image, with runtimeAdapters.dir and runtimeAdapters.allowlist. See Custom adapters.

Cloud

Each folder under apps/engine/terraform/ builds the network, secrets, container service and managed PostgreSQL for one cloud. The AWS, Azure and Cloud Run folders also create a managed Redis; on GKE, Redis runs in the cluster as a cache.

FolderRuns the engine on
awsAWS Fargate (ECS), RDS and ElastiCache
azureAzure Container Instances
gcpGoogle Cloud Run
gkeGoogle Kubernetes Engine, with Cloud SQL, Cloud VPN and Cloud Monitoring alerts. The production path: see Install
multi-regionA warm standby region on AWS or Google Cloud
bash
cd apps/engine/terraform/aws
cp terraform.tfvars.example terraform.tfvars
terraform init
terraform apply

Air-gapped hosts

apps/engine/scripts/bundle-airgap.sh builds one archive with every image and the engine source, plus checksums. Copy it to the host, load the images with docker load, and start the stack as above. The signed license is verified offline, so the engine runs without reaching medhook.dev; leave LICENSE_REVOCATION_URL unset on a host with no egress (see Authentication).

After you deploy

  1. curl https://engine.example.test/api/health returns healthy, with checks.sandbox set to isolated-vm.
  2. Create the first admin with create-engine-user.
  3. Create API clients for your integrations. Do not use root-secret tokens.
  4. Set ENGINE_PUBLIC_URL and ALLOWED_ORIGINS to the engine's real address.
  5. Check CLIENT_IP_SOURCE matches what is in front of the engine: gclb behind Google's HTTP(S) load balancer (GKE Ingress), last-hop behind AWS ALB, ingress-nginx, Caddy or Cloud Run, none when the port is reached directly. The Helm chart, the Terraform templates and Docker Compose set it; a deploy of your own must. See Client IP addresses.
  6. Change the Grafana admin password.

Health is degraded or unhealthy

/api/health answers within about 2 seconds, because every check has its own 2-second deadline. A check that misses it reports timeout instead of down. The top-level status is one of three values:

  • unhealthy, with HTTP 503: PostgreSQL or Redis is down or timeout. The engine can't run workflows. The Compose health check fails on it.
  • degraded, with HTTP 200: PostgreSQL and Redis are up, but at least one other check in the table below is not in its healthy state. Executions run, but something is off.
  • healthy, with HTTP 200: every check is in its healthy state.
CheckHealthyNot healthy, and what it makes the statusWhat to check
postgresup, with latencydown or timeout: unhealthyDATABASE_URL, that the database accepts connections from the engine, and its connection limit.
redisup, with latencydown or timeout: unhealthyREDIS_URL, and that Redis is running and reachable.
medplumup, with latencydown or timeout: degradedThe engine calls $MEDPLUM_BASE_URL/healthcheck (default http://medplum-server:8103). Start Medplum, or point the variable at it.
mllpup, with latencydown or timeout: degradedThe engine calls MLLP_HEALTH_URL (default http://medhook-mllp:8080/health; the Helm chart sets it). Check that the MLLP listener is running. MLLP triggers receive nothing while it is down.
licensevalidpending, grace or invalid: degradedpending: the engine has not verified the license since it started, or the last check failed. grace: the contract term ended and the license stops at graceExpiresAt. invalid: install the license from 1Putt.
memoryokhigh: degradedThe engine's memory is above 90% of the container limit (usage is the percentage). Raise the limit, or lower MAX_CONCURRENT_WORKFLOWS. With no limit, usage is null and the check is always ok.
sandboxisolated-vmunsafe-vm or unavailable: degradedunavailable: custom code, expressions and JavaScript transforms can't run. Use the published engine image, which ships isolated-vm. unsafe-vm: remove SANDBOX_ALLOW_UNSAFE_VM; it is for local development only.
executionArchiveok or offmisconfigured, with an error: degraded. The retention purge stops.Fix what error says, below.

The execution archive's error is one of these:

  • "EXECUTION_ARCHIVE_DIR is set but there is no message key (MESSAGE_ENCRYPTION_KEY or ENCRYPTION_MASTER_KEY)". Set one of the two keys.
  • "The message key (MESSAGE_ENCRYPTION_KEY or ENCRYPTION_MASTER_KEY) must be at least 32 characters to seal the execution archive". Use a longer key.
  • "EXECUTION_ARCHIVE_DIR (…) is not a writable directory". Create the folder, mount it into the engine, and let the engine's user write to it.

/api/health is for dashboards and the post-deploy check. On Kubernetes, the Helm chart probes two other routes. /api/live touches no dependency, so an outage never restarts the engine. /api/ready answers 503 and takes the pod out of the Service when postgres, redis or license is not ok. Each shows timeout, unreachable: <message> or, for the license, invalid. Its checks have 5 seconds in all.

Reference