Closed ydennisy closed 2 days ago
The goal of the plugin is to have poetry build
create wheels and tar.gz files that are pip installable. Thus a poetry build
doesn't have any effect to a subsequent poetry install
.
You could have a 2-stage Dockerfile, where you do the following in the build step (or you build the tar.gz/whl files outside docker in your CI/CD script):
FROM python:3.11-slim AS build
WORKDIR /app
COPY services ./services
COPY lib ./lib
RUN pip install poetry && poetry config virtualenvs.create false && pip install poetry-plugin-mono-repo-deps
RUN cd services/test-py-app && poetry build
RUN cd lib/python/utils && poetry build
This uses regular unmodified PyProject files, so the folder structure must be the same. I'd, therefore, prefer having a shell script that runs the poetry build
for all folders and then copy these into the docker image
And in the following step you then install those wheels:
FROM python:3.11-slim AS app
WORKDIR /app
COPY --from=build /app/services/test-py-app/dist/*.whl /tmp/
COPY --from=build /app/lib/python/utils/dist/*.whl /tmp/
RUN pip install --pre --no-cache-dir --find-links /tmp/ test-py-app
Hi @gerbenoostra !
Thanks for the plugin, but currently I am unable to get this to work and would appreciate your help.
I am working in a polyglot monorepo with the following simplified layout:
I have two
pyproject.toml
files in each of the lib and service, the service is referencing via paths the lib and works ok locally. The issue is during my docker build:The issue is on the last line where I get:
Which makes sense as how would poetry know this package is already installed on the machine?
It seems to me I am not quite grasping the correct usage of this plugin :(