DEV Community

PyKevlar Labs
PyKevlar Labs

Posted on Originally published at pykevlar.com

Docker Containers Don't Hide Your Python Code: How Enterprise Clients 'docker cp' Your Entire Backend

When you close your first $25,000 enterprise self-hosted deal and push your private FastAPI or Django image to the client's registry, remember one rule: a Docker image is just a tar archive. Any engineer with host access can run docker export and copy every .py file, prompt template, and pricing heuristic in three seconds.

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"]
Enter fullscreen mode Exit fullscreen mode

Mount each enterprise tenant's 198-byte pyarmor.rkey via a Kubernetes Secret to enforce annual contract expiration 100% offline inside air-gapped VPCs.


Ship zero-.py distroless Docker images in GitHub Actions

PyKevlar Team unlocks unlimited Docker & CI builds ($59.25/yr Year 1 w/ LAUNCH25).

Top comments (0)