detectAI / Dockerfile
vivek1192's picture
Switch to runserver and remove app_port for debugging
7c19daf
# 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"]