File size: 1,496 Bytes
2864f3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Multi-stage build for optimized unified (frontend + backend) deployment
FROM python:3.11-slim as builder

WORKDIR /app

# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Copy and install requirements
COPY frontend/requirements.txt requirements.txt
COPY backend/requirements.txt backend_requirements.txt

RUN pip install --upgrade pip setuptools wheel && \
    pip install --no-cache-dir -r requirements.txt && \
    pip install --no-cache-dir -r backend_requirements.txt

# Final stage
FROM python:3.11-slim

WORKDIR /app

# Install runtime dependencies for executing multi-language code and Nginx for routing
RUN apt-get update && apt-get install -y --no-install-recommends \
    nodejs \
    npm \
    g++ \
    default-jdk \
    dnsutils \
    curl \
    nginx \
    && rm -rf /var/lib/apt/lists/*

# Copy Python packages from builder
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin

# Copy application files
COPY frontend/ frontend/
COPY backend/ backend/
COPY start.sh start.sh
COPY nginx.conf /etc/nginx/nginx.conf

# Make start script executable
RUN chmod +x start.sh

# Expose the single proxy port (7860 for Hugging Face or Railway dynamic PORT)
EXPOSE 7860

# Proxy Configuration
ENV PORT=7860

# Run both Streamlit app and FastAPI using the wrapper script
CMD ["./start.sh"]