Skip to content
Merged
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
61 changes: 61 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# [Choice] Debian / Ubuntu version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04
# See https://github.com/microsoft/vscode-dev-containers/tree/master/containers/debian
ARG VARIANT=debian-12
FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT}


# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# Set env for tracking that we're running in a devcontainer
ENV DEVCONTAINER=true

# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

USER $USERNAME
RUN \
mkdir -p ~/.local/bin \
&& echo "export PATH=\$PATH:~/.local/bin" >> ~/.bashrc

# Configure apt, install packages and general tools
RUN sudo apt-get update \
&& sudo apt-get -y install --no-install-recommends apt-utils dialog nano bash-completion sudo bsdmainutils \
#
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
&& sudo apt-get -y install git iproute2 procps lsb-release figlet build-essential

# Save command line history
RUN echo "export HISTFILE=/home/$USERNAME/commandhistory/.bash_history" >> "/home/$USERNAME/.bashrc" \
&& echo "export PROMPT_COMMAND='history -a'" >> "/home/$USERNAME/.bashrc" \
&& mkdir -p /home/$USERNAME/commandhistory \
&& touch /home/$USERNAME/commandhistory/.bash_history \
&& chown -R $USERNAME /home/$USERNAME/commandhistory

# Set env for tracking that we're running in a devcontainer
ENV DEVCONTAINER=true

# node
COPY scripts/node.sh /tmp/
RUN /bin/bash /tmp/node.sh 24.x

# docker-client
COPY scripts/docker-client.sh /tmp/
RUN /bin/bash /tmp/docker-client.sh

#Add user to docker group
RUN sudo groupadd docker && sudo usermod -aG docker $USERNAME && newgrp docker

# act
COPY scripts/act.sh /tmp/
RUN /bin/bash /tmp/act.sh 0.2.21

# __DEVCONTAINER_SNIPPET_INSERT__ (control where snippets get inserted using the devcontainer CLI)

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "1.0.14",
"resolved": "ghcr.io/devcontainers/features/github-cli@sha256:ca677566507c4118e4368cd76a4800807e911e5e350cc3525fb67ebc9132dfa1",
"integrity": "sha256:ca677566507c4118e4368cd76a4800807e911e5e350cc3525fb67ebc9132dfa1"
}
}
}
36 changes: 36 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/go
{
"name": "devcontainers-ci",
"dockerFile": "Dockerfile",
"build": {
"cacheFrom": "ghcr.io/step-security/devcontainers-ci-devcontainer:latest"
},
"mounts": [
// Keep command history
"source=devcontainer-build-run-bashhistory,target=/home/vscode/commandhistory",
// Mount host docker socket
"type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock"
],
"postCreateCommand": ".devcontainer/scripts/postCreate.sh",
"remoteUser": "vscode",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"files.eol": "\n"
},
"extensions": [
"ms-azuretools.vscode-docker",
"yzhang.markdown-all-in-one",
"davidanson.vscode-markdownlint",
"heaths.vscode-guid",
"esbenp.prettier-vscode",
"meganrogge.template-string-converter"
]
}
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": "latest"
}
}
23 changes: 23 additions & 0 deletions .devcontainer/scripts/act.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" |
grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/'
}

VERSION=${1:-"$(get_latest_release nektos/act)"}
INSTALL_DIR=${2:-"$HOME/.local/bin"}
CMD=act
NAME="nektos/act"

echo -e "\e[34m»»» 📦 \e[32mInstalling \e[33m$NAME v$VERSION\e[0m ..."

mkdir -p $INSTALL_DIR
curl -sSL https://github.com/nektos/act/releases/download/v${VERSION}/act_Linux_x86_64.tar.gz -o /tmp/act.tar.gz
tar -zxvf /tmp/act.tar.gz -C $INSTALL_DIR act > /dev/null
chmod +x $INSTALL_DIR/act
rm -rf /tmp/act.tar.gz

echo -e "\n\e[34m»»» 💾 \e[32mInstalled to: \e[33m$(which $CMD)"
echo -e "\e[34m»»» 💡 \e[32mVersion details: \e[39m$($CMD --version)"
20 changes: 20 additions & 0 deletions .devcontainer/scripts/docker-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -e

VERSION=${1:-"20.10.5"}
INSTALL_DIR=${2:-"$HOME/.local/bin"}
CMD=docker
NAME="Docker Client"

echo -e "\e[34m»»» 📦 \e[32mInstalling \e[33m$NAME \e[35mv$VERSION\e[0m ..."

mkdir -p $INSTALL_DIR
curl -sSL https://download.docker.com/linux/static/stable/x86_64/docker-$VERSION.tgz -o /tmp/docker.tgz
tar -zxvf /tmp/docker.tgz -C /tmp docker/docker
chmod +x /tmp/docker/docker
mv /tmp/docker/docker $INSTALL_DIR/docker
rmdir /tmp/docker/
rm -rf /tmp/docker.tgz

echo -e "\n\e[34m»»» 💾 \e[32mInstalled to: \e[33m$(which $CMD)"
echo -e "\e[34m»»» 💡 \e[32mVersion details: \e[39m$($CMD --version)"
23 changes: 23 additions & 0 deletions .devcontainer/scripts/gh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" |
grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/'
}

VERSION=${1:-"$(get_latest_release cli/cli)"}
INSTALL_DIR=${2:-"$HOME/.local/bin"}
CMD=gh
NAME="GitHub CLI"

echo -e "\e[34m»»» 📦 \e[32mInstalling \e[33m$NAME \e[35mv$VERSION\e[0m ..."

mkdir -p $INSTALL_DIR
curl -sSL https://github.com/cli/cli/releases/download/v${VERSION}/gh_${VERSION}_linux_amd64.tar.gz -o /tmp/gh.tar.gz
tar -zxvf /tmp/gh.tar.gz --strip-components 2 -C $INSTALL_DIR gh_${VERSION}_linux_amd64/bin/gh > /dev/null
chmod +x $INSTALL_DIR/gh
rm -rf /tmp/gh.tar.gz

echo -e "\n\e[34m»»» 💾 \e[32mInstalled to: \e[33m$(which $CMD)"
echo -e "\e[34m»»» 💡 \e[32mVersion details: \e[39m$($CMD --version)"
13 changes: 13 additions & 0 deletions .devcontainer/scripts/node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
VERSION=${1:-"24.x"}
CMD=node
NAME="Node.js"

echo -e "\e[34m»»» 📦 \e[32mInstalling \e[33m$NAME \e[35mv$VERSION\e[0m ..."

curl -sL https://deb.nodesource.com/setup_$VERSION | sudo -E bash -
sudo apt install -y nodejs

echo -e "\n\e[34m»»» 💾 \e[32mInstalled to: \e[33m$(which $CMD)"
echo -e "\e[34m»»» 💡 \e[32mNode version details: \e[39m$($CMD --version)"
echo -e "\e[34m»»» 💡 \e[32mNPM version details: \e[39m$(npm --version)"
3 changes: 3 additions & 0 deletions .devcontainer/scripts/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sudo npm install --location=global yarn
Loading
Loading