File size: 1,429 Bytes
32dfa8a
264be65
32dfa8a
825a7a0
32dfa8a
 
6d446d3
34244b7
32dfa8a
 
 
 
 
 
688cd6a
2dd8f73
beccc47
6909020
2dd8f73
 
beccc47
6909020
 
2dd8f73
6909020
3b380fb
2dd8f73
 
 
 
688cd6a
32dfa8a
 
825a7a0
2dd8f73
 
688cd6a
2dd8f73
 
 
6909020
32dfa8a
 
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
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}"]