On 18. 9. 2024 16:16, Jeremy Spewock wrote:
On Wed, Sep 18, 2024 at 3:57 AM Juraj Linkeš <juraj.lin...@pantheon.tech> wrote:


diff --git a/dts/Dockerfile b/dts/Dockerfile

@@ -24,9 +27,12 @@ FROM base AS runner

+# Adds ~/.local/bin to PATH so that packages installed with pipx are callable. 
`pipx ensurepath`
+# fixes this issue, but requires the shell to be re-opened which isn't an 
option for this target.

Let's explain this a bit more, I don't really know why this isn't an option.

The main reason it isn't an option is it is all happening in the same
`docker build` process and it seems like however Docker is deciding to
create the layers isn't refreshing the terminal. I don't think there
is a way we could make it do so, but I can swap the "isn't an option"
part of the comment for something more like "and the build process
does not refresh the terminal in the required way before creating the
next layer."


Yea I think that's because each layer is basically independent so env vars (likely set by `pipx ensurepath`) don't persist.

I understand it now. The were multiple confusing things (how does `pipx ensurepath` relate to ~/.local/bin, how does `pipx ensurepath` fix which issue, why is shell mentioned and what option is not an option and why for this target and not the other and possibly more). It basically raised more questions than answered. :-)

I would just say:
pipx installs packages in ~/.local/bin, which is not in PATH by default. The `pipx ensurepath` command (which sets the path) called in the previous step only works in that step as the docker build process doesn't preserve env variables between steps.

Or something like that.


+ENV PATH="$PATH:/root/.local/bin"
+RUN poetry install --only main --no-root

-CMD ["poetry", "run", "python", "main.py"]
+ENTRYPOINT ["poetry", "run", "python", "main.py"]


Reply via email to