Spaces:
Running
Running
File size: 1,053 Bytes
4eaffe7 1e384db 168d64c 4eaffe7 1e384db 4eaffe7 1e384db 4eaffe7 1e384db 4eaffe7 1e384db 4eaffe7 1e384db 4eaffe7 | 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 32 33 | # Gunakan versi Python yang stabil untuk library AI
FROM python:3.10-slim
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
libsm6 \
libxrender1 \
libxext6 \
&& rm -rf /var/lib/apt/lists/*
# Bikin user non-root sesuai aturan Hugging Face (Wajib)
RUN useradd -m -u 1000 user
USER user
# Set environment variables agar perintah Python terbaca
ENV PATH="/home/user/.local/bin:$PATH"
# Set folder kerja di dalam container
WORKDIR /app
# Salin file requirements terlebih dahulu untuk caching yang efisien
COPY --chown=user ./requirements.txt requirements.txt
# Install dependencies (tambahkan library sistem tambahan jika YOLO membutuhkannya)
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Salin SELURUH file proyek Anda (termasuk folder chroma_data dan model YOLO)
COPY --chown=user . /app
# Jalankan FastAPI di port 7860 (Wajib)
# PENTING: Jika file utama FastAPI Anda bernama api.py, ubah "app:app" menjadi "api:app"
CMD ["uvicorn", "backend.api:app", "--host", "0.0.0.0", "--port", "7860"] |