fikrialfanf commited on
Commit
43149fe
·
verified ·
1 Parent(s): 21c0980

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -5
Dockerfile CHANGED
@@ -1,14 +1,28 @@
 
1
  FROM python:3.10-slim
2
 
 
3
  WORKDIR /app
4
- COPY . /app
5
 
6
- RUN pip install --upgrade pip
7
- RUN pip install --no-cache-dir -r requirements.txt
 
 
8
 
9
- # Buat folder cache untuk model agar bisa ditulis
10
- RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache
 
 
11
 
 
 
 
 
 
 
 
 
12
  EXPOSE 7860
13
 
 
14
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Gunakan image Python yang ringan tapi tetap stabil
2
  FROM python:3.10-slim
3
 
4
+ # Set working directory di dalam container
5
  WORKDIR /app
 
6
 
7
+ # Set environment variable untuk cache model
8
+ ENV TRANSFORMERS_CACHE=/tmp/huggingface
9
+ ENV HF_HOME=/tmp/huggingface
10
+ ENV PYTHONUNBUFFERED=1
11
 
12
+ # Install dependencies dasar
13
+ RUN apt-get update && apt-get install -y \
14
+ git \
15
+ && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Salin semua file ke dalam container
18
+ COPY . .
19
+
20
+ # Install dependency Python
21
+ RUN pip install --no-cache-dir --upgrade pip && \
22
+ pip install --no-cache-dir fastapi uvicorn transformers torch huggingface_hub pydantic
23
+
24
+ # Expose port untuk Hugging Face Spaces (harus 7860)
25
  EXPOSE 7860
26
 
27
+ # Jalankan aplikasi FastAPI
28
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]