[v1] dts: fix runner target in the Dockerfile

Message ID 20240911155058.11321-1-jspewock@iol.unh.edu (mailing list archive)
State Superseded
Delegated to: Juraj Linkeš
Headers
Series [v1] dts: fix runner target in the Dockerfile |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/loongarch-compilation success Compilation OK
ci/intel-Functional success Functional PASS
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Jeremy Spewock Sept. 11, 2024, 3:50 p.m. UTC
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

Luca Vizzarro Sept. 11, 2024, 3:52 p.m. UTC | #1
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
  
Patrick Robb Sept. 11, 2024, 5:26 p.m. UTC | #2
Reviewed-by: Patrick Robb <probb@iol.unh.edu>
  
Juraj Linkeš Sept. 16, 2024, 10:16 a.m. UTC | #3
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"]
>
  
Jeremy Spewock Sept. 16, 2024, 5:28 p.m. UTC | #4
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"]
> >
>
  

Patch

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
 
 CMD ["poetry", "run", "python", "main.py"]