File size: 1,958 Bytes
2c60697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ──────────────────────────────────────────────
# Stage 1 – Build Angular frontend
# ──────────────────────────────────────────────
FROM node:20-alpine AS frontend-build

WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ ./
RUN npx ng build --configuration=production

# ──────────────────────────────────────────────
# Stage 2 – Production image (nginx + FastAPI)
# ──────────────────────────────────────────────
FROM python:3.12-slim

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

# ── Python backend ───────────────────────────
WORKDIR /app
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY backend/ ./backend/

# ── Frontend static files ────────────────────
COPY --from=frontend-build /app/frontend/dist/frontend/browser /usr/share/nginx/html

# ── Nginx config ─────────────────────────────
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Remove default nginx site that might conflict
RUN rm -f /etc/nginx/sites-enabled/default

# ── Supervisor config ────────────────────────
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Hugging Face Spaces uses port 7860
EXPOSE 7860

CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]