the edge ships on an image with no base, and the 368 assertions agree it behaves
ci / the operator page in a real browser (push) Successful in 2m38s
ci / lint the workflow and the shell (push) Successful in 13s
geo-freshness / the pinned geo database vs the vendor (push) Successful in 4s
ci / build, test, smoke (push) Successful in 2m48s
ci / build the image and smoke it (push) Successful in 4m23s
ci / the same smoke on an image with no base (push) Successful in 5m3s
ci / the operator page in a real browser (push) Successful in 2m38s
ci / lint the workflow and the shell (push) Successful in 13s
geo-freshness / the pinned geo database vs the vendor (push) Successful in 4s
ci / build, test, smoke (push) Successful in 2m48s
ci / build the image and smoke it (push) Successful in 4m23s
ci / the same smoke on an image with no base (push) Successful in 5m3s
Dockerfile.scratch builds the same program self-contained and puts it on scratch: 12 shared objects and the CA bundle — 18.7 MB — carried at their absolute paths, because a scratch layer has nothing to borrow them from, and the dynamic loader has to land at the path recorded inside the binary or the kernel refuses to start the process. Measured on one arm64 host: chiseled 262 MB, scratch 222 MB. scripts/compose-smoke.sh runs against it unchanged through docker-compose.scratch.yml: 368 passed, 0 failed, and 368/0 again when the same gate is called as scripts/ci-gates.sh scratch-smoke. The first scratch image built here is why that second run matters. It started, its own HEALTHCHECK reported healthy, and it still failed 7 of the 368. A self-contained apphost takes its content root from the process's working directory, a scratch image has no WORKDIR, so the process began in /, never found the appsettings.json next to it, the reverse proxy had no routes, and every request that should have reached the upstream answered the edge's own 404 — including /boom's 502, which turned the "server errors alert, they never ban" scene into a streak ban. The edge said it in its own log: "Request reached the end of the middleware pipeline without being handled by application code." The schema-script gate was red on the runner at7c5e1ef(run 2462, exit 2): `dotnet tool restore` from the repo root finds no manifest, prints "No tools were restored." and exits 0, so the gate's own restore check passed vacuously and `dotnet ef` then died. It now restores dotnet/dotnet-tools.json by path and asks the tool for its version before trusting it. NativeAOT, measured further: with the two alert-queue queries taken out, `dotnet ef dbcontext optimize --precompile-queries` on EF 10.0.12 reports 0 precompilation errors and writes 8 interceptor files — 14 of whose declarations have dots in the identifier, because the local is named from the entity type's full name. The 4 refusals that remain are four shapes the generator cannot translate at all: Contains over a captured collection, any method parameter referenced inside a query (down to the CancellationToken), an ExecuteUpdate set-list, and a literal whose type is not the column's. docs/ARCHITECTURE.md carries the exception for each. No C# changed in this commit: the experiments that produced those numbers were reverted, and the query rewrites kept at7c5e1efare the ones that made 40 refusals into 4. Gates: scratch-image and scratch-smoke in scripts/ci-gates.sh and in `all`, and a fifth CI job that runs the 368 against the scratch image on the runner.
This commit is contained in:
@@ -267,6 +267,133 @@ jobs:
|
|||||||
- name: README assertion counts match what the gate ran
|
- name: README assertion counts match what the gate ran
|
||||||
run: ./scripts/ci-gates.sh readme-counts scripts/compose-smoke.sh
|
run: ./scripts/ci-gates.sh readme-counts scripts/compose-smoke.sh
|
||||||
|
|
||||||
|
# The same stack, the same 368 assertions, and an image whose base is nothing:
|
||||||
|
# scratch plus the shared objects the program was linked against, the NSS
|
||||||
|
# modules getaddrinfo needs, OpenSSL, and the CA bundle. This is the job that
|
||||||
|
# answers "will it behave on a production host" for that shape — the first
|
||||||
|
# scratch image built here passed its own HEALTHCHECK and still failed 7 of the
|
||||||
|
# 368, because a self-contained apphost with no WORKDIR starts in / and never
|
||||||
|
# finds its appsettings.json, so the proxy had no routes and every request that
|
||||||
|
# should have reached the upstream answered the edge's own 404.
|
||||||
|
scratch-image:
|
||||||
|
name: the same smoke on an image with no base
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Longer than the image job: a self-contained publish carries the runtime
|
||||||
|
# into the image instead of borrowing a base layer's, and the build cache on
|
||||||
|
# the shared runner is cold for a second Dockerfile.
|
||||||
|
timeout-minutes: 40
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# The gate below talks to docker, and the runner's job image does not ship
|
||||||
|
# the docker CLI. Measured, not guessed: the first real run of this file
|
||||||
|
# (Gitea Actions run 2316, head 6f92d37) died here with
|
||||||
|
# `./scripts/ci-gates.sh: line 44: docker: command not found`, exit 127.
|
||||||
|
# /var/run/docker.sock is mounted from the host, so what is missing is the
|
||||||
|
# client side: the CLI, the compose v2 plugin, and buildx — `docker compose
|
||||||
|
# up --build` reaches the daemon through buildx, so the compose plugin alone
|
||||||
|
# does not bring this stack up. The same install the neemle-landing
|
||||||
|
# pipeline on this instance uses. Pinned to the Debian bookworm docker.com
|
||||||
|
# repo so the version does not drift with the image.
|
||||||
|
- name: Install Docker CLI + compose plugin
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
if command -v docker >/dev/null 2>&1; then
|
||||||
|
echo "docker already present: $(docker --version)"
|
||||||
|
else
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -qq -y ca-certificates curl gnupg >/dev/null
|
||||||
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
|
curl -fsSL https://download.docker.com/linux/debian/gpg \
|
||||||
|
| gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||||
|
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" \
|
||||||
|
> /etc/apt/sources.list.d/docker.list
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -qq -y docker-ce-cli docker-compose-plugin docker-buildx-plugin >/dev/null
|
||||||
|
fi
|
||||||
|
# compose-smoke.sh calls `docker compose`, and every command in it
|
||||||
|
# talks to the host daemon over the mounted socket. A missing socket is
|
||||||
|
# an infrastructure answer, so it says so here rather than failing
|
||||||
|
# three steps later as a broken product.
|
||||||
|
docker --version
|
||||||
|
docker compose version
|
||||||
|
docker buildx version
|
||||||
|
[ -S /var/run/docker.sock ] || { echo "no /var/run/docker.sock on this runner"; exit 1; }
|
||||||
|
docker info --format 'daemon {{.ServerVersion}} on {{.OperatingSystem}}'
|
||||||
|
|
||||||
|
# The scratch build plus both images' sizes, so the difference between
|
||||||
|
# "chiseled" and "nothing at all" is a number in the run log rather than a
|
||||||
|
# claim in a README.
|
||||||
|
- name: docker build -f Dockerfile.scratch and image size
|
||||||
|
run: ./scripts/ci-gates.sh scratch-image
|
||||||
|
|
||||||
|
# The nginx config reaches the upstream container through a named volume
|
||||||
|
# here, not through a workspace path — docker-compose.ci.yml explains why
|
||||||
|
# (the host daemon cannot see the job container's workspace). Compose names
|
||||||
|
# the volume after the project, so the name is built, not guessed.
|
||||||
|
- name: Put the upstream config where the host daemon can see it
|
||||||
|
env:
|
||||||
|
COMPOSE_PROJECT_NAME: openwafci-scratch
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
VOL="${COMPOSE_PROJECT_NAME}_openwaf-upstream-conf"
|
||||||
|
# A run that died mid-scene leaves its bans in the stack's data volume:
|
||||||
|
# `compose down` keeps named volumes, and the runner reuses the same
|
||||||
|
# project name every push. Measured on run 2361, where the 502-upstream
|
||||||
|
# scene opened with the source already banned (expected 502, got 403)
|
||||||
|
# because runs 2350 and 2355 left state behind. The gate's own scenes
|
||||||
|
# rely on data outliving `compose down`, so the clean has to happen
|
||||||
|
# before the stack starts, not in its teardown.
|
||||||
|
docker volume rm "${COMPOSE_PROJECT_NAME}_openwaf-data" \
|
||||||
|
"${COMPOSE_PROJECT_NAME}_openwaf-geoip" >/dev/null 2>&1 || true
|
||||||
|
docker volume create "$VOL" >/dev/null
|
||||||
|
docker run --rm -i -v "$VOL:/conf" busybox:1.37 sh -c 'cat > /conf/default.conf' < deploy/upstream.conf
|
||||||
|
docker run --rm -v "$VOL:/conf" busybox:1.37 sh -c 'wc -c /conf/default.conf'
|
||||||
|
|
||||||
|
# The second half of the same asymmetry: compose publishes the edge's port on
|
||||||
|
# the HOST, while the job that curls it lives in its own network namespace, so
|
||||||
|
# 127.0.0.1:<port> is refused there. Measured on run 2350: the edge container
|
||||||
|
# reached `healthy`, and the gate's first admin call died with curl exit 7.
|
||||||
|
# The default-route address of the job container is the host's own address on
|
||||||
|
# that network, and compose publishes on 0.0.0.0, so that is the address the
|
||||||
|
# gate has to be pointed at. (tskr solves the same platform quirk by running
|
||||||
|
# its gates in sibling containers — see docker/test/workspace-mount.sh there.)
|
||||||
|
- name: Name the address the job can reach the published ports on
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
# `ip` is not in this image (measured: `ip: command not found`, exit 127),
|
||||||
|
# so the route is read from the kernel's own table. The gateway there is
|
||||||
|
# hex, little-endian, and bash turns it back into dotted quad.
|
||||||
|
GWHEX=$(awk '$2=="00000000" {print $3; exit}' /proc/net/route)
|
||||||
|
[ -n "$GWHEX" ] || { echo "no default route in /proc/net/route"; exit 1; }
|
||||||
|
GW=$(printf '%d.%d.%d.%d' "0x${GWHEX:6:2}" "0x${GWHEX:4:2}" "0x${GWHEX:2:2}" "0x${GWHEX:0:2}")
|
||||||
|
echo "OPENWAF_EDGE_HOST=$GW" >> "$GITHUB_ENV"
|
||||||
|
echo "the gate will ask the edge at $GW"
|
||||||
|
|
||||||
|
# Brings up edge + nginx, waits for the image's own HEALTHCHECK, asserts
|
||||||
|
# over a socket, and tears the stack down on exit.
|
||||||
|
- name: Compose smoke — the scratch image
|
||||||
|
env:
|
||||||
|
# The CI overlay: the upstream config comes from the volume the step
|
||||||
|
# above filled. Compose reads COMPOSE_FILE itself, so the gate script
|
||||||
|
# stays the one an operator runs.
|
||||||
|
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml
|
||||||
|
# Its own compose project and its own host port. The console job below
|
||||||
|
# brings up the same file, and on any machine where two jobs share one
|
||||||
|
# docker daemon (a self-hosted runner, a local act run) the default
|
||||||
|
# project name and the default 8080 make them the same stack: one
|
||||||
|
# job's `compose down` is the other's connection refused. Measured, not
|
||||||
|
# guessed — see the comment in docker-compose.yml.
|
||||||
|
COMPOSE_PROJECT_NAME: openwafci-scratch
|
||||||
|
EDGE_PORT: "8081"
|
||||||
|
EDGE: http://${{ env.OPENWAF_EDGE_HOST }}:8081
|
||||||
|
run: ./scripts/ci-gates.sh scratch-smoke
|
||||||
|
|
||||||
|
- name: README assertion counts match what the gate ran
|
||||||
|
run: ./scripts/ci-gates.sh readme-counts scripts/compose-smoke.sh
|
||||||
|
|
||||||
# The console is a page, and a page fails in ways curl cannot see: a typo in
|
# The console is a page, and a page fails in ways curl cannot see: a typo in
|
||||||
# the inline script, a fetch that 401s, a table that renders nothing while the
|
# the inline script, a fetch that 401s, a table that renders nothing while the
|
||||||
# summary looks fine. This drives it in a real Chromium.
|
# summary looks fine. This drives it in a real Chromium.
|
||||||
|
|||||||
+12
-3
@@ -6,9 +6,18 @@
|
|||||||
# reference deployment. The AOT build compiles and the binary creates its own
|
# reference deployment. The AOT build compiles and the binary creates its own
|
||||||
# schema from the DDL it carries, and then never serves: EF cannot compile a LINQ
|
# schema from the DDL it carries, and then never serves: EF cannot compile a LINQ
|
||||||
# query at run time in a NativeAOT binary, and EF 10.0.12's precompile-queries
|
# query at run time in a NativeAOT binary, and EF 10.0.12's precompile-queries
|
||||||
# generator cannot precompile this model — it refused 40 queries and then emitted
|
# generator cannot precompile this model — it refused 40 queries, the 4 that
|
||||||
# uncompilable C# for every entity materialisation. scripts/aot-probe.sh
|
# remain are shapes it cannot translate at all (Contains over a captured
|
||||||
# reproduces the verdict in one command; docs/ARCHITECTURE.md carries the numbers.
|
# collection, any method parameter inside a query, an ExecuteUpdate set-list),
|
||||||
|
# and for the queries it does accept it emits an uncompilable declaration per
|
||||||
|
# entity materialisation. scripts/aot-probe.sh reproduces the verdict in one
|
||||||
|
# command; docs/ARCHITECTURE.md carries the numbers.
|
||||||
|
#
|
||||||
|
# The static-binary shape is not abandoned, it is blocked upstream. Meanwhile
|
||||||
|
# Dockerfile.scratch ships this same program on an image with no base at all, and
|
||||||
|
# scripts/compose-smoke.sh runs against it unchanged — the README's "Two images"
|
||||||
|
# section has both sizes, and the 7 assertions the first scratch image failed for
|
||||||
|
# a reason its own HEALTHCHECK could not see.
|
||||||
#
|
#
|
||||||
# Stages:
|
# Stages:
|
||||||
# 1. restore – NuGet layer, cached independently of source changes
|
# 1. restore – NuGet layer, cached independently of source changes
|
||||||
|
|||||||
@@ -0,0 +1,163 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
#
|
||||||
|
# openwaf edge — FROM scratch: no base image, no package manager, no shell, no
|
||||||
|
# distro. The only things in the runtime layer are this program, the shared
|
||||||
|
# objects it was linked against, the CA bundle it needs to verify an upstream's
|
||||||
|
# certificate, and the geo database.
|
||||||
|
#
|
||||||
|
# What "FROM scratch" actually costs, measured rather than assumed: the runtime
|
||||||
|
# has no OS to borrow libraries from, so every shared object has to be carried
|
||||||
|
# in. They are resolved with ldd inside the build stage and copied at their
|
||||||
|
# absolute paths — the ELF interpreter (/lib64/ld-linux-x86-64.so.2 on x86-64)
|
||||||
|
# is recorded inside the apphost, so it must land at exactly that path or the
|
||||||
|
# kernel refuses to start the process. ldd cannot see what a program dlopen()s,
|
||||||
|
# so the NSS modules getaddinfo() uses to turn "upstream" into an address are
|
||||||
|
# added by name; without them the compose upstream by service name resolves to
|
||||||
|
# nothing and every request is a 502.
|
||||||
|
#
|
||||||
|
# Why self-contained and not NativeAOT, measured on this tree on 2026-10-06:
|
||||||
|
# the AOT build compiles and its binary creates its own schema, then refuses
|
||||||
|
# every EF query ("Query wasn't precompiled and dynamic code isn't supported
|
||||||
|
# with NativeAOT"), and EF 10.0.12's precompile-queries generator cannot produce
|
||||||
|
# code for this model — it refuses Contains over a captured collection, refuses
|
||||||
|
# any method parameter inside a query, throws NullReferenceException on an
|
||||||
|
# ExecuteUpdate set-list, and for the queries it does accept emits an invalid
|
||||||
|
# declaration per entity materialisation
|
||||||
|
# ("var openWaf.Domain.Security.BlockEntryPrimaryKeyProperties = …").
|
||||||
|
# scripts/aot-probe.sh reproduces the runtime half; docs/ARCHITECTURE.md carries
|
||||||
|
# the numbers. A static binary is the right shape for this image, and EF is the
|
||||||
|
# thing standing in the way, not the Dockerfile.
|
||||||
|
#
|
||||||
|
# Stages:
|
||||||
|
# 1. restore – NuGet layer, cached independently of source changes
|
||||||
|
# 2. build – self-contained publish for the build architecture, plus the
|
||||||
|
# /rootfs tree of shared objects the runtime layer will need
|
||||||
|
# 3. geoip – the database, downloaded by a static curl image
|
||||||
|
# 4. runtime – scratch
|
||||||
|
|
||||||
|
ARG DOTNET_VERSION=10.0
|
||||||
|
ARG DBIP_VERSION=2026-10
|
||||||
|
ARG DBIP_EDITION=country
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS restore
|
||||||
|
WORKDIR /src
|
||||||
|
COPY dotnet/global.json dotnet/Directory.Build.props dotnet/NuGet.Config dotnet/OpenWaf.slnx ./
|
||||||
|
COPY dotnet/OpenWaf.Domain/OpenWaf.Domain.csproj OpenWaf.Domain/
|
||||||
|
COPY dotnet/OpenWaf.Infrastructure/OpenWaf.Infrastructure.csproj OpenWaf.Infrastructure/
|
||||||
|
COPY dotnet/OpenWaf.Edge/OpenWaf.Edge.csproj OpenWaf.Edge/
|
||||||
|
COPY dotnet/OpenWaf.Tests.Unit/OpenWaf.Tests.Unit.csproj OpenWaf.Tests.Unit/
|
||||||
|
COPY dotnet/OpenWaf.Tests.Integration/OpenWaf.Tests.Integration.csproj OpenWaf.Tests.Integration/
|
||||||
|
RUN dotnet restore OpenWaf.Edge/OpenWaf.Edge.csproj
|
||||||
|
|
||||||
|
FROM restore AS build
|
||||||
|
COPY dotnet/ ./
|
||||||
|
# Predefined ARGs are only substituted in a stage that declares them.
|
||||||
|
ARG TARGETARCH
|
||||||
|
# TARGETARCH is supplied by BuildKit; the RID is spelled out from it because
|
||||||
|
# --self-contained needs one and a scratch layer cannot make up for a wrong one.
|
||||||
|
RUN case "${TARGETARCH}" in \
|
||||||
|
amd64) RID=linux-x64 ;; \
|
||||||
|
arm64) RID=linux-arm64 ;; \
|
||||||
|
*) printf 'no self-contained RID for architecture %s\n' "${TARGETARCH}" >&2; exit 1 ;; \
|
||||||
|
esac && \
|
||||||
|
printf 'self-contained RID: %s\n' "$RID" && \
|
||||||
|
dotnet publish OpenWaf.Edge/OpenWaf.Edge.csproj \
|
||||||
|
-c Release \
|
||||||
|
-r "$RID" \
|
||||||
|
--self-contained true \
|
||||||
|
-p:DebugType=none \
|
||||||
|
-p:DebugSymbols=false \
|
||||||
|
-o /publish/api \
|
||||||
|
&& cd /publish/api \
|
||||||
|
&& rm -f *.pdb \
|
||||||
|
&& rm -rf BuildHost-net472 BuildHost-netcore
|
||||||
|
|
||||||
|
# The runtime layer's /usr, /lib and /etc, assembled from what the apphost and
|
||||||
|
# the runtime's own shared objects were linked against.
|
||||||
|
RUN set -eu; \
|
||||||
|
mkdir -p /rootfs; \
|
||||||
|
copy_at_path() { \
|
||||||
|
mkdir -p "/rootfs$(dirname "$1")"; \
|
||||||
|
cp -L "$1" "/rootfs$1"; \
|
||||||
|
}; \
|
||||||
|
# Every absolute path ldd prints, not just the "name => /path" ones: the
|
||||||
|
# dynamic loader is printed as a bare "/lib/ld-linux-aarch64.so.1 (0x...)"
|
||||||
|
# line with no arrow, and filtering on the arrow drops exactly the one file
|
||||||
|
# the kernel needs to start the process. Measured: the first scratch image
|
||||||
|
# built here started with `exec /app/api/OpenWaf.Edge: no such file or
|
||||||
|
# directory` — the ENOENT the kernel reports for a missing interpreter.
|
||||||
|
{ ldd /publish/api/OpenWaf.Edge; \
|
||||||
|
find /publish/api -name '*.so' -print0 | xargs -0 ldd; } 2>/dev/null \
|
||||||
|
| awk '{ for (i = 1; i <= NF; i++) if ($i ~ /^\//) print $i }' \
|
||||||
|
| sort -u > /needed.txt; \
|
||||||
|
printf 'loader line: %s\n' "$(grep -c 'ld-linux' /needed.txt)"; \
|
||||||
|
# ldd also lists the kernel's vdso (/dev/vdso/…), which is not a file to
|
||||||
|
# carry; anything it names that is not a regular file is skipped.
|
||||||
|
while read -r lib; do [ -f "$lib" ] || continue; copy_at_path "$lib"; done < /needed.txt; \
|
||||||
|
# dlopen(), so no ldd of anything here shows them: OpenSSL, which
|
||||||
|
# libSystem.Security.Cryptography.Native.OpenSsl.so probes at first TLS use
|
||||||
|
# (measured: an image without them starts, warms up, and then answers
|
||||||
|
# "No usable version of libssl was found" and never turns healthy), and
|
||||||
|
# getaddrinfo's name-service modules.
|
||||||
|
for mod in files dns; do \
|
||||||
|
for f in /lib/*/libnss_${mod}.so.2 /usr/lib/*/libnss_${mod}.so.2; do \
|
||||||
|
[ -e "$f" ] && copy_at_path "$f"; \
|
||||||
|
done; \
|
||||||
|
done; \
|
||||||
|
for mod in ssl crypto; do \
|
||||||
|
for f in /lib/*/lib${mod}.so.3 /usr/lib/*/lib${mod}.so.3; do \
|
||||||
|
[ -e "$f" ] && copy_at_path "$f"; \
|
||||||
|
done; \
|
||||||
|
done; \
|
||||||
|
# The CA bundle: an https upstream or an https alert webhook verifies a
|
||||||
|
# certificate, and a scratch image has no /etc/ssl to verify against.
|
||||||
|
copy_at_path /etc/ssl/certs/ca-certificates.crt; \
|
||||||
|
printf 'shared objects carried: %s\n' "$(find /rootfs/lib /rootfs/lib64 -type f 2>/dev/null | wc -l)"; \
|
||||||
|
printf 'rootfs bytes: %s\n' "$(du -sk /rootfs | cut -f1)"
|
||||||
|
|
||||||
|
RUN mkdir -p /publish/data
|
||||||
|
|
||||||
|
FROM curlimages/curl:8.10.1 AS geoip
|
||||||
|
ARG DBIP_VERSION
|
||||||
|
ARG DBIP_EDITION
|
||||||
|
RUN mkdir -p /tmp/geoip && \
|
||||||
|
curl --fail --silent --show-error --location --retry 3 --retry-delay 2 \
|
||||||
|
"https://download.db-ip.com/free/dbip-${DBIP_EDITION}-lite-${DBIP_VERSION}.mmdb.gz" \
|
||||||
|
| gunzip > /tmp/geoip/GeoLite2-Country.mmdb && \
|
||||||
|
ls -la /tmp/geoip/GeoLite2-Country.mmdb
|
||||||
|
|
||||||
|
# No base image at all. Numeric user: there is no /etc/passwd to look a name up
|
||||||
|
# in, and the volume mount points are staged with that ownership because there
|
||||||
|
# is no shell here to mkdir with at start-up.
|
||||||
|
FROM scratch
|
||||||
|
# WORKDIR is not cosmetic here. A self-contained apphost takes its content root
|
||||||
|
# from the process's working directory, and a scratch image has no WORKDIR, so
|
||||||
|
# without this the process starts in / and never finds appsettings.json next to
|
||||||
|
# it: the reverse proxy then has no routes and every request that should reach
|
||||||
|
# the upstream answers the edge's own 404. Measured — the first scratch image
|
||||||
|
# that passed its own HEALTHCHECK still failed 7 of the 368 compose assertions
|
||||||
|
# for exactly this reason, and the edge said it in its own log: "Request reached
|
||||||
|
# the end of the middleware pipeline without being handled by application code."
|
||||||
|
WORKDIR /app/api
|
||||||
|
COPY --from=build /rootfs/ /
|
||||||
|
COPY --from=build --chown=1654:1654 /publish/api /app/api
|
||||||
|
COPY --from=build --chown=1654:1654 /publish/data /app/data
|
||||||
|
COPY --from=geoip --chown=1654:1654 /tmp/geoip /app/geoip
|
||||||
|
|
||||||
|
USER 1654:1654
|
||||||
|
|
||||||
|
ENV ASPNETCORE_URLS=http://+:8080 \
|
||||||
|
ASPNETCORE_FORWARDEDHEADERS_ENABLED=false \
|
||||||
|
ConnectionStrings__OpenWaf="Data Source=/app/data/openwaf.db" \
|
||||||
|
Database__Provider=sqlite \
|
||||||
|
GEOIP_MAXMIND_DB_PATH=/app/geoip/GeoLite2-Country.mmdb \
|
||||||
|
HEALTHCHECK_PORT=8080
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# The binary is the only probe available — there is no shell, no wget, no curl,
|
||||||
|
# and not even a coreutils `true` to fall back on.
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
|
||||||
|
CMD ["/app/api/OpenWaf.Edge", "--healthcheck"]
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/api/OpenWaf.Edge"]
|
||||||
@@ -333,6 +333,41 @@ after a rebuild**. Measured on 2026-10-01: the same rebuilt image reported
|
|||||||
`docker volume rm openwaf_openwaf-geoip`. That is the command to reach for when
|
`docker volume rm openwaf_openwaf-geoip`. That is the command to reach for when
|
||||||
the pin moves.
|
the pin moves.
|
||||||
|
|
||||||
|
### Two images, one program, and the same 368 assertions against both
|
||||||
|
|
||||||
|
`Dockerfile` ships the edge on `aspnet:10.0-noble-chiseled`: a distroless
|
||||||
|
runtime, no shell, no package manager. `Dockerfile.scratch` ships the same
|
||||||
|
program on **nothing at all** — no base image, no distro, no shell — and carries
|
||||||
|
the shared objects itself: the ones `ldd` reports, the dynamic loader (the kernel
|
||||||
|
looks for it at the path recorded inside the binary, so it has to land at exactly
|
||||||
|
that path), the NSS modules `getaddrinfo` dlopen()s, OpenSSL, and the CA bundle.
|
||||||
|
|
||||||
|
Measured on this tree on 2026-10-06, one host, arm64: chiseled **262 MB**,
|
||||||
|
scratch **222 MB**, of which 12 shared objects and a CA bundle make **18.7 MB**.
|
||||||
|
`scripts/compose-smoke.sh` runs unchanged against either one — the only change is
|
||||||
|
the `docker-compose.scratch.yml` override — and both answer **368 passed,
|
||||||
|
0 failed**.
|
||||||
|
|
||||||
|
The assertions are the reason the second Dockerfile is worth having, and the
|
||||||
|
first scratch image built here is the reason they were needed: it started, its
|
||||||
|
own `HEALTHCHECK` reported healthy, and it still failed **7 of the 368**. A
|
||||||
|
self-contained apphost takes its content root from the process's working
|
||||||
|
directory; a scratch image has no `WORKDIR`, so the process started in `/`, never
|
||||||
|
found the `appsettings.json` next to it, the reverse proxy had no routes, and
|
||||||
|
every request that should have reached the upstream answered the edge's own 404 —
|
||||||
|
including the `/boom` 502 the "server errors alert, they never ban" scene is
|
||||||
|
built on, which turned that scene into a streak ban. The edge said it in its own
|
||||||
|
log: *"Request reached the end of the middleware pipeline without being handled
|
||||||
|
by application code."* A healthy container was not a working edge.
|
||||||
|
|
||||||
|
```
|
||||||
|
scripts/ci-gates.sh scratch-image # build it, print both images' sizes
|
||||||
|
scripts/ci-gates.sh scratch-smoke # the 368, against it
|
||||||
|
```
|
||||||
|
|
||||||
|
Not measured here: the linux-x86-64 scratch image. The `scratch-image` CI job
|
||||||
|
builds it on the runner, and that run is where the amd64 number will come from.
|
||||||
|
|
||||||
## Schema
|
## Schema
|
||||||
|
|
||||||
Migrations are the schema of record for PostgreSQL, which is the provider a
|
Migrations are the schema of record for PostgreSQL, which is the provider a
|
||||||
@@ -1688,7 +1723,8 @@ calls the same script one gate per step, so a local green run and a CI green run
|
|||||||
cannot mean different things.
|
cannot mean different things.
|
||||||
|
|
||||||
```
|
```
|
||||||
scripts/ci-gates.sh all # restore, build, unit, integration, smoke, image, compose-smoke
|
scripts/ci-gates.sh all # restore, build, unit, integration, smoke, both images, both smokes
|
||||||
|
scripts/ci-gates.sh scratch-smoke # the 368, against the image with no base
|
||||||
scripts/ci-gates.sh unit # or any one gate on its own
|
scripts/ci-gates.sh unit # or any one gate on its own
|
||||||
scripts/ci-gates.sh console # the page, in a real Chromium (not part of `all`)
|
scripts/ci-gates.sh console # the page, in a real Chromium (not part of `all`)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Run the production smoke against the scratch image instead of the chiseled one:
|
||||||
|
# docker compose -f docker-compose.yml -f docker-compose.scratch.yml up -d --build
|
||||||
|
# Everything else — ports, env, volumes, the nginx upstream — is the shipped
|
||||||
|
# stack, so the assertions in scripts/compose-smoke.sh are the same 368.
|
||||||
|
services:
|
||||||
|
edge:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.scratch
|
||||||
+30
-7
@@ -47,13 +47,36 @@ classifies the status, and is the only thing that can create an engine ban.
|
|||||||
binary, and the only alternative, `dotnet ef dbcontext optimize
|
binary, and the only alternative, `dotnet ef dbcontext optimize
|
||||||
--precompile-queries`, first refused 40 of this tree's queries (parameter-symbol
|
--precompile-queries`, first refused 40 of this tree's queries (parameter-symbol
|
||||||
roots and captures, dotnet/efcore#35887 / #38030 / #35494, fixed only in the
|
roots and captures, dotnet/efcore#35887 / #38030 / #35494, fixed only in the
|
||||||
12.0-preview1 line) and, after every one of them was rewritten into a shape it
|
12.0-preview1 line). Four refusals remain, and they are not a style to rewrite
|
||||||
accepts, emitted 14 declarations with dots in the identifier
|
around — they are four shapes the 10.0.12 generator cannot translate at all,
|
||||||
(`var openWaf.Domain.Security.BlockEntryPrimaryKeyProperties = …`) — 28 CS1002
|
each measured with its own exception:
|
||||||
and CS1003 errors, for every entity materialisation in the model. Reproduce with
|
|
||||||
`scripts/aot-probe.sh`. The query rewrites that attempt required are kept: they
|
* `Contains` over a captured collection — a `List<long>` local dies in
|
||||||
are behaviour-identical (378 unit, 405 integration, 256 smoke at the same commit)
|
`SqlConstantExpression.Quote()` with `ArgumentException: Argument types do not
|
||||||
and they are the precondition for trying again when EF's precompiler is fixed.
|
match`; an array is worse, `Expression of type 'System.Int64[]' cannot be used
|
||||||
|
for parameter of type 'System.ReadOnlySpan\`1[System.Int64]'`;
|
||||||
|
* **any method parameter referenced inside a query**, down to the
|
||||||
|
`CancellationToken` — `UnreachableException: IdentifierName of type
|
||||||
|
ParameterSymbol: token`. Only locals declared in the querying method work;
|
||||||
|
* an `ExecuteUpdateAsync` set-list — `NullReferenceException` in
|
||||||
|
`ExpressionTreeFuncletizer.VisitUnary`, reached from
|
||||||
|
`PrecompiledQueryCodeGenerator.ProcessCapturedVariables`, whether the value is
|
||||||
|
a cast literal or a nullable local;
|
||||||
|
* a literal whose type is not the column's — `p.AlertId >= 0` against a `long`
|
||||||
|
throws `ArgumentException: Argument types do not match` in
|
||||||
|
`CSharpToLinqTranslator.VisitLiteralExpression`; `0L` is accepted.
|
||||||
|
|
||||||
|
With those two alert-queue queries taken out the generator reports **0
|
||||||
|
precompilation errors** and writes 8 interceptor files — and 14 of their
|
||||||
|
declarations have dots in the identifier
|
||||||
|
(`var openWaf.Domain.Security.BlockEntryPrimaryKeyProperties = …`), because the
|
||||||
|
local is named from the entity type's full name: 28 CS1002 and CS1003 errors,
|
||||||
|
one pair per entity materialisation in the model. So the wall is EF's
|
||||||
|
precompiler and its code generator, twice over, not this tree's code. Reproduce
|
||||||
|
the runtime half with `scripts/aot-probe.sh`. The query rewrites that attempt
|
||||||
|
required are kept: they are behaviour-identical (378 unit, 405 integration,
|
||||||
|
256 smoke at the same commit) and they are the precondition for trying again
|
||||||
|
when EF's precompiler is fixed.
|
||||||
* **Keying the ban on ip+UA** (as the analytics `SessionHash` does): a bot that
|
* **Keying the ban on ip+UA** (as the analytics `SessionHash` does): a bot that
|
||||||
varies its UA multiplies into many sources and never reaches the threshold.
|
varies its UA multiplies into many sources and never reaches the threshold.
|
||||||
* **Banning on 5xx because the original wording said `> 400`**: turns an outage
|
* **Banning on 5xx because the original wording said `> 400`**: turns an outage
|
||||||
|
|||||||
+38
-3
@@ -4,7 +4,8 @@
|
|||||||
# the job log still names the gate that failed; `all` runs them in order and
|
# the job log still names the gate that failed; `all` runs them in order and
|
||||||
# stops at the first failure.
|
# stops at the first failure.
|
||||||
#
|
#
|
||||||
# scripts/ci-gates.sh restore|build|unit|integration|schema-script|smoke|image|compose-smoke|all
|
# scripts/ci-gates.sh restore|build|unit|integration|schema-script|smoke
|
||||||
|
# scripts/ci-gates.sh image|scratch-image|compose-smoke|scratch-smoke|all
|
||||||
# scripts/ci-gates.sh console (needs a real Chromium; not part of `all`)
|
# scripts/ci-gates.sh console (needs a real Chromium; not part of `all`)
|
||||||
# scripts/ci-gates.sh readme-counts scripts/<gate> (compares the README's
|
# scripts/ci-gates.sh readme-counts scripts/<gate> (compares the README's
|
||||||
# assertion count with what that gate printed
|
# assertion count with what that gate printed
|
||||||
@@ -58,8 +59,15 @@ schema_script() {
|
|||||||
local committed=dotnet/OpenWaf.Infrastructure/Persistence/Schema/schema.sqlite.sql
|
local committed=dotnet/OpenWaf.Infrastructure/Persistence/Schema/schema.sqlite.sql
|
||||||
local regenerated
|
local regenerated
|
||||||
regenerated="$(mktemp)"
|
regenerated="$(mktemp)"
|
||||||
if ! dotnet tool restore >/dev/null 2>&1; then
|
# --tool-manifest: the manifest lives in dotnet/, and `dotnet tool restore`
|
||||||
printf 'the pinned dotnet-ef tool could not be restored: cannot check the schema script\n' >&2
|
# from the repo root finds no manifest, prints "No tools were restored." and
|
||||||
|
# still exits 0 — measured on the runner at 7c5e1ef, where the gate then died
|
||||||
|
# on "Run \"dotnet tool restore\" to make the \"dotnet-ef\" command available."
|
||||||
|
# A successful restore is therefore checked by asking the tool for its version,
|
||||||
|
# not by trusting the restore's exit code.
|
||||||
|
if ! dotnet tool restore --tool-manifest dotnet/dotnet-tools.json >/dev/null 2>&1 \
|
||||||
|
|| ! (cd dotnet && dotnet ef --version) >/dev/null 2>&1; then
|
||||||
|
printf 'the pinned dotnet-ef tool is not available: cannot check the schema script\n' >&2
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
# OPENWAF_MIGRATE_PROVIDER=sqlite: the design-time factory defaults to postgres,
|
# OPENWAF_MIGRATE_PROVIDER=sqlite: the design-time factory defaults to postgres,
|
||||||
@@ -87,6 +95,27 @@ image() { banner image; docker build -t openwaf:ci .; docker ima
|
|||||||
|
|
||||||
compose_smoke() { banner compose-smoke; ./scripts/compose-smoke.sh; }
|
compose_smoke() { banner compose-smoke; ./scripts/compose-smoke.sh; }
|
||||||
|
|
||||||
|
# The same program on a base of nothing at all: scratch, plus the shared objects
|
||||||
|
# it was linked against, plus the CA bundle. Its size is printed next to the
|
||||||
|
# chiseled one's because the difference between the two is the claim being made.
|
||||||
|
scratch_image() {
|
||||||
|
banner scratch-image
|
||||||
|
docker build -f Dockerfile.scratch -t openwaf-scratch:ci .
|
||||||
|
# One argument per `docker image ls` — two is a usage error, exit 1. The
|
||||||
|
# chiseled line prints nothing in a job that never built it (the scratch job
|
||||||
|
# is its own job), which is why it is a separate call rather than a failure.
|
||||||
|
docker image ls --format 'scratch {{.Repository}}:{{.Tag}} {{.Size}}' openwaf-scratch:ci
|
||||||
|
docker image ls --format 'chiseled {{.Repository}}:{{.Tag}} {{.Size}}' openwaf:ci
|
||||||
|
}
|
||||||
|
|
||||||
|
# The production smoke, unchanged, against the scratch image. COMPOSE_FILE is
|
||||||
|
# appended to rather than replaced, so a caller that already names the CI
|
||||||
|
# overlay (the workflow does) keeps it and gains only the dockerfile swap.
|
||||||
|
scratch_smoke() {
|
||||||
|
banner scratch-smoke
|
||||||
|
COMPOSE_FILE="${COMPOSE_FILE:-docker-compose.yml}:docker-compose.scratch.yml" ./scripts/compose-smoke.sh
|
||||||
|
}
|
||||||
|
|
||||||
# The browser gate over the operator page. It is a gate, so it lives here too and
|
# The browser gate over the operator page. It is a gate, so it lives here too and
|
||||||
# CI calls it by the same name. It is NOT part of `all`: it needs a real
|
# CI calls it by the same name. It is NOT part of `all`: it needs a real
|
||||||
# Chromium, and a machine without one exits 2 ("cannot run"), which is a
|
# Chromium, and a machine without one exits 2 ("cannot run"), which is a
|
||||||
@@ -227,7 +256,9 @@ case "${1:-all}" in
|
|||||||
smoke) smoke ;;
|
smoke) smoke ;;
|
||||||
schema-script) schema_script ;;
|
schema-script) schema_script ;;
|
||||||
image) image ;;
|
image) image ;;
|
||||||
|
scratch-image) scratch_image ;;
|
||||||
compose-smoke) compose_smoke ;;
|
compose-smoke) compose_smoke ;;
|
||||||
|
scratch-smoke) scratch_smoke ;;
|
||||||
console) console ;;
|
console) console ;;
|
||||||
lint) lint ;;
|
lint) lint ;;
|
||||||
readme-counts) readme_counts "${2:-}" ;;
|
readme-counts) readme_counts "${2:-}" ;;
|
||||||
@@ -237,6 +268,10 @@ case "${1:-all}" in
|
|||||||
# same invocation.
|
# same invocation.
|
||||||
export GATE_TOTALS_DIR="${GATE_TOTALS_DIR:-$(mktemp -d)}"
|
export GATE_TOTALS_DIR="${GATE_TOTALS_DIR:-$(mktemp -d)}"
|
||||||
restore; build; unit; integration; schema-script; smoke; image; compose_smoke
|
restore; build; unit; integration; schema-script; smoke; image; compose_smoke
|
||||||
|
# The scratch image and the same 368 assertions against it. It is in `all`
|
||||||
|
# because it is the shipped shape, not an experiment: the only difference a
|
||||||
|
# caller can see is what is under the program.
|
||||||
|
scratch_image; scratch_smoke
|
||||||
# The two gates `all` actually ran. console is not among them, so its README
|
# The two gates `all` actually ran. console is not among them, so its README
|
||||||
# number is verified by the console job (or by an operator who ran it and
|
# number is verified by the console job (or by an operator who ran it and
|
||||||
# then calls readme-counts with the same GATE_TOTALS_DIR).
|
# then calls readme-counts with the same GATE_TOTALS_DIR).
|
||||||
|
|||||||
Reference in New Issue
Block a user