File size: 2,698 Bytes
8813834
 
 
 
 
f7853ca
 
8813834
 
 
 
 
 
 
f7853ca
 
8813834
 
 
 
 
 
 
 
 
 
 
 
f7853ca
8813834
 
 
 
f7853ca
 
8813834
 
 
f7853ca
 
8813834
 
 
f7853ca
8813834
f7853ca
 
8813834
 
 
 
 
 
 
 
 
fbe61df
8813834
 
 
fbe61df
8813834
 
 
f7853ca
8813834
 
 
f7853ca
 
8813834
 
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
61
62
63
64
65
66
67
68
69
70
71
72
# ============================================================================
# UNIFIED DOCKERFILE FOR HUGGING FACE DEPLOYMENT
# Intel Image Classifier - Django Backend + React Frontend + ML Models
# ============================================================================

FROM python:3.12-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PATH=/app/node_modules/.bin:$PATH \
    NODE_ENV=production \
    DEBUG=False

WORKDIR /app

# ============================================================================
# SYSTEM DEPENDENCIES
# ============================================================================
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    gnupg \
    && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y --no-install-recommends \
    nodejs \
    build-essential \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# ============================================================================
# PYTHON DEPENDENCIES
# ============================================================================
COPY backend/requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# ============================================================================
# PROJECT FILES
# ============================================================================
COPY . .

# ============================================================================
# BUILD FRONTEND (React)
# ============================================================================
WORKDIR /app/frontend
RUN npm install --omit=dev
RUN npm run build

# ============================================================================
# PREPARE BACKEND
# ============================================================================
WORKDIR /app/backend/api

# Create necessary directories for Django
RUN mkdir -p static media logs

# Collect static files during build (not runtime)
RUN python manage.py collectstatic --noinput --clear || echo "Warning: Static files collection failed during build"

# Copy frontend build to Django static directory during build
RUN mkdir -p static/frontend && \
    cp -r /app/frontend/build/* static/frontend/ 2>/dev/null || echo "Warning: Frontend build copy failed during build"

# Make entrypoint executable
RUN chmod +x /app/backend/api/entrypoint.sh

# ============================================================================
# EXPOSE & RUN
# ============================================================================
EXPOSE 7860

# Use entrypoint script for proper initialization
ENTRYPOINT ["/app/backend/api/entrypoint.sh"]