Distribution and deployment
BunkerWeb turns one shared service platform and its pinned dependencies into deployment artifacts for container runtimes and Linux hosts. The distribution model keeps the same core service set across these targets while adapting process layout, runtime libraries, persistent data, and service startup to each environment.
Distribution model
The distribution model has three main forms: separate container services, an all-in-one container, and Linux packages. Each form assembles the BunkerWeb code with compiled native modules, Python dependencies, web assets, and runtime tools before the target environment starts the services.
| Form | Main purpose | Service shape |
|---|---|---|
| Separate containers | Scale or place service roles independently | BunkerWeb, Scheduler, UI, and API images |
| All-in-one container | Run the complete stack in one container | Nginx, Scheduler, UI, optional API, Redis, and CrowdSec under one supervisor |
| Linux packages | Install on a host managed by systemd | Package files with independent BunkerWeb, Scheduler, UI, and API units |
The common dependency set is assembled from pinned source archives and Git revisions. The build compiles Nginx modules and native support libraries, installs language dependencies, and applies required local patches before the result moves into a runtime image or package. src/…/deps.json defines the source inputs. Its current set includes Nginx 1.30.7 plus the native modules and support libraries used by the service. The shared dependency install process defines the reusable native output.
References: src/…/deps.json• L1-329 src/…/install.sh• L16-250
Dependency assembly
Dependency assembly separates build tools from runtime content. Builder stages compile the native and language dependencies. Later stages keep only the libraries, application files, and tools needed to run the selected service.
The build uses architecture-aware inputs where binary wheels or database dependencies differ. It also verifies selected external inputs by hash or signing-key fingerprint. This gives container images and Linux packages a repeatable dependency base rather than relying on an untracked host environment.
The dependency flow produces one shared application tree. Service-specific images then add only the code and language requirements needed by their role. The all-in-one image combines the service code and adds its internal Redis and CrowdSec support.
This diagram shows how pinned sources become reusable runtime content and then move into each deployment form.
flowchart LR
S[Versioned source and dependency metadata] --> B[Builder environment]
B --> N[Native modules and libraries]
B --> P[Language dependencies]
B --> A[Application and web assets]
N --> R[Shared runtime tree]
P --> R
A --> R
R --> C[Service container images]
R --> O[All-in-one image]
R --> L[Linux package payload]
References: src/…/Dockerfile• L1-167 src/…/Dockerfile• L1-70 src/…/Dockerfile• L1-47 src/…/Dockerfile• L1-30 src/…/Dockerfile• L1-70 src/…/Dockerfile-debian-bookworm• L1-62
Container distributions
Container distributions provide role-based images for deployments that want separate service lifecycles. The BunkerWeb image handles web traffic. Scheduler, UI, and API images provide the supporting roles. Each image uses a dedicated non-root runtime user and a health check.
The reference Compose setup connects the BunkerWeb and Scheduler roles through bw-universe. It publishes web traffic on host ports 80 and 443, stores Scheduler state in the bw-storage volume, and passes the protected service address through BUNKERWEB_INSTANCES. A second bw-services network remains available for protected service traffic.
The all-in-one image serves a different goal. It includes the web service and supporting roles in one image, prepares Redis and CrowdSec for local use, and uses Supervisor to keep the internal processes together. It exposes the combined entry points and stores durable state under /data.
See Container runtime topologies for the supported ways to connect these images and place their roles.
References: misc/…/docker.yml• L1-42 src/…/Dockerfile• L72-131 src/…/Dockerfile• L48-107 src/…/Dockerfile• L31-83 src/…/Dockerfile• L71-128 src/…/Dockerfile• L168-276
Container image delivery
The container build is a reusable release process. A caller selects the release label, target architecture, image name, and Dockerfile. The process can build from a registry cache, build without that cache, or create a candidate image for later promotion.
Candidate images are pushed to GHCR with a digest, provenance, and software bill of materials. The exact digest is then scanned. Regular images are also scanned when the build runs on the main builder path. A Trivy gate blocks images with matching vulnerabilities, while the SARIF report feeds the GitHub Security view.
The process supports native ARM builders through SSH and can publish the tested image to the test image namespace. This keeps multi-architecture output tied to the exact source revision and scanned image digest.
References: .github/…/container-build.yml• L1-50 .github/…/container-build.yml• L52-162 .github/…/container-build.yml• L165-260
Linux distributions
Linux distributions package the same BunkerWeb service set for host installation. The package payload includes the application tree, Nginx integration, runtime data paths, systemd unit files, log rotation, and install or upgrade actions.
The package build runs in a distribution-specific builder image. It creates a DEB or RPM artifact through FPM, with the target distribution and architecture determining the package format and name. This keeps native module builds aligned with the host Nginx and operating-system libraries.
Installation and upgrade are active deployment steps rather than simple file extraction. The post-install flow restores protected configuration and database backups, sets ownership and permissions, then enables, starts, restarts, or disables the BunkerWeb, Scheduler, UI, and API units according to the declared topology. A marker records an explicitly selected install type so later upgrades can preserve the intended service layout.
See Linux packaging for package creation, install modes, and upgrade behavior.
References: src/…/Dockerfile-debian-bookworm• L152-191 src/…/fpm.sh• L1-30 src/…/package.sh• L16-50 src/…/postinstall.sh• L81-130 src/…/postinstall.sh• L132-306 src/…/bunkerweb.service• L1-20 src/…/bunkerweb-scheduler.service• L1-20 src/…/bunkerweb-ui.service• L1-20 src/…/bunkerweb-api.service• L1-20
Runtime state
All deployment forms separate shipped code from mutable state. Container images place persistent data under /data and link service paths to that volume. Linux packages use host paths under /etc/bunkerweb, /var/lib/bunkerweb, /var/cache/bunkerweb, /var/log/bunkerweb, and /var/tmp/bunkerweb.
This boundary allows an image replacement or package upgrade to update code without removing configuration, caches, certificates, databases, or generated site data. Permissions and service users remain part of the distribution contract because each runtime must read shared code while writing only its state paths.
References: src/…/Dockerfile• L200-249 src/…/Dockerfile• L95-117 src/…/Dockerfile• L69-86 src/…/Dockerfile• L54-64 src/…/Dockerfile• L95-109 src/…/Dockerfile-debian-bookworm• L169-186 src/…/postinstall.sh• L35-51
Change checklist
When these files or sections are changed, remember to consider these:
- Keep dependency source revisions, native module build inputs, and the target Nginx version aligned across container and Linux builders.
- Keep service names, topology signals, systemd units, container entry points, and install-type detection aligned when adding or removing a service role.
- Keep Compose networks, published ports, service addresses, and the
/datavolume contract aligned with container topology guidance. - Keep
/datalinks and Linux state paths compatible with upgrade backup and restore rules. - Keep candidate image digests, platform labels, registry destinations, and vulnerability scan references tied to the same built image.
- Keep package architecture naming and FPM metadata aligned with the package builder selected for each distribution.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Native modules build against a different Nginx version | Nginx can reject the modules at startup | Match the module source tree to the target Nginx build |
| A required dependency patch no longer matches its vendored file | The image or package build stops instead of silently shipping altered behavior | Apply patches with an exact dry run and a post-patch marker check |
| Container roles use different networks or an incorrect protected service address | Scheduler cannot reach BunkerWeb or protected traffic cannot reach its service network | Keep Compose networks, BUNKERWEB_INSTANCES, and published ports aligned |
| The candidate scan uses a tag instead of the built digest | A different image can pass or fail the release gate | Scan the exact candidate digest recorded by the build |
| Package topology signals do not match the intended role layout | An upgrade can start or stop the wrong systemd services | Declare the topology and preserve the install-type marker |
| Persistent data is not mounted or has wrong ownership | Services cannot read configuration or write state | Use the distribution's data paths and service group permissions |
Key files
| File | Why to read it |
|---|---|
| src/…/deps.json | Defines the pinned external dependency set and its current Nginx baseline. |
| src/…/install.sh | Shows the shared native dependency and Nginx module output. |
| misc/…/docker.yml | Shows how the separate container roles connect and persist state. |
| .github/…/container-build.yml | Shows the multi-architecture image build, candidate promotion, and vulnerability gate. |
src/bw/Dockerfile | Shows the core container distribution. |
src/all-in-one/Dockerfile | Shows the combined service distribution and its internal support services. |
src/linux/Dockerfile-debian-bookworm | Shows the Linux package build lifecycle. |
| src/…/postinstall.sh | Shows host install, upgrade, state restore, and topology handling. |
src/linux/bunkerweb.service | Shows the systemd contract for the main web service. |