Spaces:
Running
Running
Upload Dockerfile
Browse files- Dockerfile +38 -27
Dockerfile
CHANGED
|
@@ -1,43 +1,54 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM python:3.10
|
| 3 |
|
| 4 |
-
#
|
| 5 |
USER root
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
python3-dev \
|
| 10 |
-
libsndfile1 \
|
| 11 |
ffmpeg \
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
USER user
|
| 17 |
ENV HOME=/home/user \
|
| 18 |
-
PATH
|
| 19 |
|
| 20 |
-
# Set working directory
|
| 21 |
WORKDIR $HOME/app
|
| 22 |
|
| 23 |
-
# Install pip 24.0
|
| 24 |
RUN pip install --no-cache-dir pip==24.0
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
COPY --chown=
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
COPY --chown=
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
RUN
|
| 35 |
-
# Example: ADD --chown=user https://<SOME_ASSET_URL> content/<SOME_ASSET_NAME>
|
| 36 |
|
| 37 |
-
# Expose port
|
| 38 |
EXPOSE 7860
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
CMD ["python", "app.py", "--api"]
|
| 42 |
-
# CMD ["python", "app.py"]
|
| 43 |
-
# CMD ["gradio", "app.py", "--api"]
|
|
|
|
| 1 |
+
# Gunakan base image dengan hash agar match cache Hugging Face
|
| 2 |
+
FROM python:3.10@sha256:875c3591e586f66aa65621926230925144920c951902a6c2eef005d9783a7ca7
|
| 3 |
|
| 4 |
+
# Gunakan root dulu buat install awal
|
| 5 |
USER root
|
| 6 |
+
|
| 7 |
+
# Pasang fakeroot + ubah apt-get, lalu buat user UID 1000
|
| 8 |
+
RUN apt-get update && apt-get install -y fakeroot && \
|
| 9 |
+
mv /usr/bin/apt-get /usr/bin/.apt-get && \
|
| 10 |
+
echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get "$@"' > /usr/bin/apt-get && \
|
| 11 |
+
chmod +x /usr/bin/apt-get && \
|
| 12 |
+
rm -rf /var/lib/apt/lists/* && \
|
| 13 |
+
useradd -m -u 1000 user
|
| 14 |
+
|
| 15 |
+
# Install dependencies umum untuk ML / Gradio / media processing
|
| 16 |
RUN apt-get update && apt-get install -y \
|
| 17 |
+
git \
|
| 18 |
+
git-lfs \
|
|
|
|
|
|
|
| 19 |
ffmpeg \
|
| 20 |
+
libsm6 \
|
| 21 |
+
libxext6 \
|
| 22 |
+
libgl1-mesa-glx \
|
| 23 |
+
cmake \
|
| 24 |
+
rsync \
|
| 25 |
+
&& rm -rf /var/lib/apt/lists/* && \
|
| 26 |
+
git lfs install
|
| 27 |
+
|
| 28 |
+
# Switch ke user Hugging Face standard (UID 1000)
|
| 29 |
USER user
|
| 30 |
ENV HOME=/home/user \
|
| 31 |
+
PATH=$HOME/.local/bin:$PATH
|
| 32 |
|
|
|
|
| 33 |
WORKDIR $HOME/app
|
| 34 |
|
| 35 |
+
# Install pip versi 24.0 secara eksplisit
|
| 36 |
RUN pip install --no-cache-dir pip==24.0
|
| 37 |
|
| 38 |
+
# Salin requirements.txt ke tempat sementara
|
| 39 |
+
COPY --chown=1000:1000 requirements.txt /tmp/pre-requirements.txt
|
| 40 |
+
|
| 41 |
+
# Install Python dependencies dari project
|
| 42 |
+
RUN pip install --no-cache-dir -r /tmp/pre-requirements.txt
|
| 43 |
|
| 44 |
+
# Salin seluruh kode project
|
| 45 |
+
COPY --link --chown=1000:1000 . .
|
| 46 |
|
| 47 |
+
# Simpan semua dependency ke freeze file (buat cache HF)
|
| 48 |
+
RUN pip freeze > /tmp/freeze.txt
|
|
|
|
| 49 |
|
| 50 |
+
# Expose port default Gradio / FastAPI
|
| 51 |
EXPOSE 7860
|
| 52 |
|
| 53 |
+
# Jalankan app Python
|
| 54 |
+
CMD ["python", "app.py", "--api"]
|
|
|
|
|
|