embodied-efficiency / Dockerfile
LaelaZ's picture
Rebuild as a Docker Space: FastAPI + Jinja2 + htmx deploy console (interactive Pareto + live supervisor), instrument-panel design
3cc2706 verified
raw
history blame contribute delete
807 Bytes
# Single-stage, slim image for one deployable service (FastAPI + Jinja2 + htmx).
FROM python:3.12-slim
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# Install dependencies first to leverage layer caching.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the application.
COPY app ./app
# Run as a non-root user (HF Spaces convention: uid 1000).
RUN useradd --create-home --uid 1000 appuser && chown -R appuser /app
USER appuser
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:7860/health').status==200 else 1)"
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]