[v1] dts: fix runner target in the Dockerfile
Checks
Commit Message
From: Jeremy Spewock <jspewock@iol.unh.edu>
Currently the runner target in the Dockerfile attempts to run the
`poetry install` command when building the image, but this fails due to
poetry not being found in the container. Poetry is installed in a
previous step with pipx, but doing so adds the binary to use poetry to
~/.local/bin which isn't present in the PATH variable in the container
image. The command `pipx ensurepath` fixes this issue in most cases, but
it requires a restart of the shell in order for the changes to take
place which is not something that is done in the runner target. To
solve this problem this patch manually adds ~/.local/bin to PATH in the
runner target.
Additionally, the command for installing poetry in the runner target
uses the depreciated flag --no-dev which is removed in this patch and
replaced with the new method of doing the same thing alongside the
--no-root flag from the DTS documentation.
Fixes: 19082c1fac43 ("dts: add Dockerfile")
Cc: juraj.linkes@pantheon.tech
Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
dts/Dockerfile | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Patrick Robb <probb@iol.unh.edu>
On 11. 9. 2024 17:50, jspewock@iol.unh.edu wrote:
> From: Jeremy Spewock <jspewock@iol.unh.edu>
>
> Currently the runner target in the Dockerfile attempts to run the
> `poetry install` command when building the image, but this fails due to
> poetry not being found in the container. Poetry is installed in a
> previous step with pipx, but doing so adds the binary to use poetry to
> ~/.local/bin which isn't present in the PATH variable in the container
> image. The command `pipx ensurepath` fixes this issue in most cases, but
> it requires a restart of the shell in order for the changes to take
> place which is not something that is done in the runner target. To
> solve this problem this patch manually adds ~/.local/bin to PATH in the
> runner target.
>
> Additionally, the command for installing poetry in the runner target
> uses the depreciated flag --no-dev which is removed in this patch and
> replaced with the new method of doing the same thing alongside the
> --no-root flag from the DTS documentation.
>
> Fixes: 19082c1fac43 ("dts: add Dockerfile")
> Cc: juraj.linkes@pantheon.tech
>
> Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
> ---
> dts/Dockerfile | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/dts/Dockerfile b/dts/Dockerfile
> index a81e46c41a..66b3cfd97f 100644
> --- a/dts/Dockerfile
> +++ b/dts/Dockerfile
> @@ -24,7 +24,10 @@ FROM base AS runner
> # It bakes DTS into the image during the build.
>
> COPY . /dpdk/dts
> -RUN poetry install --no-dev
> +# 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.
> +ENV PATH="$PATH:/root/.local/bin"
> +RUN poetry install --only main --no-root
There's a patch from Dean that removed --no-root. I suggest waiting for
Dean to submit v2, then you rebase on top of that and I'll merge both of
these as we seem to have the tags.
>
> CMD ["poetry", "run", "python", "main.py"]
>
On Mon, Sep 16, 2024 at 6:16 AM Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
>
>
>
> On 11. 9. 2024 17:50, jspewock@iol.unh.edu wrote:
> > From: Jeremy Spewock <jspewock@iol.unh.edu>
> >
> > Currently the runner target in the Dockerfile attempts to run the
> > `poetry install` command when building the image, but this fails due to
> > poetry not being found in the container. Poetry is installed in a
> > previous step with pipx, but doing so adds the binary to use poetry to
> > ~/.local/bin which isn't present in the PATH variable in the container
> > image. The command `pipx ensurepath` fixes this issue in most cases, but
> > it requires a restart of the shell in order for the changes to take
> > place which is not something that is done in the runner target. To
> > solve this problem this patch manually adds ~/.local/bin to PATH in the
> > runner target.
> >
> > Additionally, the command for installing poetry in the runner target
> > uses the depreciated flag --no-dev which is removed in this patch and
> > replaced with the new method of doing the same thing alongside the
> > --no-root flag from the DTS documentation.
> >
> > Fixes: 19082c1fac43 ("dts: add Dockerfile")
> > Cc: juraj.linkes@pantheon.tech
> >
> > Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
> > ---
> > dts/Dockerfile | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/dts/Dockerfile b/dts/Dockerfile
> > index a81e46c41a..66b3cfd97f 100644
> > --- a/dts/Dockerfile
> > +++ b/dts/Dockerfile
> > @@ -24,7 +24,10 @@ FROM base AS runner
> > # It bakes DTS into the image during the build.
> >
> > COPY . /dpdk/dts
> > -RUN poetry install --no-dev
> > +# 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.
> > +ENV PATH="$PATH:/root/.local/bin"
> > +RUN poetry install --only main --no-root
>
> There's a patch from Dean that removed --no-root. I suggest waiting for
> Dean to submit v2, then you rebase on top of that and I'll merge both of
> these as we seem to have the tags.
I didn't know about this change but this makes sense to me. There is
one other version that I'll submit here before Dean puts out his V2
since we had further discussion on slack about it potentially being
beneficial to add an ENTRYPOINT to the dockerfile, as well as fixing
the missing git package.
>
> >
> > CMD ["poetry", "run", "python", "main.py"]
> >
>
@@ -24,7 +24,10 @@ FROM base AS runner
# It bakes DTS into the image during the build.
COPY . /dpdk/dts
-RUN poetry install --no-dev
+# 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.
+ENV PATH="$PATH:/root/.local/bin"
+RUN poetry install --only main --no-root
CMD ["poetry", "run", "python", "main.py"]