Spaces:
Sleeping
Sleeping
python 3.12버전의 Spaces에 꼭 맞는 llama-cpp-python 빌드하기
Browse files
Dockerfile
CHANGED
|
@@ -1,42 +1,43 @@
|
|
| 1 |
-
# 1. 우분투 24.04 기반 이미지 사용 (GLIBC 2.39
|
| 2 |
FROM ubuntu:24.04
|
| 3 |
|
| 4 |
-
# 2. 필요한 기본 패키지 설치 (
|
| 5 |
-
RUN apt-get update && \
|
| 6 |
apt-get install -y \
|
| 7 |
software-properties-common \
|
| 8 |
build-essential \
|
| 9 |
-
gcc
|
| 10 |
-
python3
|
| 11 |
-
curl git
|
| 12 |
-
ln -sf /usr/bin/python3.9 /usr/bin/python3 && \
|
| 13 |
-
ln -sf /usr/bin/pip3 /usr/bin/pip && \
|
| 14 |
-
python3 -m pip install --upgrade pip setuptools wheel
|
| 15 |
|
| 16 |
-
# 3.
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
# 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
WORKDIR /app
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
RUN useradd -m -u
|
| 23 |
RUN chown -R user:user /app
|
| 24 |
USER user
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
ENV HF_HOME /app/huggingface_cache
|
| 28 |
-
ENV PATH="/home/user/.local/bin:${PATH}"
|
| 29 |
-
|
| 30 |
-
# 7. requirements.txt 파일과 wheel 파일을 복사.
|
| 31 |
COPY ./requirements.txt requirements.txt
|
| 32 |
-
COPY ./llama_cpp_python-0.3.11-cp39-cp39-linux_x86_64.whl .
|
|
|
|
| 33 |
|
| 34 |
-
# 8. llama-cpp-python을 wheel 파일로 설치 후 나머지 라이브러리
|
| 35 |
-
RUN pip install --no-cache-dir ./llama_cpp_python-0.3.11-cp39-cp39-linux_x86_64.whl
|
|
|
|
| 36 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 37 |
|
| 38 |
-
# 9. 나머지 모든 소스 코드를 작업 폴더에
|
| 39 |
COPY . /app
|
| 40 |
|
| 41 |
-
# 10. 모든 준비가 끝나면, 서버를
|
| 42 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# 1. 우분투 24.04 기반 이미지 사용 (GLIBC 2.39 포함, Python 3.12 내장)
|
| 2 |
FROM ubuntu:24.04
|
| 3 |
|
| 4 |
+
# 2. 필요한 기본 패키지 설치 (빌드 도구, 기타 필수 라이브러리 / 파이썬은 이미 내장됨)
|
| 5 |
+
RUN apt-get update && apt-get upgrade -y && \
|
| 6 |
apt-get install -y \
|
| 7 |
software-properties-common \
|
| 8 |
build-essential \
|
| 9 |
+
gcc g++ cmake \
|
| 10 |
+
python3-venv python3-dev python3-pip \
|
| 11 |
+
curl git
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# 3. 가상환경 생성 및 pip, setuptools, wheel 업그레이드
|
| 14 |
+
RUN python3 -m venv /opt/venv && \
|
| 15 |
+
/opt/venv/bin/pip install --upgrade pip setuptools wheel
|
| 16 |
|
| 17 |
+
# 4. 환경 변수 설정 (가상환경 활성화)
|
| 18 |
+
ENV PATH="/opt/venv/bin:${PATH}"
|
| 19 |
+
ENV HF_HOME=/app/huggingface_cache
|
| 20 |
+
|
| 21 |
+
# 5. 컨테이너 내부에 코드를 저장할 작업 폴더를 만듦
|
| 22 |
WORKDIR /app
|
| 23 |
|
| 24 |
+
# 6. 보안을 위해 권한이 제한된 새로운 사용자(user)를 생성하고 소유권을 이전
|
| 25 |
+
RUN useradd -m -u 1010 user
|
| 26 |
RUN chown -R user:user /app
|
| 27 |
USER user
|
| 28 |
|
| 29 |
+
# 7. requirements.txt 파일과 wheel 파일을 복사
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
COPY ./requirements.txt requirements.txt
|
| 31 |
+
# COPY ./llama_cpp_python-0.3.11-cp39-cp39-linux_x86_64.whl .
|
| 32 |
+
COPY ./llama_cpp_python-0.3.11-cp312-cp312-linux_x86_64.whl .
|
| 33 |
|
| 34 |
+
# 8. llama-cpp-python을 wheel 파일로 설치 후 나머지 라이브러리 설치 (가상환경 내 pip 사용)
|
| 35 |
+
# RUN pip install --no-cache-dir ./llama_cpp_python-0.3.11-cp39-cp39-linux_x86_64.whl
|
| 36 |
+
RUN pip install --no-cache-dir ./llama_cpp_python-0.3.11-cp312-cp312-linux_x86_64.whl
|
| 37 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 38 |
|
| 39 |
+
# 9. 나머지 모든 소스 코드를 작업 폴더에 복사
|
| 40 |
COPY . /app
|
| 41 |
|
| 42 |
+
# 10. 모든 준비가 끝나면, 서버를 실행
|
| 43 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
llama_cpp_python-0.3.11-cp312-cp312-linux_x86_64.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:de32a74bbe6ed1721f8abfad2d01ac96960b297302ed1d0a2710b75cf8bf6d23
|
| 3 |
+
size 4176439
|