Enterprise-AI-Copilot / Dockerfile
Punit1's picture
Initial commit
939c0c0
Raw
History Blame Contribute Delete
1.88 kB
# =============================================================
# 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 \
"]