| # HF Space runs this as `sdk: docker` (see README frontmatter). We can't use | |
| # `sdk: gradio` because that runner imports a module-level `demo` and never | |
| # starts uvicorn — our app is a FastAPI server with Gradio *mounted* on top, so | |
| # it must be launched explicitly. Gradio stays mounted at "/", so the Space | |
| # still "uses Gradio". Local dev is unchanged: `python app.py`. | |
| FROM python:3.11-slim | |
| # HF Spaces execute as a non-root user (uid 1000); give it a writable home. | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /home/user/app | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| COPY --chown=user . . | |
| USER user | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # MODAL_URL/MODAL_TOKEN (text) and FLUX_URL/FLUX_TOKEN (comic art) are provided | |
| # as Space secrets; unset → mock text + no comic overlay (still fully playable). | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |