From aef7b37d3c02a10a47f1e1eb9cfafa1042ac53f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 15 Jun 2025 14:58:51 +0200 Subject: [PATCH] feat: add chrome and decktape --- .../chrome/devcontainer-feature.json | 10 ++++ .github/.devcontainer/chrome/install.sh | 47 +++++++++++++++++++ .../decktape/devcontainer-feature.json | 19 ++++++++ .github/.devcontainer/decktape/install.sh | 42 +++++++++++++++++ .github/.devcontainer/devcontainer.json | 4 ++ 5 files changed, 122 insertions(+) create mode 100644 .github/.devcontainer/chrome/devcontainer-feature.json create mode 100755 .github/.devcontainer/chrome/install.sh create mode 100644 .github/.devcontainer/decktape/devcontainer-feature.json create mode 100755 .github/.devcontainer/decktape/install.sh diff --git a/.github/.devcontainer/chrome/devcontainer-feature.json b/.github/.devcontainer/chrome/devcontainer-feature.json new file mode 100644 index 0000000..34b6a2f --- /dev/null +++ b/.github/.devcontainer/chrome/devcontainer-feature.json @@ -0,0 +1,10 @@ +{ + "id": "chrome", + "version": "1.0.0", + "name": "Chrome", + "description": "Install Google Chrome web browser.", + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils", + "ghcr.io/devcontainers/features/git" + ] +} diff --git a/.github/.devcontainer/chrome/install.sh b/.github/.devcontainer/chrome/install.sh new file mode 100755 index 0000000..3f761bc --- /dev/null +++ b/.github/.devcontainer/chrome/install.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +set -e + +export DEBIAN_FRONTEND=noninteractive + +USERNAME=${USERNAME:-${_REMOTE_USER:-"automatic"}} + +VERSION=${VERSION:-"22"} + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +arch="$(dpkg --print-architecture)" +if [ "${arch}" != "amd64" ] && [ "${arch}" != "arm64" ]; then + echo "Architecture ${arch} unsupported" + exit 2 +fi + +# Determine the appropriate non-root user +if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then + USERNAME="" + POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") + for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do + if id -u "${CURRENT_USER}" >/dev/null 2>&1; then + USERNAME=${CURRENT_USER} + break + fi + done + if [ "${USERNAME}" = "" ]; then + USERNAME=root + fi +elif [ "${USERNAME}" = "none" ] || ! id -u "${USERNAME}" >/dev/null 2>&1; then + USERNAME=root +fi + +install_chrome() { + local arch="$(dpkg --print-architecture)" + check_packages wget gnupg + wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - + echo "deb [arch=${arch}] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list + check_packages google-chrome-stable +} + +apt-get clean && rm -rf /var/lib/apt/lists/* diff --git a/.github/.devcontainer/decktape/devcontainer-feature.json b/.github/.devcontainer/decktape/devcontainer-feature.json new file mode 100644 index 0000000..fccd394 --- /dev/null +++ b/.github/.devcontainer/decktape/devcontainer-feature.json @@ -0,0 +1,19 @@ +{ + "id": "decktape", + "version": "1.0.0", + "name": "decktape", + "description": "Install decktape, a tool for generating PDFs from web pages.", + "options": { + "node": { + "default": "22", + "description": "Select the Node version to install.", + "proposals": ["22"], + "type": "string" + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils", + "ghcr.io/devcontainers/features/git", + "./chrome" + ] +} diff --git a/.github/.devcontainer/decktape/install.sh b/.github/.devcontainer/decktape/install.sh new file mode 100755 index 0000000..429ed83 --- /dev/null +++ b/.github/.devcontainer/decktape/install.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +set -e + +export DEBIAN_FRONTEND=noninteractive + +USERNAME=${USERNAME:-${_REMOTE_USER:-"automatic"}} + +VERSION=${VERSION:-"22"} + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Determine the appropriate non-root user +if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then + USERNAME="" + POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") + for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do + if id -u "${CURRENT_USER}" >/dev/null 2>&1; then + USERNAME=${CURRENT_USER} + break + fi + done + if [ "${USERNAME}" = "" ]; then + USERNAME=root + fi +elif [ "${USERNAME}" = "none" ] || ! id -u "${USERNAME}" >/dev/null 2>&1; then + USERNAME=root +fi + +install_decktape() { + local version=$1 + local url="https://deb.nodesource.com/setup_${version}.x " + check_packages curl ca-certificates + curl --proto '=https' --tlsv1.2 -LsSf ${url} | sudo -E bash - + check_packages nodejs + npm install -g decktape +} + +apt-get clean && rm -rf /var/lib/apt/lists/* diff --git a/.github/.devcontainer/devcontainer.json b/.github/.devcontainer/devcontainer.json index f0f05a5..8a32366 100644 --- a/.github/.devcontainer/devcontainer.json +++ b/.github/.devcontainer/devcontainer.json @@ -39,6 +39,10 @@ "./uv": { "version": "latest" }, + "./chrome": {}, + "./decktape": { + "node": "22" + }, "ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": { "version": "${localEnv:QUARTO_VERSION}", "installTinyTex": "true",