Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +30 -17
Dockerfile
CHANGED
|
@@ -1,17 +1,30 @@
|
|
| 1 |
-
# Gunakan image Python yang ringan
|
| 2 |
-
FROM python:3.10-slim
|
| 3 |
-
|
| 4 |
-
# Set working directory
|
| 5 |
-
WORKDIR /app
|
| 6 |
-
|
| 7 |
-
# Salin dependensi
|
| 8 |
-
COPY requirements.txt .
|
| 9 |
-
|
| 10 |
-
# Install dependensi
|
| 11 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
-
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gunakan image Python yang ringan
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Salin dependensi
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
|
| 10 |
+
# Install dependensi
|
| 11 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
+
|
| 13 |
+
# Tambahkan user non-root untuk keamanan
|
| 14 |
+
RUN useradd -m -u 1000 user
|
| 15 |
+
|
| 16 |
+
# Buat cache directory yang bisa diakses oleh user
|
| 17 |
+
RUN mkdir -p /home/user/.cache/huggingface && chown -R user:user /home/user/.cache/huggingface
|
| 18 |
+
ENV HF_HOME=/home/user/.cache/huggingface
|
| 19 |
+
|
| 20 |
+
# Salin kode aplikasi setelah setting user
|
| 21 |
+
COPY . .
|
| 22 |
+
|
| 23 |
+
# Ubah hak akses direktori kerja
|
| 24 |
+
RUN chown -R user:user /app
|
| 25 |
+
|
| 26 |
+
# Gunakan user non-root
|
| 27 |
+
USER user
|
| 28 |
+
|
| 29 |
+
# Jalankan FastAPI
|
| 30 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|