Skip to content

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.

HTTP, private IP/graphqlCloudflare Accessor tailnet:8081 private admin:3306, Tailscale only

Load balancer
(TLS)

nginx

magenxcommerce
(Next.js storefront)

frankenphp
(GraphQL worker)

php
(php-fpm)

imgproxy

cache
(Valkey)

session
(Valkey)

rabbitmq

opensearch

mariadb

cron

Admins

cloudflared or tailscale
(outbound only)

backend networkfrontend network
ServiceWhat it does
nginxThe 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.
magenxcommerceThe Next.js storefront, built from the theme at THEME_VERSION.
frankenphpA 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.
phpphp-fpm for the Magento admin, payment webhooks and the other non-GraphQL Magento endpoints.
cronSupercronic running bin/magento cron:run every minute.
magentoA one-off CLI container: bin/magento, Composer and n98-magerun2. Not started with the stack; run it with docker compose run --rm magento ….
mariadbMariaDB 11.4. On the backend network only, published on 127.0.0.1 for local tools.
opensearchOpenSearch 3 with the ICU and phonetic analysis plugins, and its own TLS certificates for the transport layer.
cache, sessionTwo Valkey instances: a volatile cache and a persistent session store (RDB and AOF).
rabbitmqRabbitMQ 4 for Magento’s message queues.
imgproxyResizes product images and converts them to WebP or AVIF, read straight from pub/media.
otel-collector, openobserveOnly with the observability profile. See Observability.
cloudflaredOnly 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.
tailscaleOnly 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.

  • 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 -dev build stages.
  • No root, remapped users. The Docker daemon runs with userns-remap. Containers run as UID 65532 (the DHI non-root user, DHI_STACK_UID), which is UID 165532 on the host. Files the stack writes on the host belong to 165532.
  • Read-only containers. Every container runs with a read-only root filesystem, all capabilities dropped and no-new-privileges. Writable paths are named volumes and tmpfs mounts.
  • Read-only code. php, nginx, cron and the GraphQL worker mount the Magento code read-only. Only the magento CLI container can write it.
  • Secrets out of the images. Passwords are in .env.secrets on 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.
/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.

FileHoldsIn git
.envShop settings: brand, domain, host IP and port, image digests, versions, memory sizes, COMPOSE_PROFILES, the TS_* and TUNNEL_* settingsYes
.env.secretsPasswords for every service, Magento’s CRYPT_KEY, Composer credentials, the random admin path, TUNNEL_TOKEN or TS_AUTHKEYNever

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.

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> ]:

Terminal window
tail -f /var/log/syslog