Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Add devcontainer support #7

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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 \
wget \
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

# 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}
63 changes: 63 additions & 0 deletions .devcontainer/config/better_prompt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# File Name:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

39% of developers fix this issue

SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

# 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\]"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24% of developers fix this issue

SC2034: COLOR_GREEN appears unused. Verify use (or export if used externally).


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

41% of developers fix this issue

SC2154: git_command_name is referenced but not assigned.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

# 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}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

36% of developers fix this issue

SC2006: Use $(...) notation instead of legacy backticks ....


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

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
38 changes: 38 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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-rtems-poc/fprime/requirements.txt"

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}