killinchu-staging / Dockerfile
betterwithage's picture
fix(staging): mirror prod /app/* absolute layout (KILLINCHU_ROOT=/app, static, drones_db) — Doctrine v11
84a1dc9 verified
# syntax=docker/dockerfile:1
# SPDX-License-Identifier: Apache-2.0
# © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173
# Doctrine v11 — 749/14/163 — replay hash c7c0ba17
#
# killinchu STAGING HF Docker Space (Yachay / Perplexity Computer Agent, 2026-06-01).
# Pulls from the SAME SOURCE as prod: clones the prod HF Space repo at build time,
# mirrors its files into /app so prod serve.py's ABSOLUTE /app/* paths resolve
# identically to prod, then runs serve_staging.py with SZL_ENV=staging.
# Reachable at https://szlholdings-killinchu-staging.hf.space
# /api/killinchu/healthz reports env: "staging".
FROM python:3.12-slim
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates gnupg git && \
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Same dependency surface as prod killinchu.
RUN pip install --no-cache-dir \
"fastapi>=0.111.0,<1.0.0" \
"uvicorn[standard]>=0.29.0,<1.0.0" \
"httpx>=0.27.0,<1.0.0" \
"starlette>=0.37.0" \
"huggingface_hub>=0.25.0" \
"cryptography>=42.0.0" \
"lmdb>=1.4.0" \
"sqlite-vss>=0.1.2"
# Same source as prod: clone the prod HF Space repo (contains all per-file source).
# Pin via build-arg SZL_PROD_REF (default main) so a promote can stage an exact ref.
ARG SZL_PROD_REF=main
RUN git clone https://huggingface.co/spaces/SZLHOLDINGS/killinchu /app/prod-src && \
cd /app/prod-src && git checkout "${SZL_PROD_REF}"
# Mirror prod's per-file layout into /app: prod serve.py reads ABSOLUTE /app/* paths
# (STATIC_DIR=/app/static, /app/drones_db.json, etc.). Copying the whole prod tree
# into /app reproduces prod's `COPY <file> ./<file>` layout exactly, without modifying
# any prod file. (.git is excluded to keep the image lean.)
RUN cp -a /app/prod-src/. /app/ && rm -rf /app/.git
# Staging entrypoint wrapper (overlays env-aware /healthz BEFORE the SPA catch-all;
# imports prod app verbatim from /app/serve.py).
COPY serve_staging.py /app/serve_staging.py
ENV SZL_ENV=staging
ENV SZL_FLAGSHIP=killinchu
ENV KILLINCHU_ROOT=/app
ENV PYTHONPATH=/app
ENV PORT=7860
EXPOSE 7860
CMD ["python", "/app/serve_staging.py"]