File size: 1,189 Bytes
171eb01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485075a
 
 
 
171eb01
 
 
 
7c19daf
 
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
# Stage 1: Build React Frontend
FROM node:20-slim AS frontend-builder
WORKDIR /app/frontend

COPY frontend/package*.json ./
RUN npm ci

COPY frontend/ ./
RUN npm run build

# Stage 2: Python Backend
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies (GLIB for ReportLab/CV2 if needed)
RUN apt-get update && apt-get install -y \
    libglib2.0-0 \
    libpango-1.0-0 \
    libpangoft2-1.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Install Python Dependencies
COPY backend/requirements/production.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy Backend Code
COPY backend/ /app/backend/

# Copy Frontend Build to a location Django can find
COPY --from=frontend-builder /app/frontend/dist /app/backend/frontend_build

# Set Environment Variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV DJANGO_SETTINGS_MODULE=detect_backend.settings

# Run collectstatic to prepare static files for WhiteNoise
WORKDIR /app/backend
RUN python manage.py collectstatic --noinput

# Expose Port
EXPOSE 7860

# Run Gunicorn
# Run Django Dev Server (More reliable for debugging HF Spaces)
CMD ["python", "manage.py", "runserver", "0.0.0.0:7860"]