dataforge-playground / Dockerfile
Praneshrajan15's picture
feat: serve frontend from HF Space (same-origin)
fe6681f verified
# DataForge Playground - Multi-stage Docker build for HF Spaces.
FROM python:3.12-slim AS builder
WORKDIR /build
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc g++ && \
rm -rf /var/lib/apt/lists/*
COPY playground/api/requirements.txt /build/requirements.txt
RUN pip install --no-cache-dir -r /build/requirements.txt
COPY pyproject.toml /build/dataforge_src/pyproject.toml
COPY README_MAIN.md /build/dataforge_src/README.md
COPY dataforge/ /build/dataforge_src/dataforge/
COPY constitutions/ /build/dataforge_src/constitutions/
RUN pip install --no-cache-dir /build/dataforge_src
FROM python:3.12-slim
RUN useradd -m -u 1000 user
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /build/dataforge_src/constitutions /usr/local/lib/python3.12/site-packages/constitutions
COPY playground/api/app.py /home/user/app/app.py
COPY playground/api/samples/ /home/user/app/samples/
COPY playground/web/ /home/user/app/web/
USER user
WORKDIR /home/user/app
EXPOSE 7860
ENV PORT=7860
ENV DATAFORGE_PLAYGROUND_DEV=0
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "5"]