Container runtime topologies
Container images provide two runtime shapes for BunkerWeb. The split shape runs the web gateway, scheduler, and optional control services in separate containers. The all-in-one shape places these services and selected local support services in one container, with Supervisor managing their shared lifetime and output. See Distribution and deployment for the wider deployment model and Linux packaging for the package-based runtime shape.
Container shapes
The split shape gives each service its own container boundary. The all-in-one image gives a small deployment one container boundary while keeping the same service roles. Both shapes use persistent data and can connect to an external database or service network.
| Shape | Main roles | Service boundary |
|---|---|---|
| Split containers | BunkerWeb gateway, scheduler, and optional API, UI, or Autoconf services | One entrypoint and health check per service container |
| All-in-one container | Gateway, scheduler, optional API, UI, Autoconf, Redis, CrowdSec, log stream, and log rotation | One Supervisor process manages the enabled roles |
The split development topology connects the gateway and scheduler through a shared network. The scheduler updates the gateway through its service name and shares /data for state. The all-in-one development topology keeps the gateway and scheduler together but still uses an external MariaDB service when configured.
References: misc/…/docker-compose.yml• L1-73 misc/…/docker-compose.all-in-one.yml• L1-84
Service entrypoints
Each service image starts through an entrypoint that prepares shared state, reads container secrets, records the deployment mode, and then starts its main process. The entrypoint also catches stop signals so the child process can close before the container exits.
| Service | Runtime role | Default exposed port |
|---|---|---|
| BunkerWeb | Receives protected HTTP and stream traffic through NGINX | 8080, 8443 TCP/UDP |
| Scheduler | Generates configuration and runs scheduled jobs | None |
| API | Provides the control API | 8888 |
| UI | Provides the web control interface | 7000 |
| Autoconf | Watches its integration and applies automatic configuration work | None |
The gateway entrypoint also protects the running configuration during NGINX reloads and configuration installs. On restart, it can keep a valid current configuration while the scheduler prepares a newer one. If that preserved configuration cannot start, it falls back to a loading configuration so the scheduler can restore the latest state. The API and UI run their web servers, while Autoconf runs its background job process. These roles are separate in the split shape and become Supervisor child programs in the all-in-one shape.
References: src/…/entrypoint.sh• L15-45 src/…/entrypoint.sh• L47-198 src/…/entrypoint.sh• L260-377 src/…/entrypoint.sh• L42-79 src/…/entrypoint.sh• L42-163 src/…/entrypoint.sh• L64-124 src/…/entrypoint.sh• L25-55
All-in-one supervision
The all-in-one entrypoint prepares persistent directories and optional local services before it starts Supervisor. Supervisor stays in the foreground and owns the gateway, scheduler, API, UI, Autoconf, Redis, CrowdSec, log stream, and log rotation processes that are enabled by the runtime settings.
The startup order expresses broad dependency intent rather than a full service readiness graph. The gateway has the highest start priority. Redis and CrowdSec start before the scheduler and API when they are local and enabled. The UI and scheduler start after the gateway. The entrypoint changes service start and restart behavior from the selected environment, so disabled services do not start and optional long-running services can restart.
flowchart TD
A[Container start] --> B[All-in-one entrypoint]
B --> C[Prepare /data and local service state]
C --> D[Select enabled services]
D --> E[Supervisor]
E --> F[BunkerWeb gateway]
E --> G[Redis]
E --> H[CrowdSec]
E --> I[Log stream and rotation]
E --> J[Scheduler]
E --> K[API]
E --> L[UI]
E --> M[Autoconf]
J --> F
K --> F
L --> F
Supervisor stops the child group when the container receives a termination signal. A reload signal updates the Supervisor program set only after any active configuration install releases its generation lock. This keeps a running service set from being stopped in the middle of a generated configuration install. References: src/…/entrypoint.sh• L6-26, src/…/entrypoint.sh• L57-169, src/…/entrypoint.sh• L250-293, src/…/entrypoint.sh• L431-522, src/all-in-one/supervisord.conf#L1-L29, src/…/bunkerweb.ini• L1-21, src/…/redis.ini• L1-20, src/…/crowdsec.ini• L1-20, src/…/scheduler.ini• L1-22, src/…/api.ini• L1-22, src/…/ui.ini• L1-22, src/…/autoconf.ini• L1-22
Bundled service topology
The all-in-one image bundles Redis and CrowdSec only when their settings point to local services. Local Redis stores its data under the persistent /data tree and uses a runtime configuration built from the image configuration plus unset environment-driven options. Local CrowdSec uses the persistent data tree and exposes its local API to BunkerWeb.
An external Redis or CrowdSec endpoint removes that service from the all-in-one process group. This lets the image keep the application role while an operator owns the support service lifecycle elsewhere. The image also bundles the scheduler, API, UI, and Autoconf binaries, but each role remains independently enabled through its service mode setting. The image declares /data as persistent storage and exposes the gateway ports plus the optional UI and API ports. A container health check reports the all-in-one runtime state.
References: src/…/Dockerfile• L197-249 src/…/Dockerfile• L252-268 src/…/entrypoint.sh• L28-45 src/…/entrypoint.sh• L295-429 src/…/entrypoint.sh• L431-507 src/…/redis.ini• L1-20 src/…/crowdsec.ini• L1-20
Log topology
Container logs use the container runtime as the main output sink. Supervisor sends child output to PID 1's standard output and error streams. The all-in-one wrapper adds a service label, hides selected service streams when requested, and removes control characters before output reaches docker logs or an equivalent runtime view.
NGINX and ModSecurity write to files in the all-in-one image because the log stream process must follow those files and add labels. The stream process forwards access logs to standard output and error logs plus ModSecurity audit logs to standard error. Log rotation then manages those real files in place. In the split gateway image, the corresponding files point directly to PID 1's output streams, so the container runtime owns retention.
| Log source | All-in-one path | Output route |
|---|---|---|
| Service process | Child standard output and error | Supervisor to container output |
| NGINX access log | var/…/access.log | Log stream to standard output |
| NGINX error log | var/…/error.log | Log stream to standard error |
| ModSecurity audit log | var/…/modsec_audit.log | Log stream to standard error |
The HIDE_SERVICE_LOGS value applies to named service streams and to the NGINX, ModSecurity, and access-log streams handled by the log streamer. The service wrapper does not write service output to files. It prefixes visible lines and removes C0 control characters except tabs and newlines, plus the delete character, before forwarding them. The split image does not use this all-in-one file-following path.
References: src/…/service-log-wrapper.sh• L1-33 src/…/logging-utils.sh• L1-35 src/…/logstream.sh• L9-50 src/…/logstream.ini• L1-19 src/…/logrotate.ini• L1-32 src/…/Dockerfile• L109-131
Dependency boundaries
The runtime topology separates process dependencies from network dependencies. A split deployment uses container names and shared networks for service-to-service access. An all-in-one deployment uses loopback for bundled Redis or CrowdSec and uses the configured database URI for the scheduler's database.
The scheduler is the main configuration dependency for the gateway. It needs shared state and access to the gateway API or instance network. The UI and API provide control surfaces but do not replace the scheduler. The gateway can run without the optional API, UI, Autoconf, Redis, or CrowdSec roles when the deployment does not need them. References: misc/…/docker-compose.yml• L1-52, misc/…/docker-compose.all-in-one.yml• L1-65, src/…/entrypoint.sh• L266-293, src/…/entrypoint.sh• L431-507
Change checklist
When these files or sections are changed, remember to consider these:
- Keep split-image entrypoints and the matching all-in-one Supervisor commands aligned. A service can start correctly in one topology and fail in the other if its state setup or stop path changes alone.
- Keep log file targets aligned with the log stream and rotation policy. Changing a file name or stream direction can silently remove logs or cause duplicate output.
- Keep service log keys, visible prefixes, and
HIDE_SERVICE_LOGSmatching. A mismatch can expose logs that operators expect to hide or hide the wrong service. - Keep service enablement conditions aligned between the all-in-one entrypoint and each
supervisor.dprogram. A changed default can start a local dependency that an external endpoint should own. - Keep shared
/datapaths and network service names aligned with scheduler and database configuration. A mismatch can leave the gateway running without fresh configuration.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
/data is not writable | The all-in-one entrypoint cannot create Redis or CrowdSec state and exits | Persistent storage with ownership and write access for the container user |
| A local Redis or CrowdSec service is enabled but its state or config cannot be prepared | Supervisor starts an incomplete service set or the dependent feature cannot work | The entrypoint checks local state and builds the runtime Redis configuration before Supervisor starts |
| A service log file is renamed or no longer exists | The all-in-one log stream cannot forward that service's file output | Keep file paths, symlinks, stream entries, and log rotation rules in the same contract |
| A service name does not match its log-hide key | The wrong service logs remain visible or are hidden | Keep Supervisor wrapper arguments and HIDE_SERVICE_LOGS names aligned |
| The scheduler cannot read or migrate the configured database | Configuration generation stops and the gateway can continue with stale configuration | Make the database URI reachable and let the scheduler complete its migration step |
| A reload arrives during configuration generation | A mixed configuration could be loaded or the reload could be rejected | The entrypoints coordinate reloads with the generation lock and keep the current configuration on conflict |
Key files
| File | Why to read it |
|---|---|
| src/…/entrypoint.sh | Defines all-in-one startup, service selection, reload, shutdown, and local dependency preparation |
src/all-in-one/supervisord.conf | Defines Supervisor as the foreground process and loads the service programs |
src/all-in-one/supervisor.d/ | Shows the enabled service roles, start priorities, restart rules, and output paths |
| src/…/service-log-wrapper.sh | Defines labels, log hiding, control-character filtering, and safe forwarding for bundled service output |
| src/…/logstream.sh | Bridges NGINX and ModSecurity file logs into container output |
| src/…/logrotate.ini | Connects file rotation to the all-in-one log topology |
src/all-in-one/Dockerfile | Shows the bundled runtime shape, persistent volume, exposed ports, health check, and default service roles |
| src/…/entrypoint.sh | Shows the gateway container lifecycle, preserved configuration behavior, and safe reload boundary |
| src/…/entrypoint.sh | Shows the database and configuration lifecycle before scheduled work |
| misc/…/docker-compose.yml | Illustrates the split service and network topology |
| misc/…/docker-compose.all-in-one.yml | Illustrates the all-in-one service, storage, and external database topology |