Docker stack
The storefront and Magento run on one server as a Docker Compose stack, defined in the magenxcommerce-docker repository. Every image is built in GitHub Actions on Docker Hardened Images (dhi.io), signed, and pulled by the server; the server never builds. How a release gets to the server is in Deployment.
Containers
Section titled “Containers”| Service | What it does |
|---|---|
nginx | The only published port: listens on the server’s private IP for the load balancer. Routes pages to the storefront, /graphql to the GraphQL worker, Magento endpoints to php-fpm, and media to imgproxy. Micro-caches guest HTML and turns Magento’s cache PURGE into a storefront refresh (see Caching). A second, admin-only server on nginx:8081 is never published: it serves the Magento admin, /rabbitmq/ and /logs/ to the private access container. |
magenxcommerce | The Next.js storefront, built from the theme at THEME_VERSION. |
frankenphp | A FrankenPHP worker that answers Magento’s /graphql with Magento already booted, so the storefront’s queries skip the per-request bootstrap. nginx falls back to php-fpm when the worker is down. |
php | php-fpm for the Magento admin, payment webhooks and the other non-GraphQL Magento endpoints. |
cron | Supercronic running bin/magento cron:run every minute. |
magento | A one-off CLI container: bin/magento, Composer and n98-magerun2. Not started with the stack; run it with docker compose run --rm magento …. |
mariadb | MariaDB 11.4. On the backend network only, published on 127.0.0.1 for local tools. |
opensearch | OpenSearch 3 with the ICU and phonetic analysis plugins, and its own TLS certificates for the transport layer. |
cache, session | Two Valkey instances: a volatile cache and a persistent session store (RDB and AOF). |
rabbitmq | RabbitMQ 4 for Magento’s message queues. |
imgproxy | Resizes product images and converts them to WebP or AVIF, read straight from pub/media. |
otel-collector, openobserve | Only with the observability profile. See Observability. |
cloudflared | Only with the cloudflare profile (the default). Cloudflare Tunnel: an outbound connection to Cloudflare that carries the private admin hostname, behind a Cloudflare Access login, to nginx:8081. |
tailscale | Only with the tailscale profile, the alternative to cloudflare. Tailscale Serve on the tailnet: :443 to nginx:8081 and :3306 to MariaDB, with userspace networking. |
Three networks separate them: frontend (web, cache, search, queue), backend (the database) and observability (the collector and OpenObserve; nginx joins it for /logs/). MariaDB is never on frontend. cloudflared joins frontend only; tailscale joins frontend and backend but forwards only the ports in its serve.json and doesn’t route between them. How admins get in, and who decides, is in Security and admin access.
Hardening
Section titled “Hardening”- Hardened base images. Every image starts from a DHI image pinned by tag and SHA256 digest in
.env. The runtime images have no shell tools, no package manager and no curl; build tools stay in the-devbuild stages. - No root, remapped users. The Docker daemon runs with
userns-remap. Containers run as UID65532(the DHI non-root user,DHI_STACK_UID), which is UID165532on the host. Files the stack writes on the host belong to165532. - Read-only containers. Every container runs with a read-only root filesystem, all capabilities dropped and
no-new-privileges. Writable paths are named volumes andtmpfsmounts. - Read-only code. php, nginx, cron and the GraphQL worker mount the Magento code read-only. Only the
magentoCLI container can write it. - Secrets out of the images. Passwords are in
.env.secretson the server, never in git. The few values that must be baked in at build time (for example the OpenSearch admin password hash, the admin path and the npm token for the theme) come in as build secrets, not build arguments. - No public admin. The Magento admin, RabbitMQ management and OpenObserve are on the admin-only nginx server, reached through Cloudflare Tunnel or Tailscale after an identity login. Neither container publishes a host port. The admin path on the shop domain answers 403. See Security and admin access.
- Signed images with SBOMs. Every image digest is signed with cosign and carries a signed SPDX SBOM. The server checks the signatures before it pulls.
Folders
Section titled “Folders”/opt/<brand>/├── docker/ the stack: compose files, .env, .env.secrets, scripts├── stack/ deployed stack releases (with deputy, see Deployment)│ ├── releases/vX.Y.Z/│ └── current -> releases/vX.Y.Z└── magento/ ├── releases/YYYYMMDDHHMM/ Magento code, one folder per release ├── public/current -> ../releases/YYYYMMDDHHMM └── shared/ kept across releases ├── var/ logs, tmp, reports └── pub/media/Magento code follows the same release-and-symlink pattern as the stack, so a deploy switches current and a rollback switches it back. Databases, search indexes, queues and caches live in named Docker volumes and survive docker compose down.
Settings
Section titled “Settings”| File | Holds | In git |
|---|---|---|
.env | Shop settings: brand, domain, host IP and port, image digests, versions, memory sizes, COMPOSE_PROFILES, the TS_* and TUNNEL_* settings | Yes |
.env.secrets | Passwords for every service, Magento’s CRYPT_KEY, Composer credentials, the random admin path, TUNNEL_TOKEN or TS_AUTHKEY | Never |
Compose reads both: docker.sh sets COMPOSE_ENV_FILES=.env,.env.secrets in the shell profile. A command run without the secrets stops with required variable … is missing a value: missing, load .env.secrets.
Health checks and logs
Section titled “Health checks and logs”Every long-running container has a health check, and the stack only counts as up when all of them pass. They use what each runtime image already has, without curl: bash /dev/tcp for OpenSearch (/_plugins/_security/health, which needs no login), valkey-cli, rabbitmq-diagnostics, php-fpm -t, nginx -t, and a real storeConfig query for the GraphQL worker. That last one only passes once Magento is installed.
Every container logs to the host’s syslog, tagged [ <container name> ]:
tail -f /var/log/syslog