I'm trying to build a base image for the pipeline with pre-installed dependencies. I'm using a multistage build approach in a Dockerfile like this:
base.dockerfile
FROM python:$PYTHON_BASE AS base
RUN deps="" \
&& apt update \
&& apt-get install -y --no-install-recommends $deps
FROM base AS building-python-dependencies
WORKDIR /app
RUN <<EOF
set -ex
pip install -U pdm \
&& pdm install --frozen-lockfile --no-editable # This create the .venv (Confirmed)
EOF
FROM base as final
COPY --from=building-python-dependencies /app/.venv /app/.venv # This step fail
ENV PATH=/app/.venv/bin:$PATH \
PYTHONPATH=/app/.venv/lib/python3.11/site-packages
I encounter the following error during the build process:
Step 16/19 : COPY --from=building-python-dependencies /app/.venv /app/.venv
Service 'base' failed to build: COPY failed: stat app/.venv: file does not exist