llm_council_prem / Dockerfile.hf
LLM Council Deployer
frontend fix
df4085c
# 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. This output should go to staticfiles or similar.
# Assuming standard Vite build output to './dist' or similar, we need to ensure Django can find it.
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=/app/.venv
ENV PATH="/app/.venv/bin:$PATH"
RUN uv venv && uv pip install --system -r pyproject.toml || uv pip install --system .
# Copy built frontend assets from Stage 1
# Assuming 'npm run build' outputs to a folder that Django's collectstatic can pick up
# For Vite + Django, typically we might sync 'dist/assets' to 'assets' or 'static'
# We will need to double check where 'npm run build' puts files vs where Django looks.
# For this setup:
# 1. We'll copy the source assets just in case or better yet, verify build output.
# 2. But simpler: Just install Node in this image too? No, multi-stage is cleaner.
# Let's assume we copy the 'assets/js/dist' or whatever Vite produces.
# ACTUALLY: The current setup serves via Vite Dev Server. For Prod, we need 'npm run build'.
# Vite config usually outputs to 'dist'. We need Django to serve 'dist' as static.
COPY --from=frontend-builder /app/frontend_build /app/frontend_build
# Set env vars for HF
ENV DJANGO_SETTINGS_MODULE=config.settings.hf
ENV PYTHONUNBUFFERED=1
# Collect static files
RUN python manage.py collectstatic --noinput
# Run migration and start server on port 7860
CMD ["sh", "-c", "python manage.py migrate && gunicorn config.wsgi:application --bind 0.0.0.0:7860"]