feliksius commited on
Commit
5bb17ea
·
verified ·
1 Parent(s): 7295b0c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -19
Dockerfile CHANGED
@@ -1,31 +1,25 @@
1
- # Gunakan image Python resmi
2
- FROM python:3.9-slim@sha256:bef8d69306a7905f55cd523f5604de1dde45bbf745ba896dbb89f6d15c727170
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Buat direktori cache dan atur izin
8
- RUN mkdir -p /app/cache && chmod -R 777 /app/cache
9
-
10
- # Bersihkan cache lama (untuk mencegah error izin)
11
- RUN rm -rf /app/cache/* && chmod -R 777 /app/cache
12
-
13
- # Upgrade pip untuk kompatibilitas paket terbaru
14
- RUN pip install --upgrade pip
15
-
16
- # Salin requirements.txt dan install dependensi
17
  COPY requirements.txt .
 
 
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
- # Salin kode aplikasi
21
- COPY app.py .
22
 
23
- # Atur environment variable untuk cache
24
  ENV HF_HOME=/app/cache
25
  ENV TRANSFORMERS_CACHE=/app/cache
 
26
 
27
- # Pastikan izin direktori cache tetap benar sebelum menjalankan aplikasi
28
- RUN chmod -R 777 /app/cache
29
 
30
- # Jalankan aplikasi dengan uvicorn
31
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use a lightweight Python base image
2
+ FROM python:3.10-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Copy requirements.txt
 
 
 
 
 
 
 
 
 
8
  COPY requirements.txt .
9
+
10
+ # Install dependencies
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Copy application code
14
+ COPY . .
15
 
16
+ # Set environment variables for Hugging Face cache
17
  ENV HF_HOME=/app/cache
18
  ENV TRANSFORMERS_CACHE=/app/cache
19
+ ENV USE_QUANTIZATION=0 # Set to 1 if using quantization and GPU is available
20
 
21
+ # Expose port for FastAPI
22
+ EXPOSE 8000
23
 
24
+ # Run the FastAPI app with uvicorn
25
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]