Development environment provisioning
The development environment provisions a local Frappe bench with its database and background services. It combines Docker Compose services, a bench installer, example app selection, a VS Code Dev Container, and editor settings so that a developer can create and debug a site with a small set of shared defaults.
Provisioning model
The setup separates the local service system from the bench and site created inside it. Docker provides the long-running services. The installer creates the bench and connects it to those services. VS Code gives the developer a consistent way to enter the workspace and run the application.
Local service system
The local service system supplies the process dependencies that a Frappe bench expects. The frappe service is the development shell and workspace. MariaDB stores site data by default, while separate Redis services support cache and queued work. PostgreSQL, Mailpit, and a Cypress UI tester are optional examples for teams that need them.
The services share a Compose network. The bench therefore reaches them by service name instead of by localhost. Persistent database data uses a named volume, while the repository is mounted into the development service so that source changes remain on the host.
This diagram shows how the host, development container, and supporting services work together.
flowchart LR
Host[Developer host] -->|opens workspace| VSCode[VS Code Dev Container]
VSCode -->|runs bench and site| Frappe[Frappe development service]
Frappe -->|site data| MariaDB[(MariaDB)]
Frappe -->|cache| RedisCache[(Redis cache)]
Frappe -->|jobs and realtime| RedisQueue[(Redis queue)]
Frappe -->|optional mail or database tools| Optional[Optional services]
References: devcontainer-example/docker-compose.yml• L1-13 devcontainer-example/docker-compose.yml• L37-55 devcontainer-example/docker-compose.yml• L83-86
Provisioning assets
The assets form a small set of examples that developers copy into active workspace locations. The Compose example defines the service system. The app manifest defines the applications that the installer adds to a new bench. The example environment file provides shared local input defaults. The VS Code example defines launch, task, and workspace behavior for development. The root editor settings keep formatting consistent across the repository.
Use the examples as a starting point rather than as a second configuration layer. The active .devcontainer and development/.vscode directories are local workspace choices and can be changed for a project without changing the shared examples. For the wider role of environment inputs, see Configuration and environment inputs.
References: devcontainer-example/devcontainer.json• L1-3 development/apps-example.json• L1-6 example.env• L1-99 development/…/launch.json• L1-77 development/…/settings.json• L1-20 .editorconfig• L1-19
Application configuration
Application configuration controls which Frappe framework and applications the local bench uses. The default app manifest selects ERPNext from its version 16 branch, while installer arguments allow a developer or team to select another manifest, repository, branch, runtime version, site name, or database type.
Application selection
The app manifest is a shared input for a new bench. Each listed application is fetched during bench creation and is then installed on the site created by the installer. Teams can copy the example manifest and replace its entries when a client or project needs a different set of applications.
Application versions must remain compatible with the selected Frappe branch. A change to the manifest can therefore change both the code available in the bench and the applications enabled on the site.
References: development/apps-example.json• L1-6 development/installer.py• L36-45 development/installer.py• L119-146 development/installer.py• L243-247
Installer inputs
The installer turns the selected inputs into two related actions: it initializes a bench when the bench directory does not exist, then creates a site in that bench. It can select the app manifest, bench and site names, Frappe repository and branch, Python and Node versions, administrator password, database type, and command output level. The database choice controls which Compose service the site uses.
The default site name ends in .localhost so that local host routing can map it to the development server. MariaDB is the default database. The example Compose configuration supplies the matching local database and Redis service names.
For the full option contract and database-specific setup, see Development installer and app configuration.
References: development/installer.py• L36-116 development/installer.py• L119-195 development/installer.py• L211-247
Installer workflow
The installer provides a repeatable path from an empty development directory to a usable site. It preserves an existing bench and limits the second run to site creation, which makes the bench directory the boundary between environment creation and site creation.
Bench and site lifecycle
When a bench is new, the installer initializes it with Redis configuration generation disabled. It then links the bench to the Compose Redis services, sets the selected database type, and enables developer mode. The site step selects the database host that matches the database choice, creates the site with the configured administrator password, and installs every application present beside the Frappe framework.
The current installer maps mariadb to the mariadb service and maps other database choices to the postgresql service. The selected value must therefore match an enabled Compose service. The resulting site is ready for local development rather than production use. Its local address depends on the .localhost site name and host routing.
This sequence shows the relationship between the installer inputs, the bench, and the site.
sequenceDiagram
participant D as Developer
participant I as Installer
participant B as Bench
participant S as Compose services
participant T as Site
D->>I: Select manifest and environment options
I->>B: Initialize bench when absent
B->>S: Use database and Redis service names
I->>T: Create site with selected database
I->>T: Install fetched applications
T-->>D: Local developer site
References: development/installer.py• L29-34 development/installer.py• L119-205 development/installer.py• L211-252
Devcontainer workspace
The Dev Container example makes the development container the main place where bench commands run. VS Code opens the repository through the frappe service, uses /workspace/development as the workspace, and forwards the web, realtime, and asset-watcher ports to the host.
Workspace access
The container runs as the frappe user and stays alive as a developer workspace. The repository is mounted into /workspace, so benches created under development are available to the host while their tools run in the container. The workspace setup also installs pre-commit after creation and can mount host SSH credentials when private app access is needed.
Database selection is a Compose choice. MariaDB is enabled by default. PostgreSQL is an alternative service that must be enabled when it is needed, with the matching database choice passed to the installer.
For the complete container workflow, including service choice and container use, see Devcontainer workspace.
References: devcontainer-example/devcontainer.json• L22-23 devcontainer-example/devcontainer.json• L67-75 devcontainer-example/docker-compose.yml• L8-20 devcontainer-example/docker-compose.yml• L43-55
Development ports
The Dev Container forwards Frappe web ports in the 8000 range, realtime ports in the 9000 range, and the asset watcher port 6787. These ports are forwarded by VS Code rather than published by the example Compose file, so a terminal-only workflow needs its own host port mappings.
The forwarded port labels help a developer identify the web, realtime, and asset-watcher endpoints. Other ports are ignored by default to avoid exposing unrelated services.
References: devcontainer-example/devcontainer.json• L3-20 devcontainer-example/docker-compose.yml• L55-58
Developer-editor integration
The editor assets connect the running bench to common development actions. They select the bench Python environment, reduce file watcher noise from generated content, start the web and worker processes under the Python debugger, and clean up processes that do not stop cleanly.
Debug sessions
The launch configuration supports the web process, short/default/long workers, and the group of realtime, watcher, scheduler, and worker processes. A compound launch joins the web process with the supporting process group. This lets a developer debug a request path while the rest of the local development processes run beside it.
The cleanup task sends an interrupt to the bench and Socket.IO processes after the grouped debug session stops. This keeps the next debug session from inheriting stale processes.
References: development/…/launch.json• L7-24 development/…/launch.json• L25-68 development/…/launch.json• L70-75 development/…/tasks.json• L4-21
Editor workspace
The workspace settings point Python tools at the bench virtual environment and exclude dependencies, environment files, configuration, and build artifacts from file watching. The Dev Container recommends the remote container extension and installs the language, database, formatting, and linting tools that support the example workspace.
The repository editor rules set UTF-8, Unix line endings, spaces, final newlines, and language-specific indentation. Markdown keeps trailing whitespace because it can carry formatting meaning.
References: development/…/settings.json• L1-20 devcontainer-example/devcontainer.json• L23-46 .vscode/extensions.json• L1-9 .editorconfig• L4-19
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the installer database host mapping aligned with the Compose service selected by
db_type. - Keep the installer Redis service names aligned with the Compose service names.
- Keep the app manifest branches compatible with the selected Frappe branch and with each other.
- Keep forwarded port ranges aligned with the ports used by the launch configurations and the chosen site URL.
- Keep the Dev Container workspace path aligned with the bench path used by Python and debugger settings.
- If a database or optional service changes, update both the Compose service choice and the installer database selection.
- If private apps become part of the default workflow, review the SSH mount and container credential boundary before changing the examples.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The bench already exists when the repository or app selection changes | The installer skips bench initialization, so the existing bench keeps its prior applications and runtime choice | Use a new bench name or update the existing bench deliberately before creating the site |
| A Compose service name differs from the bench host setting | The site cannot reach MariaDB or Redis from the development container | Treat service names and installer host settings as one contract |
| The selected database does not match the enabled Compose service | Site creation fails or targets a service that is not running | Enable the selected database service and pass the same database type to the installer |
| A site name does not use the local host pattern or host routing is missing | The browser cannot resolve the local site as expected | Use a .localhost site name and add local host routing when the platform needs it |
| A terminal-only workflow uses the Dev Container example without publishing ports | The bench runs but the host browser cannot reach it | Add loopback port mappings and bind the development server to the container interface |
| The grouped debugger stops without its cleanup task | Honcho, Socket.IO, or bench processes can remain active and interfere with later sessions | Keep the post-debug cleanup task attached to the compound launch |
Key files
| File | Why to read it |
|---|---|
| devcontainer-example/docker-compose.yml | Defines the local database, Redis services, development service, optional services, and persistent data boundary |
| devcontainer-example/devcontainer.json | Defines how VS Code enters the development service, forwards ports, installs editor tools, and selects the workspace |
| development/installer.py | Defines the bench-to-site provisioning flow, database service mapping, and its main developer inputs |
| development/apps-example.json | Shows the default application set and version branch used by a new bench |
| example.env | Provides example environment inputs for local setup |
| development/…/launch.json | Shows the supported web, worker, and grouped debug flows |
| development/…/settings.json | Shows the Python environment and file watcher defaults for the bench workspace |
| development/…/tasks.json | Shows the process cleanup action used after grouped debugging |
.editorconfig | Defines the repository-wide editor format rules |
| .vscode/extensions.json | Recommends the VS Code extension needed to open the workspace in a container |