sushilideaclan01's picture
.
5152c78
Raw
History Blame Contribute Delete
1.15 kB
# Multi-stage: build frontend, then run FastAPI + static frontend
# Hugging Face Spaces: set DATA_DIR=/tmp/amalfa-data (only /tmp is writable), port 7860
# --- Frontend build ---
FROM node:20-alpine AS frontend
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm ci --no-audit --no-fund
COPY frontend/ ./
RUN npm run build
# --- Backend + serve static ---
FROM python:3.12-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Backend deps
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Backend code
COPY backend/ ./
# Frontend build → app/static so FastAPI can serve it
COPY --from=frontend /app/frontend/dist ./app/static
# Hugging Face: writable dir (ephemeral on restart unless persistent storage is mounted)
ENV DATA_DIR=/tmp/amalfa-data \
CREATIVITY_EXAMPLES_DIR=/tmp/amalfa-data/creativity_examples
RUN mkdir -p /tmp/amalfa-data/creativity_examples
ENV PORT=7860
EXPOSE 7860
# Run from backend dir so `app` package resolves
WORKDIR /app
CMD uvicorn app.main:app --host 0.0.0.0 --port ${PORT}