61 lines
1.8 KiB
Plaintext
61 lines
1.8 KiB
Plaintext
FROM python:3.11-slim
|
|
|
|
LABEL description="Vector DB API Base Image - Cache Fixed"
|
|
LABEL version="cache-fixed-v1.0"
|
|
LABEL maintainer="admin@example.com"
|
|
|
|
# 환경 변수 설정
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
POETRY_NO_INTERACTION=1 \
|
|
POETRY_VENV_IN_PROJECT=true \
|
|
POETRY_VIRTUALENVS_CREATE=true \
|
|
POETRY_VIRTUALENVS_PATH=/home/appuser/.venv \
|
|
POETRY_CACHE_DIR=/home/appuser/.cache/pypoetry \
|
|
HF_HUB_CACHE=/home/appuser/.cache/huggingface \
|
|
TRANSFORMERS_CACHE=/home/appuser/.cache/transformers
|
|
|
|
# 시스템 패키지 설치
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential gcc g++ python3-dev \
|
|
curl wget ca-certificates git \
|
|
&& rm -rf /var/lib/apt/lists/* && apt-get clean
|
|
|
|
# pip 업그레이드
|
|
RUN python3.11 -m pip install --no-cache-dir --upgrade pip setuptools wheel
|
|
|
|
# 사용자 생성
|
|
RUN groupadd -g 1000 appuser && \
|
|
useradd -r -u 1000 -g 1000 -d /home/appuser -s /bin/bash appuser && \
|
|
mkdir -p /home/appuser && chown -R 1000:1000 /home/appuser
|
|
|
|
# 작업 디렉토리 설정
|
|
WORKDIR /home/appuser
|
|
RUN chown appuser:appuser /home/appuser
|
|
|
|
# 🔧 핵심: 고정된 pyproject.toml 생성
|
|
COPY pyproject.toml poetry.lock ./
|
|
RUN chown appuser:appuser pyproject.toml poetry.lock
|
|
|
|
# appuser로 전환
|
|
USER appuser
|
|
|
|
# 🔧 Poetry를 appuser로 설치
|
|
ENV PATH="/home/appuser/.local/bin:$PATH"
|
|
RUN curl -sSL https://install.python-poetry.org | python3.11 -
|
|
|
|
# 🔧 Poetry 환경 설정 (프로젝트 내 가상환경)
|
|
RUN poetry config virtualenvs.in-project true && \
|
|
poetry config virtualenvs.create true && \
|
|
poetry config cache-dir /home/appuser/.cache/pypoetry
|
|
|
|
# 🔧 의존성 설치
|
|
RUN poetry install --only=main --no-root
|
|
|
|
EXPOSE 8000
|
|
CMD ["poetry", "--version"]
|
|
|