Spaces:
Build error
Build error
| FROM python:3.10-slim | |
| # Use Debian-slim (glibc) for compatibility with manylinux wheels on Hugging Face | |
| USER root | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| cmake \ | |
| git \ | |
| gcc \ | |
| g++ \ | |
| libgomp1 \ | |
| libopenblas-dev \ | |
| libstdc++6 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| ## 2. 사용자 설정 (user는 만들되, 설치는 root로 수행합니다) | |
| RUN useradd -m -u 1000 user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PIP_DEFAULT_TIMEOUT=120 | |
| WORKDIR $HOME/app | |
| # pip 업그레이드 (root 권한으로, 빌드 시 권한/경로 문제 방지) | |
| RUN pip install --no-cache-dir --upgrade pip | |
| # 3. requirements.txt 설치 (루트로 전역 설치) | |
| # llama-cpp-python은 requirements에서 제외되어야 합니다. | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # 4. llama-cpp-python: 가능한 경우 manylinux wheel을 사용하도록 --prefer-binary | |
| # If no wheel matches, this will build from source (cmake/python-dev provided above). | |
| RUN CMAKE_ARGS="-DLLAMA_BLAS=OFF -DLLAMA_CUBLAS=OFF" \ | |
| pip install --no-cache-dir --prefer-binary \ | |
| llama-cpp-python | |
| # 앱 소스 복사 및 소유자 변경, 이후 non-root로 실행 | |
| COPY --chown=user:user . . | |
| USER user | |
| # Use PORT env if provided by hosting (Hugging Face), fallback to 7860 | |
| CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860}"] |