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.
| Path | Use it when | Where |
|---|---|---|
| Docker Compose | one server, or a trial | apps/engine/docker-compose.yml |
| Kubernetes (Helm) | you run Kubernetes | apps/engine/helm/medhook-engine |
| Terraform | you want the cloud resources built for you | apps/engine/terraform/ |
| Air-gapped bundle | the host has no internet access | apps/engine/scripts/bundle-airgap.sh |
| GKE release bundle | production in your own Google Cloud project | see 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.
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.shPut 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.
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-namespaceTo 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.
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 themThe 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.
| Folder | Runs the engine on |
|---|---|
aws | AWS Fargate (ECS), RDS and ElastiCache |
azure | Azure Container Instances |
gcp | Google Cloud Run |
gke | Google Kubernetes Engine, with Cloud SQL, Cloud VPN and Cloud Monitoring alerts. The production path: see Install |
multi-region | A warm standby region on AWS or Google Cloud |
cd apps/engine/terraform/aws
cp terraform.tfvars.example terraform.tfvars
terraform init
terraform applyAir-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
curl https://engine.example.test/api/healthreturnshealthy, withchecks.sandboxset toisolated-vm.- Create the first admin with
create-engine-user. - Create API clients for your integrations. Do not use root-secret tokens.
- Set
ENGINE_PUBLIC_URLandALLOWED_ORIGINSto the engine's real address. - Check
CLIENT_IP_SOURCEmatches what is in front of the engine:gclbbehind Google's HTTP(S) load balancer (GKE Ingress),last-hopbehind AWS ALB, ingress-nginx, Caddy or Cloud Run,nonewhen 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. - 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 HTTP503: PostgreSQL or Redis isdownortimeout. The engine can't run workflows. The Compose health check fails on it.degraded, with HTTP200: 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 HTTP200: every check is in its healthy state.
| Check | Healthy | Not healthy, and what it makes the status | What to check |
|---|---|---|---|
postgres | up, with latency | down or timeout: unhealthy | DATABASE_URL, that the database accepts connections from the engine, and its connection limit. |
redis | up, with latency | down or timeout: unhealthy | REDIS_URL, and that Redis is running and reachable. |
medplum | up, with latency | down or timeout: degraded | The engine calls $MEDPLUM_BASE_URL/healthcheck (default http://medplum-server:8103). Start Medplum, or point the variable at it. |
mllp | up, with latency | down or timeout: degraded | The 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. |
license | valid | pending, grace or invalid: degraded | pending: 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. |
memory | ok | high: degraded | The 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. |
sandbox | isolated-vm | unsafe-vm or unavailable: degraded | unavailable: 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. |
executionArchive | ok or off | misconfigured, 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.