From 0a22c22a65cf6f18dc42175ac4455934dcc32e84 Mon Sep 17 00:00:00 2001 From: Ayoub Zaki Date: Wed, 12 Jun 2024 10:14:12 +0000 Subject: [PATCH] VSCode : Enable Development inside Docker Container This will enable seamless Development of optee_client Project with VSCode inside Docker container. The VSCode Container provides: * Automatic Mapping of the host user UID/GID inside the container * Cross-Compilers (aarch64/armhf) * GDB Multiarch for Debugging * Remote SSH on the Target with seamless ssh mapping of the Host inside the container (Linux/Windows WSL) * Git and Git Extensions to work and send Patches Note: This require Docker installation for Linux/or Windows : [1] https://docs.docker.com/engine/install VSCode Extensions (extensions.json) will be recommended for the installation For more Information : [2] https://code.visualstudio.com/docs/devcontainers/containers [3] https://www.youtube.com/watch?v=C_5tDWsWSj0 [4] https://www.youtube.com/watch?v=b1RavPr_878 Signed-off-by: Ayoub Zaki Acked-by: Jerome Forissier --- .devcontainer/Dockerfile.vscode | 39 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 29 ++++++++++++++++++++++++ .vscode/extensions.json | 10 +++++++++ 3 files changed, 78 insertions(+) create mode 100644 .devcontainer/Dockerfile.vscode create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/extensions.json diff --git a/.devcontainer/Dockerfile.vscode b/.devcontainer/Dockerfile.vscode new file mode 100644 index 00000000..c236a58c --- /dev/null +++ b/.devcontainer/Dockerfile.vscode @@ -0,0 +1,39 @@ +FROM ubuntu:22.04 + +ENV LANG=C.UTF-8 + +RUN dpkg --add-architecture armhf +RUN dpkg --add-architecture arm64 + +RUN echo 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse' > /etc/apt/sources.list +RUN echo 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse' >> /etc/apt/sources.list +RUN echo 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse' >> /etc/apt/sources.list +RUN echo 'deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse' >> /etc/apt/sources.list +RUN echo 'deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe multiverse' >> /etc/apt/sources.list +RUN echo 'deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse' >> /etc/apt/sources.list +RUN echo 'deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse' >> /etc/apt/sources.list +RUN echo 'deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse' >> /etc/apt/sources.list + +RUN apt update && apt upgrade -y && \ + apt install -y \ + build-essential \ + automake \ + cmake \ + gcc-aarch64-linux-gnu \ + gcc-arm-linux-gnueabihf \ + gdb-multiarch \ + curl \ + dpkg-dev \ + pkg-config \ + uuid-dev:armhf \ + uuid-dev:arm64 + +# Additional development tools +RUN apt-get install -y \ + git-core git-man git-email \ + sudo nano vim openssh-client bash-completion + +# Add non root user +RUN useradd -ms /bin/bash optee +RUN echo "optee ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers +USER optee diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..c576fe23 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,29 @@ +{ + "name": "optee-client-docker", + "build": { + "dockerfile": "Dockerfile.vscode" + }, + + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.profiles.linux": { + "bash": { + "path": "/bin/bash", + "args": ["-l"] + } + }, + "terminal.integrated.defaultProfile.linux": "bash" + }, + "extensions": [ + "ms-vscode.cpptools", + "eamodio.gitlens" + ] + } + }, + + // Map the host .ssh folder into the container for a seamless ssh experience + "mounts": [ + "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/optee/.ssh,type=bind,consistency=cached" + ] +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..4bdb6854 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "ms-vscode-remote.remote-containers", + "ms-vscode-remote.remote-wsl", + "ms-vscode-remote.vscode-remote-extensionpack", + "ms-vscode.cpptools-extension-pack", + "ms-vscode.cpptools", + "eamodio.gitlens", + ] +}