Alvin2707's picture
Update Dockerfile
5395025 verified
raw
history blame contribute delete
707 Bytes
# 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"]