Cannot seem to call poetry installed packages in Docker image (redhat)

5 days ago 3
ARTICLE AD BOX

I'll preface by saying I'm not familiar at all with any Redhat specific differences, but I'm running into what seems like it should be a simple issue. I have a Redhat 8 image and the following lines in the dockerfile (the image is from a work artifactory so I can't provide a direct example)

FROM docker-baseimages-local.**/redhat/ubi8:8.9 AS builder ARG WORKDIR="/home/python/app" ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 RUN dnf -y install \ python3.12 \ python3.12-pip \ python3.12-devel \ make \ gcc-c++ RUN python3.12 --version RUN mkdir -p ${WORKDIR} WORKDIR ${WORKDIR} COPY target/*.tar.gz ${WORKDIR}/ RUN tar -xvzf lunasearch-*.tar.gz --strip-components=1 RUN python3.12 -m venv ${WORKDIR}/venv ENV PATH="${WORKDIR}/venv/bin:$PATH" RUN . ./venv/bin/activate RUN pip3.12 install poetry RUN poetry --version RUN poetry install RUN uvicorn --version

All I'm doing is installing python 3.12, copying code files over, creating a virtual env, then installing everything with poetry install. All of this returns as successful, but when I try to test "uvicorn --version", it says the command cannot be found.

I'm not sure if there's something different about using poetry in a docker image that's causing this? Or if creating a virtual env in docker is causing an issue?

The commands work fine if I use poetry to install and run the app locally. I'm hoping I'm just missing something simple.

UPDATE: Adding "RUN poetry config virtualenvs.create false" to force poetry not to create it's own venv makes it past the build and works. However, doing it that way causes some issues if you're trying to slim down your image size by copying over only the bare minimum files between each builder image. But I'll take it for now- perhaps others can provide more insight into why this happened, I was just brute forcing it.

Read Entire Article