diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f44b48b..09015d1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,6 @@ // "installChromium": "false" // } }, - "postStartCommand": ["bash", "init.sh"], "customizations": { "vscode": { "extensions": [ diff --git a/.github/.devcontainer/Dockerfile b/.github/.devcontainer/Dockerfile index 197ca53..e5eae6b 100644 --- a/.github/.devcontainer/Dockerfile +++ b/.github/.devcontainer/Dockerfile @@ -1,2 +1,2 @@ ARG VARIANT="jammy" -FROM buildpack-deps:${VARIANT}-curl +FROM --platform=linux/amd64 buildpack-deps:${VARIANT}-curl diff --git a/.github/.devcontainer/devcontainer.json b/.github/.devcontainer/devcontainer.json index ae5d8b2..08e3679 100644 --- a/.github/.devcontainer/devcontainer.json +++ b/.github/.devcontainer/devcontainer.json @@ -35,6 +35,9 @@ "ghcr.io/julialang/devcontainer-features/julia:1": { "channel": "release" }, + "./quarto-computing-dependencies": { + "dependencies": "all" + }, "ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": { "version": "prerelease", "installTinyTex": "true", diff --git a/.github/.devcontainer/quarto-computing-dependencies/devcontainer-feature.json b/.github/.devcontainer/quarto-computing-dependencies/devcontainer-feature.json new file mode 100644 index 0000000..e7c688c --- /dev/null +++ b/.github/.devcontainer/quarto-computing-dependencies/devcontainer-feature.json @@ -0,0 +1,26 @@ +{ + "id": "quarto-computing-dependencies", + "version": "1.0.0", + "name": "Install Computing Dependencies for Quarto", + "description": "Install R, Python, and Julia dependencies for Quarto.", + "options": { + "dependencies": { + "type": "string", + "enum": ["all", "r", "python", "julia"], + "default": "all", + "description": "Specify what dependencies to install." + } + }, + "dependsOn": { + "ghcr.io/devcontainers/features/common-utils": {}, + "ghcr.io/rocker-org/devcontainer-features/r-rig": {}, + "ghcr.io/devcontainers/features/python": {}, + "ghcr.io/julialang/devcontainer-features/julia": {} + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils", + "ghcr.io/rocker-org/devcontainer-features/r-rig", + "ghcr.io/devcontainers/features/python", + "ghcr.io/julialang/devcontainer-features/julia" + ] +} diff --git a/.github/.devcontainer/quarto-computing-dependencies/install.sh b/.github/.devcontainer/quarto-computing-dependencies/install.sh new file mode 100755 index 0000000..d61cf37 --- /dev/null +++ b/.github/.devcontainer/quarto-computing-dependencies/install.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +set -e + +export DEBIAN_FRONTEND=noninteractive + +DEPENDENCIES=${DEPENDENCIES:-"all"} + +USERNAME=${USERNAME:-${_REMOTE_USER:-"automatic"}} + +set -e + +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 + +quarto_r_deps() { + su "${USERNAME}" -c "Rscript -e 'pak::pkg_install(\"rmarkdown\")'" +} + +quarto_python_deps() { + su "${USERNAME}" -c "python3 -m pip install jupyter" +} + +quarto_julia_deps() { + su "${USERNAME}" -c "~/.juliaup/bin/julia -e 'using Pkg; Pkg.add(\"IJulia\")'" +} + +case ${DEPENDENCIES} in + all) + quarto_r_deps + quarto_python_deps + quarto_julia_deps + ;; + r) + quarto_r_deps + ;; + python) + quarto_python_deps + ;; + julia) + quarto_julia_deps + ;; +esac diff --git a/init.sh b/init-env.sh old mode 100755 new mode 100644 similarity index 100% rename from init.sh rename to init-env.sh