crowncode-backend / Dockerfile
Rthur2003's picture
fix: correct AURIS model repository ID in Dockerfile, startup script, and upload script
e8c02eb
# ============================================
# CrownCode Backend - Hugging Face Spaces
# ============================================
# SDK: Docker | Hardware: CPU Basic (Free)
# ============================================
# Python 3.11 slim imajını kullan
FROM python:3.11-slim
# Çalışma dizini
WORKDIR /app
# Ortam değişkenleri
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
TRANSFORMERS_CACHE=/app/.cache/huggingface \
HF_HOME=/app/.cache/huggingface \
TORCH_HOME=/app/.cache/torch
# Sistem bağımlılıkları + FFmpeg
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libsndfile1 \
git \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Cache dizinleri
RUN mkdir -p /app/.cache/huggingface /app/.cache/torch \
&& chmod -R 777 /app/.cache
# Requirements (önce kopyala - Docker cache için)
COPY requirements.txt .
# PyTorch CPU versiyonu + diğer paketler
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu \
&& pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir "huggingface-hub>=0.20.0"
# Uygulama kodu
COPY app ./app
COPY startup.py .
# Models dizini — startup.py çalışınca doldurulacak
RUN mkdir -p /app/models
# Hugging Face Spaces için non-root kullanıcı (güvenlik)
RUN useradd -m -u 1000 user \
&& chown -R user:user /app
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
AURIS_MODELS_REPO=Rthur2003/auris-models \
MODELS_DIR=/app/models
# Hugging Face Spaces varsayılan port: 7860
EXPOSE 7860
# Health check — model download ~2-3 dk sürebilir, start-period uzun
HEALTHCHECK --interval=30s --timeout=10s --start-period=180s --retries=5 \
CMD curl -f http://localhost:7860/api/health || exit 1
# Başlat: önce modelleri indir, sonra API'yi ayağa kaldır
CMD ["sh", "-c", "python startup.py && uvicorn app.main:app --host 0.0.0.0 --port 7860"]