From 1930f16c2f9e146c9e12b82d19c7a8f375bcc694 Mon Sep 17 00:00:00 2001 From: ThibFrgsGmz Date: Mon, 27 Feb 2023 23:29:28 +1300 Subject: [PATCH 1/3] feat: add devcontainer cfg file from @astroesteban --- .devcontainer/Dockerfile | 26 +++++++++++ .devcontainer/config/better_prompt.sh | 63 +++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 38 ++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/config/better_prompt.sh create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..f365b5c --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,26 @@ +ARG VARIANT="22.04" +FROM ubuntu:${VARIANT} as base + +ARG DEBIAN_FRONTEND=noninteractive + +# Install required packages as well as setup the prettier bash prompt and a +# Python virtual environment. +RUN apt-get update && apt-get install -y --no-install-recommends \ + openssh-server \ + curl \ + gnupg \ + git \ + build-essential \ + cmake \ + gdb-multiarch \ + default-jre \ + python3 \ + python3-setuptools \ + python3-pip \ + python3-venv \ + && rm -rf /var/lib/apt/lists/* \ + && python3 -m venv /tmp/fprime-venv \ + && . /tmp/fprime-venv/bin/activate \ + && python3 -m pip install -U --upgrade pip setuptools setuptools_scm wheel \ + && printf '\n[ -d "%s" ] && . %s/bin/activate\n' /tmp/fprime-venv /tmp/fprime-venv >> ~/.bashrc \ + && echo 'eval "$(register-python-argcomplete fprime-cli)"' >> ~/.bashrc diff --git a/.devcontainer/config/better_prompt.sh b/.devcontainer/config/better_prompt.sh new file mode 100644 index 0000000..c5f767f --- /dev/null +++ b/.devcontainer/config/better_prompt.sh @@ -0,0 +1,63 @@ +# File Name: +# better_prompt.sh +# +# Details: +# Contains a function to configure the bash prompt for dev work + +# ````````````````````````````````````````````````````````````````````````````` +# Function name: +# set_bash_prompt() +# +# Description: +# Configures the bash prompt for development. Sets up the CWD, the current +# git branch, any active Python virtual environment, and the username. +# +# [CWD:BRANCH:VENV][USER:HOSTNAME 🚀] _ +# +# Example: +# [/workspaces:master:my_venv][root 🚀] +# Usage: +# Copy and paste the following function **and** the export command into +# your .bashrc file +# +function set_bash_prompt() { + # Color codes for easy prompt building + COLOR_DIVIDER="\[\e[30;1m\]" + COLOR_USERNAME="\[\e[34;1m\]" + COLOR_GITBRANCH="\[\e[33;1m\]" + COLOR_VENV="\[\e[36;1m\]" + COLOR_GREEN="\[\e[32;1m\]" + COLOR_PATH_OK="\[\e[32;1m\]" + COLOR_PATH_ERR="\[\e[31;1m\]" + COLOR_NONE="\[\e[0m\]" + + # Change the path color based on return value. + if test $? -eq 0 ; then + PATH_COLOR=${COLOR_PATH_OK} + else + PATH_COLOR=${COLOR_PATH_ERR} + fi + + # Set the PS1 to be "[workingdirectory:" + PS1="${COLOR_DIVIDER}[${PATH_COLOR}\w${COLOR_DIVIDER}" + # Add git branch portion of the prompt, this adds ":branchname" + if ! git_loc="$(type -p "$git_command_name")" || [ -z "$git_loc" ]; then + # Git is installed + if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + # Inside of a git repository + GIT_BRANCH=$(git symbolic-ref --short HEAD) + PS1="${PS1}:${COLOR_GITBRANCH}${GIT_BRANCH}${COLOR_DIVIDER}" + fi + fi + + # Add Python VirtualEnv portion of the prompt, this adds ":venvname" + if ! test -z "$VIRTUAL_ENV" ; then + PS1="${PS1}:${COLOR_VENV}`basename \"$VIRTUAL_ENV\"`${COLOR_DIVIDER}" + fi + + # Close out the prompt, this adds "]\n[username 🚀] " + PS1="${PS1}]${COLOR_DIVIDER}[${COLOR_USERNAME}\u${COLOR_DIVIDER} 🚀]${COLOR_NONE} " +} + +# Tell Bash to run the above function for every prompt +export PROMPT_COMMAND=set_bash_prompt \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..36f20b8 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,38 @@ +// 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.209.6/containers/ubuntu +{ + "name": "F'", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu version: hirsute, focal, bionic + // Use hirsute or bionic on local arm64/Apple Silicon. + "args": { "VARIANT": "22.04" } + }, + + // Provides runtime arguments to the container + "runArgs": [ + "--privileged", + "--network=host", + "--cap-add=SYS_PTRACE", + "--security-opt=seccomp:unconfined", + "--security-opt=apparmor:unconfined" + ], + + // Set *default* container specific settings.json values on container create. + "settings": {}, + + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vscode.cpptools-extension-pack" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "cat .devcontainer/config/better_prompt.sh >> ~/.bashrc; python3 -m pip install -U -r /workspaces/fprime/requirements.txt" + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode" +} From f6dbcffc9b5979bfa6d0b93a67fdff124956083e Mon Sep 17 00:00:00 2001 From: Thibault <70470823+ThibFrgsGmz@users.noreply.github.com> Date: Mon, 27 Feb 2023 23:51:44 +1300 Subject: [PATCH 2/3] Update devcontainer.json --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 36f20b8..96e13fa 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -31,7 +31,7 @@ // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "cat .devcontainer/config/better_prompt.sh >> ~/.bashrc; python3 -m pip install -U -r /workspaces/fprime/requirements.txt" + "postCreateCommand": "cat .devcontainer/config/better_prompt.sh >> ~/.bashrc; python3 -m pip install -U -r /workspaces/fprime-rtems-poc/fprime/requirements.txt" // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. // "remoteUser": "vscode" From f8829a02790323405734ef9cb8be932770ece7ca Mon Sep 17 00:00:00 2001 From: ThibFrgsGmz Date: Fri, 3 Mar 2023 23:37:47 +1300 Subject: [PATCH 3/3] feat: update Dockerfile (wget renode) --- .devcontainer/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f365b5c..c421c6b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -8,6 +8,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ openssh-server \ curl \ + wget \ gnupg \ git \ build-essential \ @@ -24,3 +25,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && python3 -m pip install -U --upgrade pip setuptools setuptools_scm wheel \ && printf '\n[ -d "%s" ] && . %s/bin/activate\n' /tmp/fprime-venv /tmp/fprime-venv >> ~/.bashrc \ && echo 'eval "$(register-python-argcomplete fprime-cli)"' >> ~/.bashrc + +# Install Renode +ARG RENODE_PKG= https://github.com/renode/renode/releases/download/v1.13.3/renode-1.13.3.linux-portable.tar.gz +RUN wget $RENODE_PKG \ + tar -xvzf renode-1.13.3.linux-portable.tar.gz + +ENV RENODE_INSTALL_DIR=/workspaces/renode +ENV PATH=${RENODE_INSTALL_DIR}:${PATH} \ No newline at end of file