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 / container-stack-architecture

Container stack architecture

The Frappe container stack is a Compose-defined set of services that runs web requests, real-time events, background jobs, scheduled jobs, and shared site state. It uses one application image across these roles so that each service works from the same Frappe and app code.

Deployment model

The base compose.yaml defines the application roles and their shared sites volume. Other Compose files can add local data services, connect to shared services, or place a proxy in front of the frontend.

The stack does not require one database, Redis layout, or public network shape. A deployment selects a matching set of services and networks around the same application roles. The full pwd.yml stack is one self-contained shape: it adds a MariaDB service, two Redis services, site creation, logs, and one shared bridge network.

References: compose.yaml• L1-18 compose.yaml• L19-103 pwd.yml• L1-19 pwd.yml• L87-109 pwd.yml• L237-245

Service roles

Each service group owns one part of the runtime. The configurator prepares shared connection settings before the services that use them start, while the frontend joins the request path to the internal runtimes.

ServiceRoleSystem responsibility
configuratorShared setupWrites site-wide database, Redis, and real-time settings to the shared site state.
frontendWeb edgeAccepts HTTP traffic and routes application and real-time traffic to the matching internal service.
backendRequest runtimeHandles normal Frappe web requests.
websocketReal-time runtimeMaintains the real-time connection used by connected clients.
queue-short and queue-longBackground workConsume separate queue classes so short work has a separate worker path from long work.
schedulerTime-based workStarts work that Frappe marks for scheduled execution.
Database servicePersistent dataStores site records when the selected topology runs a local database.
Redis servicesShared transient stateProvide separate cache and queue endpoints for Frappe.
create-siteSite bootstrapCreates the first site in the self-contained pwd.yml topology after its dependencies and shared settings are ready.

The application services use the same sites volume. This keeps site configuration and assets visible to the frontend, backend, real-time service, workers, and scheduler.

References: compose.yaml• L9-18 compose.yaml• L19-44 compose.yaml• L46-103 pwd.yml• L21-85 pwd.yml• L111-235

Container relationships

The public request path enters through frontend and then splits between normal HTTP handling and real-time handling. Workers and the scheduler bypass that public path and use the same site state, database, and Redis queue services.

This diagram shows how traffic, work, and shared state move through the stack.

flowchart LR
    Client[Client] --> Frontend[frontend]
    Frontend --> Backend[backend]
    Frontend --> Websocket[websocket]
    Backend --> Database[(Database)]
    Backend --> RedisCache[(Redis cache)]
    Backend --> RedisQueue[(Redis queue)]
    Websocket --> RedisQueue
    QueueShort[queue-short] --> RedisQueue
    QueueLong[queue-long] --> RedisQueue
    Scheduler[scheduler] --> RedisQueue
    QueueShort --> Database
    QueueLong --> Database
    Scheduler --> Database
    Configurator[configurator] --> Sites[(Shared sites volume)]
    Backend --> Sites
    Frontend --> Sites
    Websocket --> Sites
    QueueShort --> Sites
    QueueLong --> Sites
    Scheduler --> Sites

Compose service names provide the internal connection points. The frontend receives backend:8000 for web requests and websocket:9000 for real-time traffic. A topology can change network membership, but it must keep these connections reachable.

References: compose.yaml• L46-85 compose.yaml• L86-103 pwd.yml• L111-136 pwd.yml• L138-235

Configuration inputs

Compose inputs select the application image, locate shared data services, and set the boundary between the frontend and its upstreams. The configurator turns database and Redis inputs into site-wide settings. The nginx entrypoint then turns frontend inputs into the active web server configuration.

Input groupMain inputsEffect
Image and lifecycleCUSTOM_IMAGE, CUSTOM_TAG, ERPNEXT_VERSION, PULL_POLICY, RESTART_POLICYSelects the image and its pull and restart behavior.
Database and RedisDB_HOST, DB_PORT, REDIS_CACHE, REDIS_QUEUESelects the persistent data service and the cache and job endpoints.
Real-time serviceSOCKETIO_PORTSets the port used by the real-time service. The base stack uses 9000.
Web runtimeGUNICORN_THREADS, GUNICORN_WORKERS, GUNICORN_TIMEOUTSets request capacity and request time limits.
Frontend listenerNGINX_LISTEN_PORTSets the port on which the frontend listens. The default is 8080.
Frontend routingBACKEND, SOCKETIO, FRAPPE_SITE_NAME_HEADERSelects internal upstreams and the site name sent to Frappe.
Proxy trust and request limitsTRUST_UPSTREAM_FORWARDED_PROTO, UPSTREAM_REAL_IP_ADDRESS, UPSTREAM_REAL_IP_HEADER, UPSTREAM_REAL_IP_RECURSIVE, PROXY_READ_TIMEOUT, CLIENT_MAX_BODY_SIZEControls forwarded HTTPS trust, client address handling, proxy wait time, and request size.
Public entry pointHTTP_PUBLISH_PORT, HTTPS_PUBLISH_PORT, SITES_RULE, LETSENCRYPT_EMAIL, NGINX_PROXY_HOSTSSelects published ports, host rules, and proxy or certificate inputs in topology variants.

The nginx entrypoint supplies safe defaults when frontend inputs are absent. It checks the forwarded-protocol trust value before it renders the proxy configuration. The template uses that value to preserve HTTPS only when an upstream proxy is trusted.

