File size: 1,030 Bytes
39018b4
 
 
 
 
c428ab0
 
39018b4
 
c428ab0
39018b4
 
 
 
c428ab0
39018b4
 
 
 
c428ab0
 
39018b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ── STAGE 1: Build Frontend (Next.js) ──
FROM node:20-alpine AS builder
WORKDIR /app/frontend
COPY frontend/ ./
RUN npm install
# Batasi memori build agar tidak error di HF
ENV NODE_OPTIONS="--max-old-space-size=2048"
RUN npm run build

# ── STAGE 2: Setup Backend ──
FROM python:3.10-slim
RUN useradd -m -u 1000 user
WORKDIR /app

# Tambahkan build-essential untuk library ML (Prophet/XGBoost)
RUN apt-get update && apt-get install -y \
    libgomp1 \
    gcc \
    g++ \
    make \
    python3-dev \
    curl \
    && rm -rf /var/lib/apt/lists/*

COPY --chown=user backend/requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip \
 && pip install --no-cache-dir -r requirements.txt

COPY --chown=user backend/ ./
RUN mkdir -p /app/models && chown -R user:user /app/models
RUN mkdir -p /app/static && chown -R user:user /app/static
COPY --chown=user --from=builder /app/frontend/out /app/static

USER user
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]