llm_council_prem / Dockerfile
LLM Council Deployer
Switch to Gunicorn with Uvicorn Worker
432a462
# Multi-stage build for Hugging Face Spaces
# Stage 1: Build Frontend
FROM node:20-slim AS frontend-builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
# Build the frontend assets to /app/frontend_build (as configured in vite.config.js)
RUN npm run build
# Stage 2: Python Backend
FROM python:3.11-slim-bookworm
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install uv for fast python dependency management
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# Copy project files
COPY . .
# Install Python dependencies
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN uv venv /opt/venv && uv pip install -r pyproject.toml
# Copy built frontend assets from Stage 1
COPY --from=frontend-builder /app/frontend_build /app/frontend_build
# Set env vars for HF and Production
ENV DJANGO_SETTINGS_MODULE=config.settings.hf
ENV PYTHONUNBUFFERED=1
ENV SECRET_KEY=django-insecure-deploy-key-change-in-prod
# Collect static files (will pull from /app/frontend_build into /app/staticfiles)
RUN python manage.py collectstatic --noinput
# Run migration and start server on port 7860
# Fix permissions for Hugging Face Spaces (runs as user 1000)
RUN chmod -R 777 /app
# Run migration and start server on port 7860 (using Gunicorn with Uvicorn worker for robustness)
CMD ["sh", "-c", "python manage.py migrate && gunicorn config.asgi:application -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:7860 --log-level debug"]