Introducing a new way to review your PRs.

Read the announcement

frappe / frappe_docker

Docker environment for developing, deploying, and running Frappe applications (ERPNext and custom apps) in production and development

View on GitHub

15 documents · Updated Nov 23, 2026

docs / compose-service-topology-variants

Compose service topology variants

Compose overrides select the supporting services and network shape around the core Frappe and ERPNext runtime. They let one stack use MariaDB or PostgreSQL, split Redis roles, run site migrations or backups, bind site data to a host path, and connect several independent benches to shared infrastructure without changing the base application services.

This page extends Container stack architecture with the main service combinations. For the surrounding startup and request path, see Runtime startup and web serving and Networking, TLS, and proxy options.

Override composition

The base compose.yaml describes the application processes but leaves infrastructure choices open. Compose merges one or more override files with that base. The deployment topology is therefore the result of the selected set rather than any one file.

References: compose.yaml• L19-100 docs/…/05-overrides.md• L5-9

The main relationship is between the configurator and the services it prepares. Database and Redis overrides provide service names and endpoints. The configurator writes those endpoints into the shared bench state before the backend, websocket, workers, and scheduler use it.

References: compose.yaml• L9-44 overrides/compose.postgres.yaml• L1-20 overrides/compose.mariadb.yaml• L1-27 overrides/compose.redis.yaml• L1-21

This diagram shows how the selected infrastructure becomes the shared runtime used by the application services.

flowchart LR
  Base[Base application services] --> Config[Configurator]
  DB[Database variant] --> Config
  Redis[Redis variant] --> Config
  Config --> Runtime[Backend, frontend, websocket, workers, scheduler]
  Tasks[Optional migration or backup services] --> Runtime
  Network[Optional shared networks and proxy] --> Runtime

Database variants

Database overrides add the persistent database that the base stack expects. Each variant gives the configurator a database host and port, waits for database health, and stores database data in a named volume.

References: overrides/compose.mariadb.yaml• L1-31 overrides/compose.postgres.yaml• L1-23

VariantTopology roleMain boundary
MariaDBRuns a database inside the application stack.The stack reaches it as db on port 3306.
PostgreSQLReplaces MariaDB with PostgreSQL.The stack reaches it as db on port 5432.
Shared MariaDBRuns MariaDB as a separate shared service for more than one application stack.Bench stacks reach mariadb-database through the mariadb-network.
MariaDB secretsChanges the MariaDB password source from an environment value to a Docker secret file.The secret file path must be supplied through DB_PASSWORD_SECRETS_FILE.

The shared MariaDB shape separates database lifecycle from each bench lifecycle. A bench then joins the shared network and points its database settings at the shared service. The secrets variant applies to the in-stack db service and is therefore a companion to the normal MariaDB shape rather than a new database engine.

References: overrides/compose.mariadb-shared.yaml• L1-31 overrides/compose.mariadb-secrets.yaml• L1-11 docs/…/07-single-server-example.md• L106-134

Site data storage

The sites volume carries the site files and local assets used by the application services. The default topology lets Docker manage this volume, while the bind-mount override makes the same data available at a chosen host path.

References: compose.yaml• L14-18 compose.yaml• L54-70 compose.yaml• L99-101 overrides/compose.bind-mount-sites.yaml• L1-15

The bind-mount shape requires SITES_DATA_LOCATION to name an existing absolute directory. The directory must be writable by the frappe user in the image. This changes where site data is stored, but it does not change the application services or their shared volume name.

References: overrides/compose.bind-mount-sites.yaml• L1-15

Redis arrangements

The Redis override creates two logical Redis roles. The cache service is disposable. The queue service keeps queue and publish/subscribe data in a volume. This split lets Frappe treat short-lived cache data separately from background-job coordination.

References: overrides/compose.redis.yaml• L1-21 compose.yaml• L27-35

The configurator publishes the two endpoints as redis_cache and redis_queue settings. The legacy redis_socketio setting follows the queue endpoint. Real-time events therefore use the same durable Redis role as job queues.

References: compose.yaml• L27-35

Migration service

The migrator override adds a one-purpose service that prepares every existing site for a new application image or app version. It waits for the configurator, skips cleanly when migration is disabled or when no sites exist, and exits after the all-site migration completes.

References: overrides/compose.migrator.yaml• L13-44

Migration is a deployment task rather than a permanent runtime process. Set MIGRATE_SITES to false when the stack must start without this automatic step; its default is true. The migrator and the normal runtime services use the same sites volume. The base runtime services wait on the configurator rather than on the migrator.

References: overrides/compose.migrator.yaml• L18-44 compose.yaml• L9-18 docs/…/06-automated-builds-and-deployment.md• L132-147

