File size: 1,882 Bytes
939c0c0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | # =============================================================
# Enterprise AI Copilot Platform β Hugging Face Spaces
# Single-container Dockerfile (backend + frontend static files)
# =============================================================
# ββ Stage 1: Build React Frontend ββββββββββββββββββββββββββββ
FROM node:18-alpine AS frontend-build
WORKDIR /frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ .
# Pass the API URL for the static build (same container = same origin)
ENV VITE_API_URL=""
RUN npm run build
# ββ Stage 2: Python Backend βββββββββββββββββββββββββββββββββββ
FROM python:3.10-slim
# Install system deps
RUN apt-get update && apt-get install -y \
gcc g++ libpq-dev curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python dependencies
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend source
COPY backend/ .
COPY agents/ /agents/
COPY services/ /services/
COPY scripts/ /scripts/
# Copy built frontend static files
COPY --from=frontend-build /frontend/dist /app/static
# Create data directories
RUN mkdir -p /app/data /uploads
# Environment variables for HF Spaces
ENV DEPLOY_MODE=huggingface
ENV PYTHONPATH="/app:/agents:/services"
# SQLite by default (no REDIS_URL = in-memory cache)
ENV DATABASE_URL=sqlite+aiosqlite:///./data/copilot.db
# Note: Set GROQ_API_KEY and SECRET_KEY in HF Space secrets
# HF Spaces runs on port 7860
EXPOSE 7860
# Startup: init DB + seed data + serve
CMD ["sh", "-c", "\
python -c 'import asyncio; from app.core.database import init_db; asyncio.run(init_db())' && \
python /scripts/seed_data.py --hf-mode 2>/dev/null || true && \
uvicorn app.main:app --host 0.0.0.0 --port 7860 \
"]
|