1. Multi-Stage Dockerfile: Compile in Stage 1, Ship Zero Source in Stage 2
Use a two-stage Docker build where Stage 1 compiles your FastAPI/Django repo into a single ChaCha20 + Native C binary, and Stage 2 copies only that stripped ELF64 executable into a minimal debian:bookworm-slim runtime image with zero Python source files or pip caches:
FROM python:3.12-slim AS builder
RUN apt-get update && apt-get install -y --no-install-recommends gcc libc6-dev
WORKDIR /src
COPY . .
RUN pip install --no-cache-dir -r requirements.txt pykevlar
ARG PYKEVLAR_LICENSE
RUN PYKEVLAR_LICENSE="$PYKEVLAR_LICENSE" pykevlar build server.py \
--protect app --mix-str --enable-bcc --anti-llm --outer -F -O /out
FROM debian:bookworm-slim
WORKDIR /srv
COPY --from=builder /out/server /srv/server
ENTRYPOINT ["/srv/server"]
Mount each enterprise tenant's 198-byte pyarmor.rkey via a Kubernetes Secret to enforce annual contract expiration 100% offline inside air-gapped VPCs.