Replies: 2 comments 2 replies
-
I think your use case is covered by the bundle plugin. See also #1382 |
Beta Was this translation helpful? Give feedback.
2 replies
-
Based on @yrro comment I found the following works. Not super elegant, but it is functional and reliable.
FROM python:3.12-slim-bookworm as builder
RUN pip install poetry==1.7.1
ENV POETRY_NO_INTERACTION=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
RUN poetry self add poetry-plugin-bundle
WORKDIR /src
COPY pyproject.toml poetry.lock README.md ./
# Copy the module separately so it ends up in the correct directory structure
COPY appmodule ./appmodule
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry bundle venv /src/.venv
FROM python:3.12-slim-bookworm as runtime
ENV VIRTUAL_ENV=/src/.venv \
PATH="/src/.venv/bin:$PATH"
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
ENTRYPOINT ["appscript"] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Running
poetry install
installs the current project in editable mode by default. I can't find any way to configure this. Should there be an option topoetry install
the current project not in editable mode?My use case is for containerised applications, not libraries. For instance, I was experimenting with the
poetry-dynamic-versioning
plugin in this app, and because I couldn't install in non-editable mode, the process felt a bit awkward. For instance, I couldpoetry build --format wheel && pip install ./dist/* && rm -r ./dist
but it would be nice just to be able topoetry install --no-editable
in my docker build. In my case, it's because of the quirks ofpoetry-dynamic-versioning
, which overwrites version variables in the current package based on git tags but reverts changes after the build stage which works fine for dist files but not when the package is installed in editable mode.Another advantage for allowing install of applications in non-editable mode is that multistage builds become easier. For instance, I often use multi-stage docker builds, and install my project & deps in the build stage, and copy the
lib
directory to the serving stage. This is more difficult if the current package isn't bundled and installed insite-packages
along with the dependencies.Is my use case niche/is there a better way, or could this be a feature?
Beta Was this translation helpful? Give feedback.
All reactions