sikomo-forecast / Dockerfile
anoderb
fix: resolve build errors by adding build dependencies and limiting build memory
c428ab0
Raw
History Blame Contribute Delete
1.03 kB
# ── 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"]