# Gunakan base image dengan hash agar match cache Hugging Face FROM python:3.10@sha256:875c3591e586f66aa65621926230925144920c951902a6c2eef005d9783a7ca7 # Gunakan root dulu buat install awal USER root # Pasang fakeroot + ubah apt-get, lalu buat user UID 1000 RUN apt-get update && apt-get install -y fakeroot && \ mv /usr/bin/apt-get /usr/bin/.apt-get && \ echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get "$@"' > /usr/bin/apt-get && \ chmod +x /usr/bin/apt-get && \ rm -rf /var/lib/apt/lists/* && \ useradd -m -u 1000 user # Install dependencies umum untuk ML / Gradio / media processing RUN apt-get update && apt-get install -y \ git \ git-lfs \ ffmpeg \ libsm6 \ libxext6 \ libgl1-mesa-glx \ cmake \ rsync \ && rm -rf /var/lib/apt/lists/* && \ git lfs install # Switch ke user Hugging Face standard (UID 1000) USER user ENV HOME=/home/user \ PATH=$HOME/.local/bin:$PATH WORKDIR $HOME/app # Install pip versi 24.0 secara eksplisit RUN pip install --no-cache-dir pip==24.0 # Salin requirements.txt ke tempat sementara COPY --chown=1000:1000 requirements.txt /tmp/pre-requirements.txt # Install Python dependencies dari project RUN pip install --no-cache-dir -r /tmp/pre-requirements.txt # Salin seluruh kode project COPY --link --chown=1000:1000 . . # Simpan semua dependency ke freeze file (buat cache HF) RUN pip freeze > /tmp/freeze.txt # Expose port default Gradio / FastAPI EXPOSE 7860 # Jalankan app Python CMD ["python3", "app.py", "--api"]