fjarsra commited on
Commit
7da61c8
·
verified ·
1 Parent(s): 64f0ed1

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -0
Dockerfile ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 1. Gunakan Python 3.9 (Versi paling stabil untuk Scikit-Learn & Pandas)
2
+ FROM python:3.9
3
+
4
+ # 2. Set folder kerja di dalam container (Virtual Computer)
5
+ WORKDIR /code
6
+
7
+ # 3. Copy file requirements.txt terlebih dahulu
8
+ # (Tujuannya agar Docker bisa 'cache' proses install library, biar cepat kalau deploy ulang)
9
+ COPY ./requirements.txt /code/requirements.txt
10
+
11
+ # 4. Install library yang ada di requirements.txt
12
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
13
+
14
+ # 5. Copy seluruh sisa file proyek (folder app, model_artifacts, main.py, dll) ke dalam container
15
+ COPY . /code
16
+
17
+ # 6. Atur izin (Permissions)
18
+ # Hugging Face menjalankan aplikasi sebagai user 'non-root' (user ID 1000).
19
+ # Kita harus memberi izin akses ke folder cache agar aplikasi tidak error saat menulis file sementara.
20
+ RUN mkdir -p /code/cache
21
+ RUN chmod -R 777 /code
22
+
23
+ # Set Environment Variable untuk Cache (biar library ML gak bingung nyimpan cache dimana)
24
+ ENV XDG_CACHE_HOME=/code/cache
25
+
26
+ # 7. Perintah Menyalakan Server
27
+ # PENTING: Hugging Face WAJIB menggunakan port 7860. Jangan diganti ke 8000.
28
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]