From: Jeremy Spewock <jspew...@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 can be 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 a depreciated flag, and the --revision parameter does not work with
the runner target. To address these problems the --no-dev flag 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 and git is
added to the base target of the image. The CMD of the runner target is
also replaced with an ENTRYPOINT for ease of use.

Fixes: 19082c1fac43 ("dts: add Dockerfile")
Cc: juraj.lin...@pantheon.tech

Signed-off-by: Jeremy Spewock <jspew...@iol.unh.edu>
---
 dts/Dockerfile | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/dts/Dockerfile b/dts/Dockerfile
index a81e46c41a..58642fdc67 100644
--- a/dts/Dockerfile
+++ b/dts/Dockerfile
@@ -13,8 +13,11 @@ RUN apt-get -y update && apt-get -y upgrade && \
         python3-pip \
         pipx \
         python3-cachecontrol \
+        git \
+        xz-utils \
         openssh-client && \
-    pipx install poetry>=1.8.2 && pipx ensurepath
+    pipx install poetry>=1.8.2 && pipx ensurepath && \
+    git config --global --add safe.directory /dpdk
 WORKDIR /dpdk/dts
 
 
@@ -24,9 +27,12 @@ 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"]
+ENTRYPOINT ["poetry", "run", "python", "main.py"]
 
 FROM base AS dev
 
@@ -35,4 +41,4 @@ FROM base AS dev
 # the dependencies should be installed using Poetry.
 
 RUN apt-get -y install --no-install-recommends \
-        vim emacs git
+        vim emacs
-- 
2.46.0

Reply via email to