File size: 707 Bytes
5395025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Gunakan image Python yang ringan
FROM python:3.10-slim

# Set working directory
WORKDIR /app

# Salin dependensi
COPY requirements.txt .

# Install dependensi
RUN pip install --no-cache-dir -r requirements.txt

# Tambahkan user non-root untuk keamanan
RUN useradd -m -u 1000 user

# Buat cache directory yang bisa diakses oleh user
RUN mkdir -p /home/user/.cache/huggingface && chown -R user:user /home/user/.cache/huggingface
ENV HF_HOME=/home/user/.cache/huggingface

# Salin kode aplikasi setelah setting user
COPY . .

# Ubah hak akses direktori kerja
RUN chown -R user:user /app

# Gunakan user non-root
USER user

# Jalankan FastAPI
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]