Skip to content

Commit

Permalink
.devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Armando Hernandez committed May 22, 2022
1 parent 45a4d2c commit 4c2b938
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# syntax=docker/dockerfile:1.2
FROM crops/poky:ubuntu-20.04
# swtich to root user to install additional packages
USER root
# create a non-root user
ARG USERNAME=builder
ARG GROUPNAME=build
ARG USER_UID=1024
ARG USER_GID=1024
RUN set -x && \
groupadd \
--gid ${USER_GID} \
${GROUPNAME} \
&& \
useradd \
--uid ${USER_UID} \
--gid ${USER_GID} \
--create-home \
${USERNAME} \
&& \
:
# update gcc version to 9
RUN set -x && \
apt update && \
apt install software-properties-common -y && \
#apt update && \
add-apt-repository ppa:ubuntu-toolchain-r/ppa && \
#apt update && \
apt install g++-9 -y && \
add-apt-repository --remove ppa:ubuntu-toolchain-r/ppa -y && \
apt --purge autoremove software-properties-common -y && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 60 && \
update-alternatives --config g++ && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 && \
update-alternatives --config g++ && \
:
# add additional packages
RUN set -x && \
apt update && \
apt install -y \
sudo \
vim \
less \
bsdmainutils \
nasm \
mc \
libncurses5-dev \
libncursesw5-dev \
python3 \
python3-pip \
&& \
echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} && \
chmod 0400 /etc/sudoers.d/${USERNAME} && \
apt clean && \
rm -fr /var/lib/apt/lists/* && \
:
# install kas
RUN set -x && \
pip3 install kas && \
:
# switch back to regular user
#USER usersetup
USER builder
# Install fuzzy finder
RUN git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
RUN cd ~/.fzf && ./install
58 changes: 58 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// For format details, see https://aka.ms/devcontainer.json
{
"name": "${localWorkspaceFolderBasename}",

// Due to devcontainer not yet supporting the '--network host' argument when building from a Dockerfile
// See: https://github.com/microsoft/vscode-remote-release/issues/3545
// Workaround: build the image on the host before asking vscode to build it so that it is re-used
"initializeCommand":
"DOCKER_BUILDKIT=1 docker build --network host --tag poky:ubuntu-20.04 .devcontainer/",

"build": {
"dockerfile": "Dockerfile",
"context": ".",
},

// Arguments to tuse when running the container
"runArgs": [
"--network=host",
"--mount=type=volume,src=yoctovol,dst=/workspaces/${localWorkspaceFolderBasename}/yocto"
],

// Environment variables to set in the container
"containerEnv": {},

// Volumes to mount when running the container
"mounts": [
"source=${localEnv:HOME}/.ssh/,target=/home/yoctouser/.ssh/,type=bind",
],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash"
},
},
"terminal.integrated.defaultProfile.linux": "bash",
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-themes",
"twxs.cmake",
"ms-vscode.cmake-tools",
"cschlosser.doxdocgen",
"jeff-hykin.better-cpp-syntax",
"ms-vscode-remote.remote-ssh",
"coenraads.bracket-pair-colorizer-2",
"franneck94.vscode-c-cpp-config",
"mhutchie.git-graph",
"github.remotehub",
"eamodio.gitlens",
"oderwat.indent-rainbow",
"ms-vscode.cpptools-extension-pack"
],
}
11 changes: 11 additions & 0 deletions .devcontainer/init_workspace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash


SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

set -e

chown :build "${SCRIPT_DIR}/../yocto/"
chmod 775 "${SCRIPT_DIR}/../yocto/"
chmod g+s "${SCRIPT_DIR}/../yocto/"

0 comments on commit 4c2b938

Please sign in to comment.