ci / lint the workflow and the shell (push) Successful in 10s
ci / the operator page in a real browser (push) Successful in 2m36s
ci / the same smoke on an image with no base (push) Successful in 4m4s
ci / build the image and smoke it (push) Successful in 4m4s
ci / build, test, smoke (push) Successful in 2m19s
Run 2503 turned a good artifact red: the publish layer was cached, the report layer was cached with it, the build log carried no report lines, and the gate that greps that log found nothing to match. The report is now a script (scripts/aot-link-report.sh) that the build stage copies in and runs, and that CI runs again with `docker run --entrypoint sh … /report.sh` — a container start is never cached, so the gate asks the binary. It exits non-zero when the link names an interpreter or needs a shared object, which is the one claim a scratch layer depends on. Verified here: the script prints `binary bytes: 56820992`, `static-pie linked`, `program headers naming an interpreter: 0`, `NEEDED shared objects: 0`, `static: no interpreter, no NEEDED shared object`, exit 0 — both as a build step and as a `docker run`. .dockerignore keeps `scripts/` out of the context and now makes one named exception for it.
114 lines
5.5 KiB
Docker
114 lines
5.5 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
#
|
|
# NativeAOT probe: the packaging recipe that works for its neighbour project,
|
|
# applied to this edge and measured. NOT the shipped image — Dockerfile (chiseled)
|
|
# and Dockerfile.scratch (self-contained on no base) are what ship.
|
|
#
|
|
# What this proves: the AOT build of this program links FULLY STATIC against musl
|
|
# — no libc, no interpreter — so a scratch layer holding one binary is reachable
|
|
# for openwaf too. What it does not prove: that the binary serves traffic. EF
|
|
# refuses to compile a LINQ query at run time in a NativeAOT binary and EF
|
|
# 10.0.12's precompile-queries generator cannot produce code for this model;
|
|
# docs/ARCHITECTURE.md (NativeAOT entry) carries the four refusal shapes and the
|
|
# codegen bug, and scripts/aot-probe.sh reproduces the runtime half.
|
|
#
|
|
# The recipe is not invented here. ~/work/tskr ships a .NET 10 NativeAOT API FROM
|
|
# scratch as one static musl binary (app/api/Dockerfile, app/api/leasevibe.csproj)
|
|
# and it gets there by deleting the thing that blocks us: it has no EF Core at
|
|
# all — Npgsql plus a Roslyn source generator (app/lib/MicroOrm) that turns
|
|
# Where(...) expressions into generated code at build time. The parts that
|
|
# transfer regardless of the data layer are here:
|
|
# apk add clang build-base cmake zlib-dev zlib-static openssl-dev openssl-libs-static
|
|
# RID linux-musl-*, <StaticExecutable>true</StaticExecutable>,
|
|
# <StaticOpenSslLinking>true</StaticOpenSslLinking>, <IlcSingleThreaded>true
|
|
# scratch + CA bundle + SSL_CERT_FILE, healthcheck answered by the binary itself.
|
|
# It also names the wall this host has: the musl AOT ILC crashes under emulation
|
|
# on Apple Silicon, so the linux-musl-x64 build belongs on the x86 runner.
|
|
|
|
ARG DOTNET_VERSION=10.0
|
|
ARG DBIP_VERSION=2026-10
|
|
ARG DBIP_EDITION=country
|
|
|
|
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-alpine AS restore
|
|
WORKDIR /src
|
|
# The AOT link needs a real toolchain plus the STATIC system libs: libz.a,
|
|
# libssl.a, libcrypto.a. cmake is pulled in by the StaticOpenSslLinking step.
|
|
RUN apk add --no-cache clang build-base cmake zlib-dev zlib-static openssl-dev openssl-libs-static
|
|
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/
|
|
ARG TARGETARCH
|
|
RUN case "${TARGETARCH}" in \
|
|
amd64) RID=linux-musl-x64 ;; \
|
|
arm64) RID=linux-musl-arm64 ;; \
|
|
*) printf 'no musl RID for architecture %s\n' "${TARGETARCH}" >&2; exit 1 ;; \
|
|
esac && printf 'RID=%s\n' "$RID" > /rid && dotnet restore OpenWaf.Edge/OpenWaf.Edge.csproj -r "$RID"
|
|
|
|
FROM restore AS build
|
|
COPY dotnet/ ./
|
|
RUN . /rid && dotnet publish OpenWaf.Edge/OpenWaf.Edge.csproj \
|
|
-c Release \
|
|
-r "$RID" \
|
|
--self-contained true \
|
|
-p:PublishAot=true \
|
|
-p:InvariantGlobalization=true \
|
|
-p:DebugType=none \
|
|
-p:OpenWafCompiledModel=true \
|
|
-p:NoWarn=IL2026%3BIL3050 \
|
|
-p:IlcTreatWarningsAsErrors=false \
|
|
-p:StaticExecutable=true \
|
|
-p:StaticOpenSslLinking=true \
|
|
-p:IlcSingleThreaded=true \
|
|
-o /publish/api \
|
|
&& mkdir -p /publish/data
|
|
|
|
# The static-link claim, checked against the binary rather than asserted in a
|
|
# comment. The same script is what CI runs — see scripts/aot-link-report.sh for
|
|
# why the gate does not grep this build's log (a cached layer prints nothing, and
|
|
# run 2503 turned a good artifact red that way).
|
|
COPY scripts/aot-link-report.sh /report.sh
|
|
RUN sh /report.sh /publish/api/OpenWaf.Edge
|
|
|
|
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
|
|
|
|
FROM scratch
|
|
# Content root is the working directory for a self-contained apphost, and this
|
|
# one is the binary itself: without WORKDIR the process starts in / and never
|
|
# finds appsettings.json, which leaves the proxy with no routes. Measured on the
|
|
# scratch (JIT) image, where it cost 7 of the 368 assertions.
|
|
WORKDIR /app
|
|
COPY --from=build --chown=1654:1654 /publish/api/OpenWaf.Edge /app/OpenWaf.Edge
|
|
COPY --from=build --chown=1654:1654 /publish/api/appsettings*.json /app/
|
|
COPY --from=build --chown=1654:1654 /publish/data /app/data
|
|
COPY --from=geoip --chown=1654:1654 /tmp/geoip /app/geoip
|
|
# Outbound TLS (an https alert webhook, an https upstream) verifies a chain, and
|
|
# scratch ships no trust store. Static OpenSSL reads this path when told to.
|
|
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
|
|
USER 1654:1654
|
|
|
|
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt \
|
|
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 \
|
|
OPENWAF_SCHEMA=script
|
|
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
|
|
CMD ["/app/OpenWaf.Edge", "--healthcheck"]
|
|
|
|
ENTRYPOINT ["/app/OpenWaf.Edge"]
|