Spaces:
Sleeping

File size: 1,723 Bytes
7ac6163
 
 
 
 
 
5ee5954
 
7ac6163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a908b0
7ac6163
 
 
 
 
 
 
 
 
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# ============================================
# 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

# Uygulama kodu
COPY app ./app

# 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

# Hugging Face Spaces varsayılan port: 7860
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:7860/api/health || exit 1

# Başlat
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]