Japrax19 commited on
Commit
6cfe5b0
·
verified ·
1 Parent(s): c083fb4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -3
Dockerfile CHANGED
@@ -1,10 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.10-slim
2
 
 
 
 
 
 
 
 
3
  WORKDIR /app
4
 
5
- COPY requirements.txt .
 
6
  RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- COPY . .
 
9
 
10
- CMD ["python", "app.py"]
 
 
1
+ # Gunakan multi-stage build: pertama build frontend, lalu backend
2
+
3
+ # Stage 1: Build React frontend
4
+ FROM node:18 AS frontend-builder
5
+ WORKDIR /app
6
+ COPY frontend/package*.json ./
7
+ RUN npm install
8
+ COPY frontend/ .
9
+ RUN npm run build
10
+
11
+ # Stage 2: Backend + serving static files
12
  FROM python:3.10-slim
13
 
14
+ # Install system dependencies (untuk terminal)
15
+ RUN apt-get update && apt-get install -y \
16
+ bash \
17
+ git \
18
+ npm \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
  WORKDIR /app
22
 
23
+ # Copy backend code
24
+ COPY backend/requirements.txt .
25
  RUN pip install --no-cache-dir -r requirements.txt
26
+ COPY backend/ .
27
+
28
+ # Copy built frontend from stage 1
29
+ COPY --from=frontend-builder /app/dist /app/static
30
+
31
+ # Buat user non-root (wajib untuk HF)
32
+ RUN useradd -m -u 1000 user
33
+ USER user
34
+ ENV HOME=/home/user \
35
+ PATH=/home/user/.local/bin:$PATH
36
+
37
+ # Hugging Face cache
38
+ ENV HF_HOME=/home/user/.cache/huggingface
39
+ ENV TOKENIZERS_PARALLELISM=false
40
 
41
+ # Expose port yang digunakan HF (7860)
42
+ EXPOSE 7860
43
 
44
+ # Jalankan FastAPI dengan uvicorn
45
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]