File size: 1,529 Bytes
604e0d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748c488
604e0d1
 
 
 
 
 
 
 
 
aff287e
 
 
 
 
 
 
604e0d1
 
 
 
 
99de5ef
 
 
 
604e0d1
 
 
 
 
 
99de5ef
 
 
748c488
5eb5663
 
 
748c488
604e0d1
 
 
748c488
604e0d1
 
748c488
604e0d1
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
# Root-level Dockerfile

# Stage 1: Build React frontend
FROM node:18-alpine AS frontend-build

WORKDIR /app/frontend

COPY frontend/package.json frontend/package-lock.json ./
RUN npm install

COPY frontend/ ./
RUN npm run build


# Stage 2: Build Python backend + serve frontend with Nginx
FROM python:3.9-slim

# Set working directory
WORKDIR /app

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

# Copy backend code
COPY backend/ /app/backend


COPY model/ /app/model/

ENV TRANSFORMERS_CACHE=/app/model
ENV HF_HUB_OFFLINE=1
ENV TRANSFORMERS_OFFLINE=1

COPY --from=frontend-build /app/frontend/build /app/frontend_build

# Install nginx
RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*

# Copy global nginx config to override default one
COPY frontend/nginx.global.conf /etc/nginx/nginx.conf

# Copy nginx server block
COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf

# Link built frontend to nginx root
RUN rm -rf /usr/share/nginx/html && \
    ln -s /app/frontend_build /usr/share/nginx/html

# Create required writable directories
RUN mkdir -p /app/tmp/body /app/tmp/proxy /app/tmp/fastcgi /app/tmp/uwsgi /app/tmp/scgi /app/logs && \
    chmod -R 777 /app/tmp /app/logs

# Create log directory for NGINX
RUN mkdir -p /app/logs && chmod -R 777 /app/logs

# Copy start script
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Expose port 7860 for Hugging Face
EXPOSE 7860

# Start both backend and nginx
CMD ["/start.sh"]