File size: 1,091 Bytes
b4a2e7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend ./
RUN npm run build

FROM python:3.10-slim

# Install Node.js
RUN apt-get update && apt-get install -y \
    curl \
    && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Setup Backend
COPY backend/requirements.txt backend/
RUN pip install --no-cache-dir -r backend/requirements.txt
COPY backend backend/

# Setup Frontend
COPY frontend/package*.json frontend/
WORKDIR /app/frontend
RUN npm install --omit=dev
COPY --from=frontend-builder /app/frontend/.next ./.next
COPY --from=frontend-builder /app/frontend/public ./public
# We need the source files for Next.js to run in production for App Router depending on setup, but mostly .next and node_modules are enough.
COPY frontend/next.config.mjs ./

WORKDIR /app

# Create a start script
COPY start.sh .
RUN chmod +x start.sh

# Expose the port Hugging Face expects
EXPOSE 7860

# Run both servers
CMD ["./start.sh"]