taste-engine / Dockerfile
mucahitkantepe's picture
Cache model weights in bucket for fast cold starts
343fd3b
Raw History Blame Contribute Delete
1.16 kB
# --- Stage 1: Build frontend ---
FROM oven/bun:1 AS frontend-build
WORKDIR /app/frontend
COPY frontend/package.json frontend/bun.lock* ./
RUN bun install --frozen-lockfile
COPY frontend/ .
RUN bun run build
# --- Stage 2: Python runtime ---
FROM python:3.11-slim
# System deps for torch/PIL
RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python deps with pip (uv not available in slim image)
COPY pyproject.toml .
RUN pip install --no-cache-dir ".[browser]" 2>/dev/null || pip install --no-cache-dir . && \
pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
# Copy app code
COPY taste/ taste/
COPY backend/ backend/
COPY cli.py .
# Copy built frontend
COPY --from=frontend-build /app/frontend/dist frontend/dist
# Data directory — mounted from HF bucket at /data
ENV TASTE_DATA_DIR=/data
ENV HF_HOME=/data/cache/huggingface
ENV TRANSFORMERS_CACHE=/data/cache/huggingface
# HF Spaces expects port 7860
ENV PORT=7860
EXPOSE 7860
CMD ["python", "-m", "uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "7860"]