fix(backend): Dockerfile editable install 제거 + PYTHONPATH
기존 `pip install -e .` 두 줄은 두 가지 이유로 실패:
1. `app/` 가 COPY 되기 전 단계라 setuptools packages.find 결과가
비어 editable 빌드가 무의미.
2. Ubuntu 22.04 의 기본 pip 가 PEP 660 build_editable hook 을
요구하지만, build isolation 환경의 setuptools 가 노출 안 함
("build backend is missing the 'build_editable' hook").
수정:
- editable install 자체를 제거. 런타임은 PYTHONPATH=/app 으로
`app.*` import 가 동작하므로 프로젝트를 wheel 로 설치할 필요 없음.
- 의존성은 tomllib 로 pyproject.toml 에서 직접 추출해 단일 `pip
install -r` 로 설치. ML 휠 (chronos/lgbm/transformers ...) 레이어
캐싱이 pyproject.toml 단위로 유지됨 → app 코드 변경시 재빌드 회피.
- COPY app ./app 은 deps 설치 뒤로 유지 (캐시 분리).
This commit is contained in:
@@ -7,6 +7,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
PYTHONPATH=/app \
|
||||
TZ=Asia/Seoul
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
@@ -20,11 +21,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
WORKDIR /app
|
||||
|
||||
COPY pyproject.toml ./
|
||||
|
||||
# Install PyTorch (CUDA 12.1 wheels) first so the rest of deps don't downgrade it.
|
||||
RUN pip install --extra-index-url https://download.pytorch.org/whl/cu121 \
|
||||
torch==2.3.1 torchvision==0.18.1
|
||||
RUN pip install --no-deps -e . || true
|
||||
RUN pip install -e .
|
||||
|
||||
# Install runtime deps from pyproject.toml WITHOUT installing the project itself.
|
||||
# - 이전 `pip install -e .` 은 app/ 가 아직 COPY 되기 전이라 packages.find 결과가 비고,
|
||||
# ubuntu 22.04 기본 pip 의 PEP 660 editable hook 과 충돌해 실패했음.
|
||||
# - 런타임에는 PYTHONPATH=/app 으로 `app.*` 임포트가 동작하므로 프로젝트 설치 자체가 불필요.
|
||||
# - deps 만 별도 레이어로 캐시 → 코드 변경 시 ML 휠 재빌드 회피.
|
||||
RUN python -c "import tomllib; \
|
||||
deps = tomllib.load(open('pyproject.toml','rb'))['project']['dependencies']; \
|
||||
open('/tmp/reqs.txt','w').write('\n'.join(deps))" \
|
||||
&& pip install -r /tmp/reqs.txt
|
||||
|
||||
COPY app ./app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user