Warum werden Pakete nicht in meinem mehrstufigen Docker-Build mit PIP installiert?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Warum werden Pakete nicht in meinem mehrstufigen Docker-Build mit PIP installiert?

by Anonymous » 20 Apr 2025, 03:04

Ich arbeite an einem Python-Projekt mit einem mehrstufigen Docker-Build und lief in ein Problem, bei dem Pydantic (nur Beispiel) nicht installiert ist, obwohl PIP vorhanden ist und im endgültigen Bild arbeitet.project-root/
├── docker-compose.yml
├── vector_db_service/
│ ├── app/
│ │ └── __init__.py
│ ├── Dockerfile
│ ├── pyproject.toml
│ ├── .env
< /code>
docker-compose.yml:
services:
vector_db_service:
container_name: vector_db_service
build:
context: ./vector_db_service
dockerfile: Dockerfile
command: tail -f /dev/null
env_file:
- ./vector_db_service/.env
< /code>
dockerfile: < /p>
# Build stage
FROM python:3.13-slim AS compile-image

RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

RUN pip install --no-cache-dir --upgrade pip

# Final image
FROM python:3.13-slim

COPY --from=compile-image /opt/venv /opt/venv

WORKDIR /app
ENV HOME=/app
ENV PATH="/opt/venv/bin:$PATH"

RUN addgroup --system app && adduser --system --group app

COPY . .

RUN chown -R app:app $HOME
RUN chown -R app:app "/opt/venv/"

USER app

RUN pip install -e pydantic

< /code>
Die letzte Zeile, pip install -e pydantic, installiert nichts. Der Build endet erfolgreich, aber das Paket ist nicht installiert. Ich habe bestätigt, dass PIP im endgültigen Bild installiert ist. Muss ich aus dem Projektrouch installieren, oder fehlt mir etwas im Build -Prozess? < /P>
Jede Hilfe wäre sehr geschätzt. Vielen Dank im Voraus!

Top