This sequence shows how site preparation fits between configuration and normal runtime use.

sequenceDiagram
  participant C as Configurator
  participant M as Migrator
  participant R as Runtime services
  C->>M: Complete shared bench configuration
  M->>M: Check migration intent and site presence
  alt Migration enabled and sites exist
    M->>M: Migrate all sites
    M-->>R: Leave migrated sites for runtime services
  else Migration skipped
    M-->>R: Leave sites unchanged
  end

Multi-bench topology

The multi-bench override allows several Compose projects to share central edge and database infrastructure while keeping each bench’s application traffic isolated. Each project gets its own bench network. The frontend also joins the public Traefik network. Application services that need database access join the shared MariaDB network.

References: overrides/compose.multi-bench.yaml• L1-52

The frontend is the public boundary for each bench. Its Traefik labels use ROUTER as the project-specific service and router name. SITES_RULE maps one or more host names to that bench. The custom-domain setup must use BENCH_NETWORK with the same network name as this bench.

References: overrides/compose.multi-bench.yaml• L1-16 docs/…/07-single-server-example.md• L138-179 docs/…/07-single-server-example.md• L197-249

The topology has three network roles:

  • traefik-public carries traffic between the central proxy and each bench frontend.
  • mariadb-network carries database traffic to the shared MariaDB service.
  • The per-bench network carries traffic among the services belonging to one bench.

The SSL companion adds HTTPS routing and certificate resolution to the existing per-bench Traefik labels. It does not create a second application path.

References: overrides/compose.multi-bench.yaml• L3-52 overrides/compose.multi-bench-ssl.yaml• L1-14 docs/…/01-tls-ssl-setup.md• L18-26

Backup scheduling

The backup override turns the scheduler container into the execution point for recurring site backups. An Ofelia daemon watches Docker labels and runs bench --site all backup as the frappe user at the configured interval.

References: overrides/compose.backup-cron.yaml• L1-15

The default schedule runs every six hours. BACKUP_CRONSTRING changes that schedule. Backup output remains part of the bench’s normal site data and storage model. The override adds scheduling only. It does not define an external backup store or retention policy.

References: overrides/compose.backup-cron.yaml• L10-15

Custom-domain attachment

The custom-domain override adds a small Caddy proxy beside an existing bench rather than moving the bench’s own frontend. It joins the public proxy network and a selected bench network. It then forwards a new host rule to that bench while setting the target site through the Host request header.

References: overrides/compose.custom-domain.yaml• L1-29

This shape is useful when a new domain must reach an existing site or when a local network needs a separate entry point. ROUTER and SITES_RULE identify the new route. BASE_SITE selects the site that receives the request. BENCH_NETWORK selects the existing bench network. The SSL companion changes the route to use HTTP and HTTPS with the shared certificate resolver.

References: overrides/compose.custom-domain.yaml• L11-29 overrides/compose.custom-domain-ssl.yaml• L1-5 docs/…/07-single-server-example.md• L251-289

Edge proxy variants

Proxy overrides choose how traffic reaches the frontend. They are a separate topology concern from database and worker selection. Their network and route contracts must still match the chosen bench shape.

References: overrides/compose.noproxy.yaml• L1-6 overrides/compose.proxy.yaml• L1-23 overrides/compose.https.yaml• L1-36 overrides/compose.nginxproxy.yaml• L1-24

VariantRuntime shapeUse
No proxyPublishes the frontend directly on port 8080 or a chosen host port.Local or LAN access where another proxy is not needed.
Single-stack TraefikAdds a Traefik proxy to the same Compose project.One stack with label-based HTTP routing.
Single-stack HTTPSAdds HTTPS termination and ACME certificate handling to the stack.One stack with HTTP-to-HTTPS routing.
Central TraefikRuns Traefik in a separate project on traefik-public.Several benches with one shared public edge.
nginx-proxyUses frontend host environment values to route to the frontend.Simple host-based routing.
nginx-proxy with ACME companionAdds a certificate service and HTTPS port to nginx-proxy.Automatic certificates with host-based routing.

The single-stack HTTP model uses compose.proxy.yaml and routes host names to the frontend through Traefik. The HTTPS model uses compose.https.yaml to redirect HTTP to HTTPS and obtain certificates through an ACME HTTP challenge. It stores certificate state in the cert-data volume. The central Traefik model uses compose.traefik.yaml on the traefik-public network and protects its dashboard with basic authentication. The nginx-proxy model uses NGINX_PROXY_HOSTS and VIRTUAL_PORT values to publish the frontend. It can be paired with its ACME companion for HTTPS. These pairings are topology contracts rather than interchangeable labels.