References: compose.yaml• L1-7 compose.yaml• L37-75 overrides/compose.https.yaml• L1-36 overrides/compose.nginxproxy.yaml• L1-24 resources/…/nginx-entrypoint.sh• L6-71 resources/…/nginx-template.conf• L1-29

Shared state

The sites volume is the main state boundary for the application. It carries site configuration, installed-app information, and assets between containers, which lets a replacement container serve the same sites.

The image entrypoint links the site asset path to the assets included in the image. This gives the shared site tree access to the image's current frontend assets while preserving the common mount used by the application services.

Other state belongs to the selected services. A local database stores business data. A queue Redis may store job data. Cache Redis is transient. The self-contained pwd.yml topology also mounts logs separately, so recovery plans must account for that state when logs matter.

References: compose.yaml• L14-18 compose.yaml• L71-85 compose.yaml• L101-103 resources/…/main-entrypoint.sh• L4-14 pwd.yml• L9-11 pwd.yml• L237-241

Topology variants

Topology variants change the services around the application roles without changing the main request and work paths. Database and Redis choices define where state lives. Proxy choices define how users reach the frontend.

The main choices are:

  • Local database: MariaDB or PostgreSQL runs as a Compose service.
  • Local Redis: Separate cache and queue services provide the endpoints used by Frappe.
  • Direct HTTP: The frontend publishes a port without an outer proxy.
  • Traefik proxy: A Traefik service discovers the labeled frontend and publishes HTTP traffic.
  • nginx-proxy: An nginx-proxy service discovers the frontend through Docker labels and publishes HTTP traffic.
  • HTTPS: A Traefik variant redirects HTTP to HTTPS and stores ACME certificate data in a volume.
  • Multi-bench: The frontend joins a shared public proxy network and a bench network. Runtime services join the bench network and any shared data networks they need.

Read Runtime startup and web serving for startup order and request handling. Read Compose service topology variants for override combinations. Read Networking, TLS, and proxy options for public network and proxy choices.

References: compose.yaml• L19-103 overrides/compose.noproxy.yaml• L1-6 overrides/compose.proxy.yaml• L1-23 overrides/compose.nginxproxy.yaml• L1-24 overrides/compose.https.yaml• L1-36 overrides/compose.multi-bench.yaml• L1-54 pwd.yml• L1-245

Change checklist

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

  • When service names or internal ports change, update frontend upstreams and every topology that routes to those names.
  • When configurator keys change, keep database and Redis service names aligned with the values written to shared site state.
  • When the sites mount or asset path changes, update every application role and the image entrypoint that prepares assets.
  • When frontend inputs or the nginx template contract changes, keep Compose defaults and proxy variants aligned.
  • When forwarded-protocol trust changes, check both the outer proxy scheme and the headers passed to Frappe.
  • When a service moves to an external network, verify that every dependent service can still reach its named endpoint.
  • When site creation inputs change, preserve its wait for shared settings and its dependency readiness checks.

Important failure modes

TriggerConsequenceGuard
configurator cannot completeDependent services lack shared connection settings.Check that database and Redis inputs resolve to reachable services.
Frontend upstream names or networks do not matchHTTP or real-time traffic cannot reach its runtime.Keep BACKEND, SOCKETIO, service names, and network membership aligned.
The sites volume changes identityExisting sites, settings, or assets are not visible to the stack.Preserve the volume across replacement and recovery.
The asset link cannot be createdThe frontend or site cannot use the image's packaged assets.Keep the site mount writable and preserve the image asset path.
A required proxy input is missing or invalidThe frontend cannot render a valid route or listener.Set the inputs required by the selected topology before startup.
Forwarded HTTPS is trusted on the wrong networkFrappe can see the wrong scheme or client address.Enable trust only behind the intended proxy and set its real-IP source.
Site creation starts before shared settings or dependencies are readyThe initial site is not created.Keep the configurator completion and dependency wait conditions.

Key files

FileWhy to read it
compose.yamlDefines the core service roles, shared site state, startup dependency, and frontend connections.
pwd.ymlShows a self-contained deployment with database, Redis, site creation, logs, and one network.
resources/…/main-entrypoint.shShows how image assets become available through the shared site tree.
resources/…/nginx-entrypoint.shShows the frontend input defaults and the boundary where nginx configuration is rendered.
resources/core/nginx/nginx-template.confShows how the frontend separates assets, HTTP requests, protected files, and real-time traffic.
overrides/compose.mariadb.yaml and overrides/compose.postgres.yamlShow the supported local database shapes and their connection contracts.
overrides/compose.redis.yamlShows the split between cache Redis and queue Redis.
overrides/compose.noproxy.yaml, overrides/compose.proxy.yaml, and overrides/compose.nginxproxy.yamlShow direct-port and outer-proxy entry points.
overrides/compose.https.yamlShows the HTTPS boundary and certificate state.
overrides/compose.multi-bench.yaml and overrides/compose.custom-domain.yamlShow shared-network and custom-host variants.

References: compose.yaml• L1-103 resources/…/main-entrypoint.sh• L1-14 resources/…/nginx-entrypoint.sh• L1-71 resources/…/nginx-template.conf• L1-118