Hey all,
I have a poetry project which needs a library called pyoma-2 (^1.2.0). This package uses vtk. My docker image does not build because of this error I get:
138.0 Unable to find installation candidates for vtk (9.3.1)
138.0
138.0 at /opt/poetry/venv/lib/python3.10/site-packages/poetry/installation/chooser.py:74 in choose_for
138.0 70│
138.0 71│ links.append(link)
138.0 72│
138.0 73│ if not links:
138.0 → 74│ raise RuntimeError(f"Unable to find installation candidates for {package}")
138.0 75│
138.0 76│ # Get the best link
138.0 77│ chosen = max(links, key=lambda link: self._sort_key(package, link))
138.0 78│
138.0
138.0 Cannot install vtk.
138.0
------
1 warning found (use docker --debug to expand):
- UndefinedVar: Usage of undefined variable '$PYTHONPATH' (line 34)
Dockerfile:66
--------------------
65 | # install runtime deps to $VIRTUAL_ENV
66 | >>> RUN --mount=type=cache,target=/root/.cache \
67 | >>> poetry lock && poetry install --no-root --only main
68 | COPY client/ client/
--------------------
ERROR: failed to solve: process "/bin/sh -c poetry lock && poetry install --no-root --only main" did not complete successfully: exit code: 1
################################
# PYTHON-BASE
# Sets up all our shared environment variables
################################
FROM python:3.10.14-slim AS python-base
# Python
ENV PYTHONUNBUFFERED=1 \
# pip
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
\
# Poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
POETRY_VERSION=1.8.3 \
# make poetry install to this location
POETRY_HOME="/opt/poetry" \
# do not ask any interactive question
POETRY_NO_INTERACTION=1 \
# never create virtual environment automaticly, only use env prepared by us
POETRY_VIRTUALENVS_CREATE=false \
\
# this is where our requirements + virtual environment will live
VIRTUAL_ENV="/venv"
# prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$VIRTUAL_ENV/bin:$PATH"
# prepare virtual env
RUN python -m venv $VIRTUAL_ENV
# working directory and Python path
WORKDIR /app
ENV PYTHONPATH="/app:$PYTHONPATH"
################################
# BUILDER-BASE
# Used to build deps + create our virtual environment
################################
FROM python-base AS builder-base
RUN apt-get update && \
apt-get install -y \
apt-transport-https \
gnupg \
ca-certificates \
build-essential \
git \
nano \
curl \
docker.io \
net-tools \
&& apt-get clean
# install poetry - respects $POETRY_VERSION & $POETRY_HOME
# The --mount will mount the buildx cache directory to where
# Poetry and Pip store their cache so that they can re-use it
RUN --mount=type=cache,target=/root/.cache \
curl -sSL https://install.python-poetry.org | python -
# used to init dependencies
WORKDIR /app
COPY poetry.lock pyproject.toml ./
# install runtime deps to $VIRTUAL_ENV
RUN --mount=type=cache,target=/root/.cache \
poetry lock && poetry install --no-root --only main
COPY client/ client/
################################
# DEVELOPMENT
# Image used during development / testing
################################
FROM builder-base AS development
WORKDIR /app
# quicker install as runtime deps are already installed
RUN --mount=type=cache,target=/root/.cache \
poetry lock && poetry install --no-root --with test,lint
CMD ["bash"]
################################
# PRODUCTION
# Final image used for runtime
################################
FROM python-base AS production
RUN apt-get update && \
apt-get install -y \
nano \
curl \
docker.io \
net-tools \
libgl1 \
libglib2.0-0 \
&& apt-get clean
# copy in our built poetry + venv
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
COPY --from=builder-base $VIRTUAL_ENV $VIRTUAL_ENV
WORKDIR /app
COPY poetry.lock pyproject.toml ./
COPY client/ client/
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["python", "run_job.py"]
Not really sure what I am doing wrong. I appreciate any help.
best, teflon