<div dir="ltr"><div dir="ltr"><br></div><div>Tested-by: Nicholas Pratte <<a href="mailto:npratte@iol.unh.edu">npratte@iol.unh.edu</a>><br></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 29, 2024 at 10:48 AM Patrick Robb <<a href="mailto:probb@iol.unh.edu">probb@iol.unh.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <span dir="auto"><<a href="mailto:jspewock@iol.unh.edu" target="_blank">jspewock@iol.unh.edu</a>></span><br>Date: Tue, Jan 16, 2024 at 2:18 PM<br>Subject: [PATCH v4] dts: add Dockerfile<br>To:  <<a href="mailto:Honnappa.Nagarahalli@arm.com" target="_blank">Honnappa.Nagarahalli@arm.com</a>>,  <juraj.linkes@pantheon.tech>,  <<a href="mailto:thomas@monjalon.net" target="_blank">thomas@monjalon.net</a>>,  <<a href="mailto:wathsala.vithanage@arm.com" target="_blank">wathsala.vithanage@arm.com</a>>,  <<a href="mailto:probb@iol.unh.edu" target="_blank">probb@iol.unh.edu</a>>,  <<a href="mailto:paul.szczepanek@arm.com" target="_blank">paul.szczepanek@arm.com</a>>,  <<a href="mailto:yoan.picchi@foss.arm.com" target="_blank">yoan.picchi@foss.arm.com</a>><br>Cc:  <<a href="mailto:dev@dpdk.org" target="_blank">dev@dpdk.org</a>>, Jeremy Spewock <<a href="mailto:jspewock@iol.unh.edu" target="_blank">jspewock@iol.unh.edu</a>><br></div><br><br>From: Juraj Linkeš <juraj.linkes@pantheon.tech><br>
<br>
The Dockerfile defines development and CI runner images.<br>
<br>
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech><br>
Signed-off-by: Jeremy Spewock <<a href="mailto:jspewock@iol.unh.edu" target="_blank">jspewock@iol.unh.edu</a>><br>
---<br>
v4:<br>
<br>
Remove an example from and updated a comment in the devcontainer.json<br>
and added the --no-root flag to the README to comply with the warning<br>
message and the discussion on slack.<br>
<br>
v3:<br>
<br>
Remove pexpect.<br>
<br>
v2:<br>
<br>
This verson updates the dockerfile to instead install poetry using pipx<br>
due to the version of poetry installed using the package repositories of<br>
the distro being out of date, and to conform to documentation on<br>
installing poetry.<br>
<br>
This version also adds extra information to the README about the<br>
preference of using SSH keys, and added a way to inject them into the<br>
devcontainer for vscode.<br>
<br>
 dts/.devcontainer/devcontainer.json | 30 +++++++++++++<br>
 dts/Dockerfile                      | 38 ++++++++++++++++<br>
 dts/README.md                       | 70 +++++++++++++++++++++++++++++<br>
 3 files changed, 138 insertions(+)<br>
 create mode 100644 dts/.devcontainer/devcontainer.json<br>
 create mode 100644 dts/Dockerfile<br>
 create mode 100644 dts/README.md<br>
