From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0A2A1438E6; Tue, 16 Jan 2024 20:18:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5E0740298; Tue, 16 Jan 2024 20:18:29 +0100 (CET) Received: from mail-yb1-f228.google.com (mail-yb1-f228.google.com [209.85.219.228]) by mails.dpdk.org (Postfix) with ESMTP id D182540278 for ; Tue, 16 Jan 2024 20:18:28 +0100 (CET) Received: by mail-yb1-f228.google.com with SMTP id 3f1490d57ef6-dc22ae44595so775719276.1 for ; Tue, 16 Jan 2024 11:18:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1705432708; x=1706037508; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PlZIVHHvGf4Dd8LTo7bXZZpDr3xo/UwAS1wq6Z3qjHg=; b=TypNQLwBYSEe4s3kGStRpHjEplejPXJLL4wM1Z1ojd426lJnVIyzhGsm0i56D0bFb3 F2a0ifgdIcpIRy1dChcYbCJdSyjuFB2O29E9SREDMF1rCD7Em7lN0PrsXp7Zel+BQB9u WM8HaY4Sl2T89kQq+1SG8wHb7qGPY09wWdE24= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705432708; x=1706037508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PlZIVHHvGf4Dd8LTo7bXZZpDr3xo/UwAS1wq6Z3qjHg=; b=DjF/9ROIcScBPWAB1tuwqVAZfXG49XR8syWF4bZ0SV12491xbtn8EwIrJAOv233Y7k pofbIws+ttseXRYQ93m3J/PTsAmTGpPkyd40ZPSXJ6RWQBdhoI5f6mioW68sXTp0+vBU F7B3x4SZLp/AGj3gzRJrDNKn9JoYTV6UueQ7HxFMmV/13m4xglaLudf9DMj0g7My+4Je EWKMfZPKZ8uvC8T/5ATGupttZz7D1k4BrWU1F3WAIf0m2d/yCMc5AH63n2husaW4UCHn 3LGcyKQgeaVmxMCxQDVPs8+rFSMBJqqRtgcBXvmuc2qFuB1DJ20mM5e42u6Iogox9kEA dlZw== X-Gm-Message-State: AOJu0YxhG53wrq47RXulO8VTzx+N9u6efnt+RdmbJ2CnkrsqcZ+dMlYD WjnInApJwVFIcmVtOlumMy0xa11wMculiMMJrRUo3FnjzG5KihBGEhd+RA== X-Google-Smtp-Source: AGHT+IHmM+DiCV2/2tv8nrZE1tQmqBV/5Qcm3LG528Rhng37YwPr5bQ1NA3k54c2W7F4/usgO+62Ehl1gN9G X-Received: by 2002:a05:6902:2003:b0:dbe:9eef:df53 with SMTP id dh3-20020a056902200300b00dbe9eefdf53mr3731072ybb.36.1705432708154; Tue, 16 Jan 2024 11:18:28 -0800 (PST) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id 81-20020a251054000000b00dbed47f3847sm754024ybq.24.2024.01.16.11.18.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2024 11:18:28 -0800 (PST) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::1083]) by postal.iol.unh.edu (Postfix) with ESMTP id 698A86043300; Tue, 16 Jan 2024 14:18:27 -0500 (EST) From: jspewock@iol.unh.edu To: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, thomas@monjalon.net, wathsala.vithanage@arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v4] dts: add Dockerfile Date: Tue, 16 Jan 2024 14:18:14 -0500 Message-ID: <20240116191814.31316-1-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111222608.13239-1-jspewock@iol.unh.edu> References: <20240111222608.13239-1-jspewock@iol.unh.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Juraj Linkeš The Dockerfile defines development and CI runner images. Signed-off-by: Juraj Linkeš Signed-off-by: Jeremy Spewock --- v4: Remove an example from and updated a comment in the devcontainer.json and added the --no-root flag to the README to comply with the warning message and the discussion on slack. v3: Remove pexpect. v2: This verson updates the dockerfile to instead install poetry using pipx due to the version of poetry installed using the package repositories of the distro being out of date, and to conform to documentation on installing poetry. This version also adds extra information to the README about the preference of using SSH keys, and added a way to inject them into the devcontainer for vscode. dts/.devcontainer/devcontainer.json | 30 +++++++++++++ dts/Dockerfile | 38 ++++++++++++++++ dts/README.md | 70 +++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 dts/.devcontainer/devcontainer.json create mode 100644 dts/Dockerfile create mode 100644 dts/README.md diff --git a/dts/.devcontainer/devcontainer.json b/dts/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..4d737f1b40 --- /dev/null +++ b/dts/.devcontainer/devcontainer.json @@ -0,0 +1,30 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/docker-existing-dockerfile +{ + "name": "Existing Dockerfile", + + // Sets the run context to one level up instead of the .devcontainer folder. + "context": "..", + + // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. + "dockerFile": "../Dockerfile", + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // The next line runs commands after the container is created - in our case, installing dependencies. + "postCreateCommand": "poetry install --no-root", + + "extensions": [ + "ms-python.vscode-pylance", + ] + + // Uncomment when using a ptrace-based debugger like C++, Go, and Rust + // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + + // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. + // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], + + // Uncomment to mount your SSH keys into the devcontainer used by vscode. + // "mounts": ["source=${localEnv:HOME}/.ssh,destination=/root/.ssh,type=bind,readonly"] +} diff --git a/dts/Dockerfile b/dts/Dockerfile new file mode 100644 index 0000000000..fa4c1af10e --- /dev/null +++ b/dts/Dockerfile @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 University of New Hampshire + +# There are two Docker images defined in this Dockerfile. +# One is to be used in CI for automated testing. +# The other provides a DTS development environment, simplifying Python dependency management. + +FROM ubuntu:22.04 AS base + +RUN apt-get -y update && apt-get -y upgrade && \ + apt-get -y install --no-install-recommends \ + python3 \ + python3-pip \ + pipx \ + python3-cachecontrol \ + openssh-client && \ + pipx install poetry>=1.5.1 && pipx ensurepath +WORKDIR /dpdk/dts + + +FROM base AS runner + +# This image is intended to be used as the base for automated systems. +# It bakes DTS into the image during the build. + +COPY . /dpdk/dts +RUN poetry install --no-dev + +CMD ["poetry", "run", "python", "main.py"] + +FROM base AS dev + +# This image is intended to be used as DTS development environment. It doesn't need C compilation +# capabilities, only Python dependencies. Once a container mounting DTS using this image is running, +# the dependencies should be installed using Poetry. + +RUN apt-get -y install --no-install-recommends \ + vim emacs git diff --git a/dts/README.md b/dts/README.md new file mode 100644 index 0000000000..36c8cc9a0c --- /dev/null +++ b/dts/README.md @@ -0,0 +1,70 @@ +# DTS Environment +The execution and development environments for DTS are the same, a +[Docker](https://docs.docker.com/) container defined by our [Dockerfile](./Dockerfile). +Using a container for the development environment helps with a few things. + +1. It helps enforce the boundary between the DTS environment and the TG/SUT, something + which caused issues in the past. +2. It makes creating containers to run DTS inside automated tooling much easier, since + they can be based off of a known-working environment that will be updated as DTS is. +3. It abstracts DTS from the server it is running on. This means that the bare-metal os + can be whatever corporate policy or your personal preferences dictate, and DTS does + not have to try to support all distros that are supported by DPDK CI. +4. It makes automated testing for DTS easier, since new dependencies can be sent in with + the patches. +5. It fixes the issue of undocumented dependencies, where some test suites require + python libraries that are not installed. +6. Allows everyone to use the same python version easily, even if they are using a + distribution or Windows with out-of-date packages. +7. Allows you to run the tester on Windows while developing via Docker for Windows. + +## Tips for setting up a development environment + +### Getting a docker shell +These commands will give you a bash shell inside the container with all the python +dependencies installed. This will place you inside a python virtual environment. DTS is +mounted via a volume, which is essentially a symlink from the host to the container. +This enables you to edit and run inside the container and then delete the container when +you are done, keeping your work. It is also strongly recommended that you mount your SSH +keys into the container to allow you to connect to hosts without specifying a password. + +#### Start docker container with SSH keys + +```shell +docker build --target dev -t dpdk-dts . +docker run -v $(pwd)/..:/dpdk -v /home/dtsuser/.ssh:/root/.ssh:ro -it dpdk-dts bash +$ poetry install --no-root +$ poetry shell +``` + +#### Start docker container without SSH keys + +```shell +docker build --target dev -t dpdk-dts . +docker run -v $(pwd)/..:/dpdk -it dpdk-dts bash +$ poetry install --no-root +$ poetry shell +``` + +### Vim/Emacs +Any editor in the ubuntu repos should be easy to use, with vim and emacs already +installed. You can add your normal config files as a volume, enabling you to use your +preferred settings. + +```shell +docker run -v ${HOME}/.vimrc:/root/.vimrc -v $(pwd)/..:/dpdk -it dpdk-dts bash +``` + +### Visual Studio Code +VSCode has first-class support for developing with containers. You may need to run the +non-docker setup commands in the integrated terminal. DTS contains a .devcontainer +config, so if you open the folder in vscode it should prompt you to use the dev +container assuming you have the plugin installed. Please refer to +[VS Development Containers Docs](https://code.visualstudio.com/docs/remote/containers) +to set it all up. Additionally, there is a line in `.devcontainer/devcontainer.json` +that, when included, will mount the SSH keys of the user currently running vscode into +the container for you. The `source` on this line can be altered to mount any SSH keys on +the local machine into the container at the correct location. + +### Other +Searching for '$IDE dev containers' will probably lead you in the right direction. -- 2.43.0