Infrastructure review and evidence
Reviewed on 2026-11-30: Dockerfile, production/development/proxy Compose definitions, .env.example, Docker build-context exclusions, frontend build/watch publication, data storage/cleanup, and project operations. This is a technical review with isolated acceptance evidence, not production installation approval.
Verified boundaries
The production image runs as UID/GID 1654. Compose uses a read-only root filesystem, drops capabilities, sets no-new-privileges, bounds memory/CPU/processes, places writable state/data on separate owned named volumes, and publishes only a loopback application port. It creates no listener on 80/443 and installs no production Caddy service. The external-network overlay refers to an existing network and uses a project-specific DNS alias.
The app's readiness probe checks database connectivity and an active catalogue entry. It does not replace a real browser renderer check, archive validation, HTTPS acceptance or notification-delivery testing. Initial archive import can take longer than one readiness wait; an unavailable dataset does not become an authenticated working map merely because the process is running.
Signing/bootstrap secrets are read-only file mounts; SMTP credentials use the optional private secrets-folder mount and SmtpPasswordFile. The application reads an SMTP password only when SMTP delivery is configured. Operations restrict secret paths to the installation's private secrets/ directory, require mode 0400 and UID/GID 1654, and never print values. The image build context excludes secret directories, .env and .env.*, operational state, and nested/mixed-case PMTiles archives. The web build also excludes PMTiles case-insensitively. Protected archives belong in the catalogue volume, not image/static output.
Forwarded headers use explicitly parsed exact trusted IPs. The configured public host constrains forwarded host handling; no broad trusted subnet is installed. Host Caddy may appear through Docker's gateway address, so the exact peer must be verified on the target installation. An external-network Caddy should use a stable exact IP on its existing network. Origin policy remains additional authorization policy; it is not a substitute for project tokens.
Examples suppress viewer access logging and skip response compression for protected PMTiles Range paths. Operational app logs default to Warning with hosting request diagnostics filtered. No telemetry or visitor-IP persistence is introduced by this review. A deployment owner must still review any global Caddy/upstream edge logging or shared caches that exist outside this project.
Findings and changes
Reproducible image recipe
Pinned source/dependencies alone did not make image IDs repeatable: a root-filesystem comparison found identical server/CLI payloads but different generated mtimes, and ASP.NET's static-webassets endpoint manifest embedded build-time Last-Modified headers for compressed CSS. The artifact stage now sets those headers and exported file/directory/symlink timestamps from SOURCE_DATE_EPOCH. Runtime package-installation metadata and helper installation/removal metadata are normalized in the same layer that creates them; existing base files are not copied into a new blanket normalization layer. Docker-generated host files and virtual filesystems are excluded. The helper uses only its existing Python standard library for normalization.
For a release, freeze the checkout, base digests, lockfiles, build number, commit and original epoch. SOURCE_DATE_EPOCH is optional in .env and passed to both Compose builds. With it unset, development builds keep their ordinary current timestamps. Explicit BUILD_TIMESTAMP overrides the web metadata timestamp; otherwise it follows the epoch. Exact image rebuilds additionally need BuildKit's image exporter timestamp rewriting and disabled changing provenance attestations. Example for Linux, using separate release tags:
epoch="$(git show -s --format=%ct HEAD)"
commit="$(git rev-parse HEAD)"
docker buildx build --no-cache --provenance=false \
--build-arg "SOURCE_DATE_EPOCH=$epoch" \
--build-arg "GIT_COMMIT=$commit" --build-arg BUILD_NUMBER=release-1 \
--output type=image,rewrite-timestamp=true,unpack=false -t ctwebmaps:release-1 .
docker buildx build --no-cache --provenance=false \
--build-arg "SOURCE_DATE_EPOCH=$epoch" \
--output type=image,rewrite-timestamp=true,unpack=false \
-f build/ops/Dockerfile -t ctwebmaps-ops:release-1 .
SOURCE_DATE_EPOCH means the original source commit time and must be current or past, never a scheduled future release date. The normalizer, helper and reproducibility runner reject future epochs. BuildKit clamps timestamps newer than the epoch; with a future epoch its injected host-file mount teardown can reset /etc metadata after build commands finish. An actual future-epoch trial exposed this boundary, so it is rejected rather than advertised as repeatable. The recipe preserves asset ETags, content hashes and compressed payloads. The helper also removes timestamp-bearing apk.log and disables Python bytecode generation during its build.
Actual no-cache twin builds at epoch 1795996800 passed for both components: app image sha256:6cc639b7b7e8ffbd2e34d8effa4909ecbef246b99f71d5d1ac22e1a9683b38a5; helper proof is recorded alongside it in artifacts/reproducible-builds.json. The app and corrected helper were frozen and tested independently. The final guards are additionally checked by targeted tests and a repeated helper pair. node tests/infrastructure/reproducible_build.mjs repeats both image builds from a frozen local snapshot, records exact IDs and epoch-specific reports in artifacts/, and writes build logs under .runtime/. Set SOURCE_DATE_EPOCH to override the default fixture epoch or REPRO_COMPONENTS=ops to repeat only the helper. tests/infrastructure/compare_rootfs.py compares exported root filesystems without extraction/execution; compare_image_layers.py also checks saved layer metadata. Evidence applies to the recorded snapshot, platform, toolchain and dependency inputs; arbitrary future repository/package changes produce different images.
| Finding | Outcome/evidence |
|---|---|
| CLI release URL was pinned but downloaded bytes were not verified | The final source-build recipe checks the official source archive SHA256 before extraction and pins the compiler image plus module versions/checksums. Application base images use immutable digests; npm and NuGet restore use lockfiles. |
| Official CLI prebuilt embeds vulnerable Go/dependency versions | Replaced by a dependency-only rebuild of pinned upstream v1.31.2 under pinned Go 1.27.4, with frozen module graph and source hash. The exact recipe produced an identical binary to the patched candidate; Trivy detected 109 Go packages and zero vulnerabilities of any severity. Details/evidence are in build/pmtiles/README.md and the local patched-CLI audit artifact. |
| Distributed CLI needs third-party notices, not only a dependency list | The build collects 730 original notice files, covering all 108 linked modules and Go toolchain LICENSE/PATENTS, with SHA256 inventory and downloadable /licenses/go/notices.zip. The full graph has 688 entries; two unlinked graph-only modules lack matching root notices and are explicitly listed, without invented terms. Source bytes and all ZIP payloads were verified. This is notice delivery, not legal approval. |
Context excluded only .env and one lowercase PMTiles directory |
Root ignore rules now cover .env.*, .ops, and nested/mixed-case PMTiles; real Docker context canaries passed. |
Web build excluded .pmtiles case-sensitively |
Case-insensitive archive exclusion is implemented. |
Data free-space checks measured / on Linux, not a separately mounted data filesystem |
Fixed to measure the actual data path on Unix and the drive root on Windows. A separate 32 MiB tmpfs reproduced the old error and passes the corrected capacity/import guard. |
| A large extraction could consume the reserve after the initial check | Actual free space is monitored every 100 ms during extraction/import; reserve crossing cancels/drains the writer and kills the CLI before cleanup. Native and real 32 MiB tmpfs/process regressions preserve active data and recover staging space. This is a sampled guard, not a quota against unrelated processes. |
Fresh custom container mount paths lose Dockerfile's default /state//data ownership |
Operations initialization now prepares only the two verified owned named-volume roots as UID/GID 1654, independent of application mount targets. |
| Storage configuration could shadow application/system paths or disagree with mounts | Operations reject unsafe/nonabsolute/overlapping storage paths and require the configured state/data roots to match their own named-volume mounts. Startup static-root overlap validation is also required in the server. |
| Per-file frontend publication could leave temporary or mixed files after I/O failure | Root added rollback and temporary-file cleanup. The regression injects one failed index.html rename after compilation succeeds, modifies an earlier CSS asset and compares all published file hashes. The root agent reports the corrected regression passes; compiler failures are also covered. This does not claim whole-directory atomic visibility during a successful multi-file publication or recovery from a hard power loss. |
| Retention assumes a bounded complete browser session, while token renewal can continue | SDK/server session-expiry and config-refresh work is coordinated separately. Automatic cleanup is safe only for supported bounded SDK sessions and custom clients honoring the same session/refresh contract, plus configured grace. Token lifetime alone is insufficient. |
| Package repositories must retain the selected versions | ICU and helper security packages use exact versions. Repeatability uses the fixed metadata/exporter recipe above; package availability still depends on external repositories. Retain reviewed image artifacts for offline recovery. |
| Raw maintenance Python image included vulnerable OS/pip components | The separate reviewed helper now uses the patched pinned Python/OS recipe without pip/ensurepip. The local Trivy report detects 33 OS packages and zero vulnerabilities. Operations require local review/API labels, no entrypoint override, immutable-ID execution and no automatic pulls. Actual Docker policy tests reject missing/unreviewed/entrypoint-overridden images before volume mutation. |
| Restoring an optional SMTP secret could fail after copying state/data | Reproduced with real Docker volumes. Stage metadata now declares all required secrets; missing target files are refused before install. The helper also opens every writable target before any volume copy. Tests preserve original signing keys/empty volumes on refusal and restore successfully after explicit SMTP-file provisioning without enabling SMTP. |
External existing-network fixture
tests/infrastructure/Dockerfile launches a private nested Docker daemon without the host Docker socket. It uses the actual compose.yml and compose.caddy-network.yml, plus a clearly synthetic Python upstream so no production map archive or credentials are needed.
The fixture creates an independent Caddy container before the app, attaches Caddy only to the pre-existing external network, then starts the app through the real overlay. It verifies:
- The app joins both its own default network and the existing external network, with the expected unique project alias.
- Requests traverse Caddy to that alias; the upstream sees Caddy's exact configured network IP.
- Authorization/Origin/Range headers survive transport, authorized sample bytes return 206 with exact range/length/ETag, private cache and CORS policy survive, and Range output is not compressed despite
Accept-Encoding: gzip. - The synthetic upstream denies a request without authorization, so the proxy does not accidentally use a public alternate route.
- Viewer request paths/tokens are absent from Caddy's captured operational logs.
- Compose teardown leaves the existing network and independent Caddy running.
- Docker's actual context parser excludes synthetic
.env.production, secret-file, nested and mixed-case PMTiles canaries.
This verifies attachment, naming and proxy transport. The upstream is synthetic; actual ASP.NET authentication, trusted-header semantics and PMTiles serving remain covered by the real backend/proxy tests rather than inferred from this fixture.
Docker Desktop's nested cgroup namespace cannot apply all CPU/memory domain controllers. The network fixture explicitly overrides those app caps, and the custom-path operations fixture omits helper resource flags with a local test-only CLI adapter. It retains a private cgroup namespace, no host socket, real files/volumes/permissions/Compose behavior, and no production resources. Resource-limit enforcement is measured separately in real-host disposable containers and application performance tests. These fixtures must not be presented as CPU/RAM-cap acceptance evidence.
Custom placement and lifecycle acceptance
MAPS_DATA_PATH and MAPS_STATE_PATH choose private container mount targets for the project's own named volumes. They are not arbitrary host bind paths. The operations helpers mount those same verified volumes at their own canonical /data and /state, so encrypted backup/restore does not depend on app target names. Driver bind options, external volumes and mismatched project/directory ownership are refused.
The custom-path fixture resolves the real central Compose configuration, starts a UID-1654 synthetic app at /custom/data and /custom/state, creates actual SQLite/map-data files, encrypts a consistent backup, and restores into a second installation using different /recovery/... targets. It verifies stored SQLite content and map-data bytes through canonical helper mounts, then starts the recovered app. This tests placement, ownership and backup compatibility, not the actual ASP.NET rendering path.
A separate full-size acceptance run on 2026-11-30 used the actual final ASP.NET image sha256:33b2f7272d365caa24944a70137c2fe0cf5e61135881743b7f23b3f644a4a64c and the patched reviewed helper built from build/ops/Dockerfile. The fixture explicitly checked ASP.NET 10.0.15 and CLI 1.31.2-ctweb.1, booted the app, imported the complete 968353286-byte Denmark archive, and passed the application's real readiness probe. It encrypted the complete state/data/secrets backup, restarted the source, restored a second real instance at /recovery/state and /recovery/data, and verified matching active data version/signing-key bytes plus actual Identity SQLite and catalogue contents as UID 1654. Both instances were ready simultaneously; uninstalling the recovered target preserved source readiness. The helper was resolved through the maintenance profile, checked for review/API labels, and executed by its local immutable ID. This proves full application/data recovery for that image and fixture environment; later unrelated code changes still require their own checks. No browser/TLS acceptance or production recovery-time objective is inferred from this run.
The full-size run was repeated on 2026-11-30 23:34:01–23:36:33 UTC using the final functional candidate, source commit 288fce43051994c272621223d5b8f048732871f0, image manifest sha256:05eb07b8174bccc7379d328b31e9658b05b47f4ec6e298a36907adbac47d9f85, config ID sha256:cdd85c0b01ce427e07397e3e9e1c38c18ca6f1c675ee19e24e34179cb845f1f8. The private nested engine loaded that exact exported candidate and confirmed .NET/ASP.NET 10.0.15 and PMTiles 1.31.2-ctweb.1. The complete 968353286-byte import, encrypted state/data/secrets backup, source restart, custom-path restore, Identity SQLite/catalogue/signing-key checks, simultaneous readiness and target-only purge all passed again.
This repeat additionally verified the Production SDK-release archive. The source had persisted release directories and SHA-256 manifests matching every SDK file. After encrypted restore, a separate read-only volume probe compared exact manifest hashes and every retained SDK file hash before the recovered app was started, preventing current-image republication from masking a missing backup. The same bytes remained after startup. Unauthenticated historical SDK JS/CSS/worker/declaration HTTP responses matched the stored hashes and immutable-cache policy on both installations. The source stayed healthy after target uninstall. Evidence is artifacts/actual-ops-sdkarchive.log; the fixture is tests/infrastructure/actual_app_ops.py.
The 152-second interval includes helper/generic-fixture work, image loading and the complete real-app sequence; it is not an isolated backup/restore timing or production RTO. Nested unsupported resource caps remain explicitly omitted as described above. No existing production app, proxy, host socket, data source bytes or external volumes were changed.
Backup placement is centrally configured by MAPS_BACKUP_ROOT, resolved through the Compose extension. Omitted backup/update checkpoint paths use a project/timestamp/random filename inside that root; explicit command-line paths override it. Relative traversal and linked roots are rejected, operator-selected absolute roots are allowed, and existing ciphertext is never overwritten. Actual Linux operations tests cover the central fallback for both backup and update plus explicit overrides. Restore still requires an explicit source path; no automatic retention policy is implied.
Data cleanup review
Catalogue and archive paths are derived from strict version identifiers. Resolution checks every existing ancestor for symlink/reparse points. Imported archives are staged, fully validated/hashed, renamed into immutable directories, then activated by an atomically replaced catalogue. Rollback revalidates the archived bytes before changing the pointer.
Retention protects the current version, the configured most-recent activation count, and inactive archives until deactivation time plus full supported session lifetime plus grace. Rollback starts a fresh window for the version being deactivated. Cleanup deletes only a known archive file and then an empty version directory, never recursively traversing arbitrary contents. Busy/unauthorized cleanup is deferred.
Abandoned staging cleanup considers GUID-named directories older than 24 hours while holding the same writer lock. It refuses links and unexpected nested contents. An immutable directory left unreferenced after a crash is deliberately retained. The private volume must have one owner and no untrusted writers: ancestor checks do not claim race-free protection against a malicious process concurrently replacing filesystem components. Hard links or direct archive mutation by another privileged writer would likewise violate immutable-storage ownership. Directory-entry persistence across power loss still requires target-filesystem recovery testing.
Commands and outstanding acceptance
python3 -m unittest discover -s tests/infrastructure -p 'test_*.py' -v
node --test tests/infrastructure/build-publication.test.mjs
docker build -f tests/infrastructure/Dockerfile -t ctwebmaps-infrastructure-fixture:local .
docker run --rm --privileged --name ctwebmaps-infrastructure-fixture ctwebmaps-infrastructure-fixture:local
For the full real-image mode, export a reviewed image and provide the full Denmark archive explicitly. Example on a Linux development host:
docker save --output .runtime/ops-app.tar ctwebmaps:1.0.0-development
docker run --rm --privileged --name ctwebmaps-real-ops-fixture \
-e CTWEB_FIXTURE_APP_TAR=/fixture-app-image.tar \
-e CTWEB_FIXTURE_BOOTSTRAP=/fixture-denmark.pmtiles \
--mount "type=bind,source=$(pwd)/.runtime/ops-app.tar,target=/fixture-app-image.tar,readonly" \
--mount "type=bind,source=$(pwd)/public/data/denmark.pmtiles,target=/fixture-denmark.pmtiles,readonly" \
ctwebmaps-infrastructure-fixture:local
The full mode requires the current expected patched runtime/CLI versions, imports the real archive once, and needs space for source data, ciphertext, staging and restored data. Without explicit fixture inputs, the ordinary command reports that real-image acceptance was not requested. No host socket or host cgroup namespace is mounted.
The Windows sandbox may deny esbuild's parent-directory reads; run its isolated publication fixture from an approved normal development shell when needed. It copies source into a private fixture directory and never edits the live source/output or copies the large PMTiles archive.
Production DNS/certificates, the real existing proxy's exact IP and global logging/cache policy, measured full-size backup/recovery duration, organization key custody/retention, SMTP/webhook delivery, cross-architecture image execution and power-loss recovery remain explicit installation acceptance. No production service or existing Caddy installation was changed by these tests.