<br>
diff --git a/dts/.devcontainer/devcontainer.json b/dts/.devcontainer/devcontainer.json<br>
new file mode 100644<br>
index 0000000000..4d737f1b40<br>
--- /dev/null<br>
+++ b/dts/.devcontainer/devcontainer.json<br>
@@ -0,0 +1,30 @@<br>
+// For format details, see <a href="https://aka.ms/devcontainer.json" rel="noreferrer" target="_blank">https://aka.ms/devcontainer.json</a>. For config options, see the README at:<br>
+// <a href="https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/docker-existing-dockerfile" rel="noreferrer" target="_blank">https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/docker-existing-dockerfile</a><br>
+{<br>
+       "name": "Existing Dockerfile",<br>
+<br>
+       // Sets the run context to one level up instead of the .devcontainer folder.<br>
+       "context": "..",<br>
+<br>
+       // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.<br>
+       "dockerFile": "../Dockerfile",<br>
+<br>
+       // Use 'forwardPorts' to make a list of ports inside the container available locally.<br>
+       // "forwardPorts": [],<br>
+<br>
+       // The next line runs commands after the container is created - in our case, installing dependencies.<br>
+       "postCreateCommand": "poetry install --no-root",<br>
+<br>
+       "extensions": [<br>
+               "ms-python.vscode-pylance",<br>
+       ]<br>
+<br>
+       // Uncomment when using a ptrace-based debugger like C++, Go, and Rust<br>
+       // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],<br>
+<br>
+       // Uncomment to use the Docker CLI from inside the container. See <a href="https://aka.ms/vscode-remote/samples/docker-from-docker" rel="noreferrer" target="_blank">https://aka.ms/vscode-remote/samples/docker-from-docker</a>.<br>
+       // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],<br>
+<br>
+       // Uncomment to mount your SSH keys into the devcontainer used by vscode.<br>
+       // "mounts": ["source=${localEnv:HOME}/.ssh,destination=/root/.ssh,type=bind,readonly"]<br>
+}<br>
diff --git a/dts/Dockerfile b/dts/Dockerfile<br>
new file mode 100644<br>
index 0000000000..fa4c1af10e<br>
--- /dev/null<br>
+++ b/dts/Dockerfile<br>
@@ -0,0 +1,38 @@<br>
+# SPDX-License-Identifier: BSD-3-Clause<br>
+# Copyright(c) 2022 University of New Hampshire<br>
+<br>
+# There are two Docker images defined in this Dockerfile.<br>
+# One is to be used in CI for automated testing.<br>
+# The other provides a DTS development environment, simplifying Python dependency management.<br>
+<br>
+FROM ubuntu:22.04 AS base<br>
+<br>
+RUN apt-get -y update && apt-get -y upgrade && \<br>
+    apt-get -y install --no-install-recommends \<br>
+        python3 \<br>
+        python3-pip \<br>
+        pipx \<br>
+        python3-cachecontrol \<br>
+        openssh-client && \<br>
+    pipx install poetry>=1.5.1 && pipx ensurepath<br>
+WORKDIR /dpdk/dts<br>
+<br>
+<br>
+FROM base AS runner<br>
+<br>
+# This image is intended to be used as the base for automated systems.<br>
+# It bakes DTS into the image during the build.<br>
+<br>
+COPY . /dpdk/dts<br>
+RUN poetry install --no-dev<br>
+<br>
+CMD ["poetry", "run", "python", "main.py"]<br>
+<br>
+FROM base AS dev<br>
+<br>
+# This image is intended to be used as DTS development environment. It doesn't need C compilation<br>
+# capabilities, only Python dependencies. Once a container mounting DTS using this image is running,<br>
+# the dependencies should be installed using Poetry.<br>
+<br>
+RUN apt-get -y install --no-install-recommends \<br>
+        vim emacs git<br>
diff --git a/dts/README.md b/dts/README.md<br>
new file mode 100644<br>
index 0000000000..36c8cc9a0c<br>
--- /dev/null<br>
+++ b/dts/README.md<br>
@@ -0,0 +1,70 @@<br>
+# DTS Environment<br>
+The execution and development environments for DTS are the same, a<br>
+[Docker](<a href="https://docs.docker.com/" rel="noreferrer" target="_blank">https://docs.docker.com/</a>) container defined by our [Dockerfile](./Dockerfile).<br>
+Using a container for the development environment helps with a few things.<br>
+<br>
+1. It helps enforce the boundary between the DTS environment and the TG/SUT, something<br>
+   which caused issues in the past.<br>
+2. It makes creating containers to run DTS inside automated tooling much easier, since<br>
+   they can be based off of a known-working environment that will be updated as DTS is.<br>
+3. It abstracts DTS from the server it is running on. This means that the bare-metal os<br>
+   can be whatever corporate policy or your personal preferences dictate, and DTS does<br>
+   not have to try to support all distros that are supported by DPDK CI.<br>
+4. It makes automated testing for DTS easier, since new dependencies can be sent in with<br>
+  the patches.<br>
+5. It fixes the issue of undocumented dependencies, where some test suites require<br>
+   python libraries that are not installed.<br>
+6. Allows everyone to use the same python version easily, even if they are using a<br>
+   distribution or Windows with out-of-date packages.<br>
+7. Allows you to run the tester on Windows while developing via Docker for Windows.<br>
+<br>
+## Tips for setting up a development environment<br>
+<br>
+### Getting a docker shell<br>
+These commands will give you a bash shell inside the container with all the python<br>
+dependencies installed. This will place you inside a python virtual environment. DTS is<br>
+mounted via a volume, which is essentially a symlink from the host to the container.<br>
+This enables you to edit and run inside the container and then delete the container when<br>
+you are done, keeping your work. It is also strongly recommended that you mount your SSH<br>
+keys into the container to allow you to connect to hosts without specifying a password.<br>
+<br>
+#### Start docker container with SSH keys<br>
+<br>
+```shell<br>
+docker build --target dev -t dpdk-dts .<br>
+docker run -v $(pwd)/..:/dpdk -v /home/dtsuser/.ssh:/root/.ssh:ro -it dpdk-dts bash<br>
+$ poetry install --no-root<br>
+$ poetry shell<br>
+```<br>
+<br>
+#### Start docker container without SSH keys<br>
+<br>
+```shell<br>
+docker build --target dev -t dpdk-dts .<br>
+docker run -v $(pwd)/..:/dpdk -it dpdk-dts bash<br>
+$ poetry install --no-root<br>
+$ poetry shell<br>
+```<br>
+<br>
+### Vim/Emacs<br>
+Any editor in the ubuntu repos should be easy to use, with vim and emacs already<br>
+installed. You can add your normal config files as a volume, enabling you to use your<br>
+preferred settings.<br>
+<br>
+```shell<br>
+docker run -v ${HOME}/.vimrc:/root/.vimrc -v $(pwd)/..:/dpdk -it dpdk-dts bash<br>
+```<br>
+<br>
+### Visual Studio Code<br>
+VSCode has first-class support for developing with containers. You may need to run the<br>
+non-docker setup commands in the integrated terminal. DTS contains a .devcontainer<br>
+config, so if you open the folder in vscode it should prompt you to use the dev<br>
+container assuming you have the plugin installed. Please refer to<br>
+[VS Development Containers Docs](<a href="https://code.visualstudio.com/docs/remote/containers" rel="noreferrer" target="_blank">https://code.visualstudio.com/docs/remote/containers</a>)<br>
+to set it all up. Additionally, there is a line in `.devcontainer/devcontainer.json`<br>
+that, when included, will mount the SSH keys of the user currently running vscode into<br>
+the container for you. The `source` on this line can be altered to mount any SSH keys on<br>
+the local machine into the container at the correct location.<br>
+<br>
+### Other<br>
+Searching for '$IDE dev containers' will probably lead you in the right direction.<br>
-- <br>
2.43.0<br>
<br>
</div><br></div></blockquote><div> </div></div></div>