Spaces:
Sleeping
Sleeping
| # CUDA 12.1 runtime (torch==2.5.1+cu121 ile uyumlu) | |
| FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| PYTHONUNBUFFERED=1 | |
| # System deps: Python, FFmpeg, GL, git, ca-certs | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3 python3-pip python3-venv \ | |
| ffmpeg \ | |
| libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 \ | |
| git ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # python/pip alias | |
| RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \ | |
| update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 | |
| # Non-root kullanıcı | |
| RUN useradd -m -u 1000 -s /bin/bash appuser | |
| WORKDIR /app | |
| # Python deps (senin pinlerin) | |
| COPY requirements.txt /app/requirements.txt | |
| # PyTorch CUDA 12.1 wheels index | |
| ENV PIP_NO_CACHE_DIR=1 \ | |
| PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cu121 | |
| RUN pip install --upgrade pip && \ | |
| pip install --no-cache-dir -r /app/requirements.txt | |
| # Uygulama | |
| COPY app.py /app/app.py | |
| # HF cache -> non-root HOME (dokümana uygun yollar) | |
| ENV HOME=/home/appuser \ | |
| HF_HOME=/home/appuser/.cache/huggingface \ | |
| TRANSFORMERS_CACHE=/home/appuser/.cache/huggingface/transformers \ | |
| HUGGINGFACE_HUB_CACHE=/home/appuser/.cache/huggingface/hub \ | |
| HF_HUB_ENABLE_HF_TRANSFER=0 | |
| # Sahiplik | |
| RUN mkdir -p /home/appuser/.cache/huggingface/transformers /home/appuser/.cache/huggingface/hub && \ | |
| chown -R appuser:appuser /home/appuser/.cache /app | |
| # Streamlit (Docker Spaces $PORT kullanır) | |
| ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0 \ | |
| STREAMLIT_BROWSER_GATHER_USAGE_STATS=false | |
| EXPOSE 7860 | |
| # Non-root ile çalış | |
| USER appuser | |
| CMD bash -lc '\ | |
| streamlit run /app/app.py \ | |
| --server.port=${PORT:-7860} \ | |
| --server.address=0.0.0.0 \ | |
| --browser.gatherUsageStats=false' | |