References: overrides/compose.proxy.yaml• L1-23 overrides/compose.https.yaml• L1-36 overrides/compose.traefik.yaml• L1-46 overrides/compose.nginxproxy.yaml• L1-24 overrides/compose.nginxproxy-ssl.yaml• L1-28 docs/…/01-tls-ssl-setup.md• L9-45

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the database host and port in the configurator aligned with the service name and listener exposed by the selected database override.
  • Keep shared-network names aligned between the central database or proxy project and every bench that joins them.
  • Keep ROUTER, SITES_RULE, and per-bench network names unique when adding another bench.
  • Keep BENCH_NETWORK equal to the external network name created for the target bench when adding a custom domain.
  • Keep BASE_SITE aligned with the site that must receive custom-domain requests.
  • Keep the proxy choice aligned with its required frontend labels, published ports, and network name.
  • Keep the HTTPS certificate resolver, email, published ports, and certificate volume aligned when changing the HTTPS topology.
  • Keep the SSL companion paired with the proxy topology whose shared service, labels, and certificate volume it extends.
  • Keep migration ordering tied to configurator completion and the shared sites volume when changing startup dependencies.
  • Keep backup schedule changes separate from backup storage and retention design because the cron override supplies only execution timing.
  • Keep SITES_DATA_LOCATION set to an existing writable host directory when replacing Docker-managed site storage with a bind mount.

Important failure modes

TriggerConsequenceGuard
A bench uses the wrong database host or port for its selected override.The configurator writes unusable database settings and the runtime cannot connect.Match DB_HOST and DB_PORT to the selected database topology.
A multi-bench stack does not join mariadb-network or its own bench network.The bench loses database access or its internal and edge paths cannot connect.Use the shared network names from the central services and keep ROUTER-based bench networks distinct.
SITES_RULE or ROUTER is missing in a multi-bench or custom-domain deployment.Traefik cannot create the intended route.Set both values before rendering the merged Compose configuration.
A custom-domain proxy joins the wrong bench network or sends the wrong Host value.The route reaches the wrong bench or no site accepts the request.Match BENCH_NETWORK to the target bench and BASE_SITE to the target site.
The HTTPS override lacks a Let's Encrypt email or persistent certificate volume.Certificate setup fails or certificate state is lost when the proxy is replaced.Set LETSENCRYPT_EMAIL and retain cert-data.
A central proxy and a bench use different traefik-public network names.The proxy cannot discover or reach the bench frontend.Use the same external public network in both Compose projects.
An SSL companion is used without its base proxy override.The companion lacks the proxy service or shared volumes it must extend.Include the base proxy file before the SSL file.
Automatic migration runs before site data is available or is disabled during a schema change.Sites can remain on an old schema or the migration step has nothing to process.Start it after configurator completion and set migration intent to match the release plan.
Backup scheduling is enabled without a usable storage and retention plan.Backups may run but may not provide recoverable history.Treat the cron override as a trigger only and validate where site backups are retained.
SITES_DATA_LOCATION is unset, absent, or not writable by the image user.Compose cannot mount the site data or runtime services cannot write site files.Create the absolute directory first and grant it the required frappe ownership and access.

Key files

FileWhy to read it
compose.yamlDefines the base application lifecycle and the configurator contract that overrides extend.
overrides/compose.mariadb.yamlShows the in-stack MariaDB topology.
overrides/compose.postgres.yamlShows the PostgreSQL alternative and its configurator boundary.
overrides/compose.mariadb-shared.yamlShows how database lifecycle moves into a shared project and network.
overrides/compose.mariadb-secrets.yamlShows the secret-backed MariaDB password option.
overrides/compose.bind-mount-sites.yamlShows how site data moves from a Docker-managed volume to a host directory.
overrides/compose.redis.yamlShows the cache and queue Redis split.
overrides/compose.migrator.yamlShows the optional migration gate for automated deployments.
overrides/compose.multi-bench.yamlShows per-bench isolation with shared edge and database networks.
overrides/compose.multi-bench-ssl.yamlShows how HTTPS is added to each multi-bench route.
overrides/compose.backup-cron.yamlShows the recurring all-site backup trigger.
overrides/compose.custom-domain.yamlShows how a new domain attaches to an existing bench.
overrides/compose.noproxy.yamlShows direct frontend publishing without an edge proxy.
overrides/compose.proxy.yamlShows the single-stack HTTP Traefik route.
overrides/compose.https.yamlShows single-stack HTTPS termination and certificate handling.
overrides/compose.traefik.yamlShows the central Traefik project used by multi-bench deployments.
overrides/compose.nginxproxy.yamlShows the environment-driven nginx-proxy alternative.
docs/…/07-single-server-example.mdConnects the database, multi-bench, and custom-domain variants into one deployment model.
docs/…/01-tls-ssl-setup.mdCompares the supported public edge and TLS topologies.