From b455d2bfeb42f6b0ab1d9f81daa08983f3a19c5e Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Wed, 28 Aug 2024 16:45:50 +0000 Subject: [PATCH 01/10] remove yarn --- tools/devcontainers/sage/.devcontainer/Dockerfile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/devcontainers/sage/.devcontainer/Dockerfile b/tools/devcontainers/sage/.devcontainer/Dockerfile index b3d23383ce..4ed326d07b 100644 --- a/tools/devcontainers/sage/.devcontainer/Dockerfile +++ b/tools/devcontainers/sage/.devcontainer/Dockerfile @@ -11,8 +11,6 @@ ENV DEVCONTAINER_VERSION=${devcontainerVersion} ARG actVersion="0.2.49" # https://github.com/sharkdp/hyperfine ARG hyperfineVersion="1.17.0" -# https://github.com/yarnpkg/berry -ARG yarnVersion="3.6.1" # https://www.npmjs.com/package/@devcontainers/cli ARG devcontainerCliVersion="0.50.2" # https://pypi.org/project/poetry @@ -83,9 +81,6 @@ RUN groupadd docker \ # Fix Vault CLI # See https://github.com/hashicorp/vault/issues/10924 && setcap -r /usr/bin/vault \ - # Install Yarn - && corepack enable yarn \ - && corepack prepare "yarn@${yarnVersion}" --activate \ # Instal pnpm # && curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=${pnpmVersion} bash - \ && corepack enable pnpm \ @@ -152,9 +147,7 @@ RUN useradd -m $user \ " . ./dev-env.sh" \ " workspace-initialize-env" \ "fi" \ - "" | tee -a "/home/$user/.bashrc" \ - # Set the default version of Yarn - && corepack prepare "yarn@${yarnVersion}" --activate + "" | tee -a "/home/$user/.bashrc" # Install SonarScanner CLI ARG SONAR_SCANNER_HOME=/opt/sonar-scanner From 980ad8d24676ac2dc988bf767be25427f6ae4ec9 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Wed, 28 Aug 2024 16:51:16 +0000 Subject: [PATCH 02/10] install pnpm globally --- tools/devcontainers/sage/.devcontainer/Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/devcontainers/sage/.devcontainer/Dockerfile b/tools/devcontainers/sage/.devcontainer/Dockerfile index 4ed326d07b..f33b648010 100644 --- a/tools/devcontainers/sage/.devcontainer/Dockerfile +++ b/tools/devcontainers/sage/.devcontainer/Dockerfile @@ -24,7 +24,7 @@ ARG renvVersion="1.0.0" # https://www.npmjs.com/package/playwright ARG playwrightVersion="1.40.1" # https://github.com/pnpm/pnpm/releases -ARG pnpmVersion="8.7.0" +ARG pnpmVersion="9.9.0" # https://github.com/SonarSource/sonar-scanner-cli/releases ARG sonarScannerVersion="5.0.1.3006" # https://github.com/hadolint/hadolint @@ -82,9 +82,7 @@ RUN groupadd docker \ # See https://github.com/hashicorp/vault/issues/10924 && setcap -r /usr/bin/vault \ # Instal pnpm - # && curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=${pnpmVersion} bash - \ - && corepack enable pnpm \ - && corepack prepare "pnpm@${pnpmVersion}" --activate \ + && corepack install --global "pnpm@${pnpmVersion}" \ # Install @devcontainers/cli && npm install -g "@devcontainers/cli@${devcontainerCliVersion}" \ # Install act From 940a8aacf69da984083764cea890a4045fec8c00 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Wed, 28 Aug 2024 18:03:03 +0000 Subject: [PATCH 03/10] update a few tools --- .../sage/.devcontainer/Dockerfile | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/devcontainers/sage/.devcontainer/Dockerfile b/tools/devcontainers/sage/.devcontainer/Dockerfile index f33b648010..d57cd9fcaf 100644 --- a/tools/devcontainers/sage/.devcontainer/Dockerfile +++ b/tools/devcontainers/sage/.devcontainer/Dockerfile @@ -8,19 +8,21 @@ ARG devcontainerVersion="" ENV DEVCONTAINER_VERSION=${devcontainerVersion} # https://github.com/nektos/act -ARG actVersion="0.2.49" +ARG actVersion="0.2.65" # https://github.com/sharkdp/hyperfine -ARG hyperfineVersion="1.17.0" +ARG hyperfineVersion="1.18.0" # https://www.npmjs.com/package/@devcontainers/cli ARG devcontainerCliVersion="0.50.2" # https://pypi.org/project/poetry -ARG poetryVersion="1.8.2" +ARG poetryVersion="1.8.3" # https://docs.posit.co/resources/install-r/#specify-r-version ARG rVersion="4.2.3" # https://aquasecurity.github.io/trivy -ARG trivyVersion="0.44.1" +ARG trivyVersion="0.54.1" # https://github.com/rstudio/renv ARG renvVersion="1.0.0" +# https://nodejs.org/en/about/previous-releases +ARG nodeVersionMajor="20" # https://www.npmjs.com/package/playwright ARG playwrightVersion="1.40.1" # https://github.com/pnpm/pnpm/releases @@ -51,12 +53,8 @@ RUN groupadd docker \ # Required by Hadolint shellcheck \ # Add Node.js repository - && mkdir -p /etc/apt/keyrings \ - && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \ - | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ - && NODE_MAJOR=18 \ - && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \ - | tee /etc/apt/sources.list.d/nodesource.list \ + && curl -fsSL https://deb.nodesource.com/setup_${nodeVersionMajor}.x -o nodesource_setup.sh \ + && bash nodesource_setup.sh \ # Add Hadolint && curl https://github.com/hadolint/hadolint/releases/download/v${hadolintVersion}/hadolint-Linux-x86_64 -o hadolint \ && mv hadolint /usr/local/bin/. \ From cfb7e2f8cdc2de0ee1f0e80ed6103b8ab9ac1903 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Wed, 28 Aug 2024 21:52:05 +0000 Subject: [PATCH 04/10] update --- .../sage/.devcontainer/Dockerfile | 14 ++++++++------ .../sage/.devcontainer/devcontainer.json | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/tools/devcontainers/sage/.devcontainer/Dockerfile b/tools/devcontainers/sage/.devcontainer/Dockerfile index d57cd9fcaf..107f9b6639 100644 --- a/tools/devcontainers/sage/.devcontainer/Dockerfile +++ b/tools/devcontainers/sage/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -ARG imageVersion=jammy-20240227 +ARG imageVersion=jammy-20240808 FROM ubuntu:$imageVersion # Safer bash scripts with 'set -euxo pipefail' @@ -52,7 +52,7 @@ RUN groupadd docker \ xz-utils tk-dev libffi-dev liblzma-dev \ # Required by Hadolint shellcheck \ - # Add Node.js repository + # Add Node.js && curl -fsSL https://deb.nodesource.com/setup_${nodeVersionMajor}.x -o nodesource_setup.sh \ && bash nodesource_setup.sh \ # Add Hadolint @@ -79,8 +79,8 @@ RUN groupadd docker \ # Fix Vault CLI # See https://github.com/hashicorp/vault/issues/10924 && setcap -r /usr/bin/vault \ - # Instal pnpm - && corepack install --global "pnpm@${pnpmVersion}" \ + # Enable corepack + && corepack enable \ # Install @devcontainers/cli && npm install -g "@devcontainers/cli@${devcontainerCliVersion}" \ # Install act @@ -143,7 +143,9 @@ RUN useradd -m $user \ " . ./dev-env.sh" \ " workspace-initialize-env" \ "fi" \ - "" | tee -a "/home/$user/.bashrc" + "" | tee -a "/home/$user/.bashrc" \ + # Install the default version of pnpm + && corepack install --global "pnpm@${pnpmVersion}" # Install SonarScanner CLI ARG SONAR_SCANNER_HOME=/opt/sonar-scanner @@ -165,7 +167,7 @@ RUN npx playwright@${playwrightVersion} install --with-deps \ chromium \ firefox \ webkit \ - # Install pyenv as the user + # Install pyenv as the non-root user && curl https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash - # Install Python environments diff --git a/tools/devcontainers/sage/.devcontainer/devcontainer.json b/tools/devcontainers/sage/.devcontainer/devcontainer.json index 209ea53e6a..98e4d0ddd9 100644 --- a/tools/devcontainers/sage/.devcontainer/devcontainer.json +++ b/tools/devcontainers/sage/.devcontainer/devcontainer.json @@ -1,13 +1,16 @@ { "name": "Sage Dev Container", - "build": { - "dockerfile": "Dockerfile", - "args": { - "imageVersion": "jammy-20230624", + "build": { + "dockerfile": "Dockerfile", + "args": { + "imageVersion": "jammy-20240808", "devcontainerVersion": "${localEnv:DEVCONTAINER_VERSION}" - } - }, - "remoteUser": "vscode", + } + }, + "remoteUser": "vscode", "shutdownAction": "stopContainer", - "runArgs": ["--name", "sage_devcontainer"] + "runArgs": [ + "--name", + "sage_devcontainer" + ] } \ No newline at end of file From d7fc5c82802fd3decaca272c758bb9de645a4c22 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 29 Aug 2024 16:50:37 +0000 Subject: [PATCH 05/10] split the dev container Dockerfile into logical parts --- tools/devcontainers/build-image.sh | 7 - .../sage/.devcontainer/Dockerfile | 147 ++++++++++-------- .../sage/.devcontainer/README.md | 4 + .../sage/.devcontainer/devcontainer.json | 4 +- 4 files changed, 84 insertions(+), 78 deletions(-) delete mode 100755 tools/devcontainers/build-image.sh diff --git a/tools/devcontainers/build-image.sh b/tools/devcontainers/build-image.sh deleted file mode 100755 index beafacef5a..0000000000 --- a/tools/devcontainers/build-image.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -# This script must be run from the folder that includes it. - -devcontainer build \ - --image-name ghcr.io/sage-bionetworks/sage-devcontainer:testing \ - --workspace-folder sage diff --git a/tools/devcontainers/sage/.devcontainer/Dockerfile b/tools/devcontainers/sage/.devcontainer/Dockerfile index 107f9b6639..0c96525471 100644 --- a/tools/devcontainers/sage/.devcontainer/Dockerfile +++ b/tools/devcontainers/sage/.devcontainer/Dockerfile @@ -1,12 +1,11 @@ +# Base image ARG imageVersion=jammy-20240808 FROM ubuntu:$imageVersion -# Safer bash scripts with 'set -euxo pipefail' +# Set safer bash scripts SHELL ["/bin/bash", "-euxo", "pipefail", "-c"] -ARG devcontainerVersion="" -ENV DEVCONTAINER_VERSION=${devcontainerVersion} - +# Arguments # https://github.com/nektos/act ARG actVersion="0.2.65" # https://github.com/sharkdp/hyperfine @@ -31,12 +30,19 @@ ARG pnpmVersion="9.9.0" ARG sonarScannerVersion="5.0.1.3006" # https://github.com/hadolint/hadolint ARG hadolintVersion="2.12.0" +# The version of this dev container image +ARG devcontainerVersion="" +# The username of the non-root user +ARG user=vscode + +# Set environment variables +ENV DEVCONTAINER_VERSION=${devcontainerVersion} \ + LANG=en_US.UTF-8 \ + LC_ALL=en_US.UTF-8 -# Create the docker group so that we can assign it to the user. -# This is to enable the non-root user to use the command `docker`. +# Install system packages # hadolint ignore=DL3008,DL3013 -RUN groupadd docker \ - && apt-get update -qq -y && export DEBIAN_FRONTEND=noninteractive \ +RUN apt-get update -qq -y && export DEBIAN_FRONTEND=noninteractive \ && apt-get install --no-install-recommends -qq -y \ ca-certificates curl git bash-completion gnupg2 lsb-release ssh sudo \ python3-pip python3-dev python-is-python3 openjdk-17-jdk \ @@ -52,13 +58,9 @@ RUN groupadd docker \ xz-utils tk-dev libffi-dev liblzma-dev \ # Required by Hadolint shellcheck \ - # Add Node.js + # Add Node.js repository && curl -fsSL https://deb.nodesource.com/setup_${nodeVersionMajor}.x -o nodesource_setup.sh \ && bash nodesource_setup.sh \ - # Add Hadolint - && curl https://github.com/hadolint/hadolint/releases/download/v${hadolintVersion}/hadolint-Linux-x86_64 -o hadolint \ - && mv hadolint /usr/local/bin/. \ - && chmod +x /usr/local/bin/hadolint \ # Add GitHub CLI repository && curl -sSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \ gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg \ @@ -70,64 +72,65 @@ RUN groupadd docker \ # Add hashicorp repository && curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - \ && echo "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list \ - # Install extra packages + # Install additional packages && apt-get update -qq -y \ - && apt-get install --no-install-recommends -qq -y \ - nodejs gh ngrok \ - terraform \ - vault \ + && apt-get install --no-install-recommends -qq -y nodejs gh ngrok terraform vault \ + # Enable corepack + && corepack enable \ # Fix Vault CLI # See https://github.com/hashicorp/vault/issues/10924 && setcap -r /usr/bin/vault \ - # Enable corepack - && corepack enable \ - # Install @devcontainers/cli - && npm install -g "@devcontainers/cli@${devcontainerCliVersion}" \ - # Install act - && curl "https://raw.githubusercontent.com/nektos/act/v${actVersion}/install.sh" | bash - \ - # Install hyperfine - && curl -sSL "https://github.com/sharkdp/hyperfine/releases/download/v${hyperfineVersion}/hyperfine_${hyperfineVersion}_amd64.deb" \ - -o /tmp/hyperfine.deb \ - && apt-get install --no-install-recommends -qq -y /tmp/hyperfine.deb \ - && rm -fr /tmp/hyperfine.deb \ - # Install AWS CLI - && curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip \ + # Set up UTF-8 locale + && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen + +# Install Poetry +RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/etc/poetry python3 - --version "${poetryVersion}" \ + && ln -s /etc/poetry/bin/poetry /usr/local/bin/. + +# Install R +RUN curl "https://cdn.rstudio.com/r/ubuntu-2204/pkgs/r-${rVersion}_1_amd64.deb" -o /tmp/r_amd64.deb \ + && gdebi --non-interactive /tmp/r_amd64.deb \ + && rm -fr /tmp/r_amd64.deb \ + && ln -s /opt/R/${rVersion}/bin/R /usr/local/bin/R \ + && ln -s /opt/R/${rVersion}/bin/Rscript /usr/local/bin/Rscript \ + && R -e "options(repos = c(POSIT = \"https://packagemanager.posit.co/all/__linux__/jammy/latest\", CRAN = \"https://mirror.las.iastate.edu/CRAN\")); install.packages(\"renv\", version = \"${renvVersion}\")" + +# Install Trivy +RUN curl -fsSL "https://github.com/aquasecurity/trivy/releases/download/v${trivyVersion}/trivy_${trivyVersion}_Linux-64bit.deb" -o /tmp/trivy.deb \ + && dpkg -i /tmp/trivy.deb \ + && rm -fr /tmp/trivy.deb + +# Install act +RUN curl "https://raw.githubusercontent.com/nektos/act/v${actVersion}/install.sh" | bash - + +# Install @devcontainers/cli +RUN npm install -g "@devcontainers/cli@${devcontainerCliVersion}" + +# Install AWS CLI +RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip \ && unzip awscliv2.zip \ && ./aws/install \ && rm -fr awscliv2.zip ./aws \ # Add AWS Session Manager plugin && curl -fsSL "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o /tmp/session-manager-plugin.deb \ && dpkg -i /tmp/session-manager-plugin.deb \ - && rm -fr /tmp/session-manager-plugin.deb \ - # Install Poetry - && curl -sSL https://install.python-poetry.org | POETRY_HOME=/etc/poetry python3 - --version "${poetryVersion}" \ - && ln -s /etc/poetry/bin/poetry /usr/local/bin/. \ - # Install R - && curl "https://cdn.rstudio.com/r/ubuntu-2204/pkgs/r-${rVersion}_1_amd64.deb" -o /tmp/r_amd64.deb \ - && gdebi --non-interactive /tmp/r_amd64.deb \ - && rm -fr /tmp/r_amd64.deb \ - && ln -s /opt/R/${rVersion}/bin/R /usr/local/bin/R \ - && ln -s /opt/R/${rVersion}/bin/Rscript /usr/local/bin/Rscript \ - && R -e "options(repos = c(POSIT = \"https://packagemanager.posit.co/all/__linux__/jammy/latest\", CRAN = \"https://mirror.las.iastate.edu/CRAN\")); install.packages(\"renv\", version = \"${renvVersion}\")" \ - # Install Trivy - && curl -fsSL "https://github.com/aquasecurity/trivy/releases/download/v${trivyVersion}/trivy_${trivyVersion}_Linux-64bit.deb" -o /tmp/trivy.deb \ - && dpkg -i /tmp/trivy.deb \ - && rm -fr /tmp/trivy.deb \ - # Cleanup - && apt-get -y autoclean \ - && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* \ - && pip install --no-cache-dir pipenv + && rm -fr /tmp/session-manager-plugin.deb -# Setting up a UTF-8 locale -RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \ - && locale-gen -ENV LANG=en_US.UTF-8 \ - LC_ALL=en_US.UTF-8 +# Install Hadolint +RUN curl https://github.com/hadolint/hadolint/releases/download/v${hadolintVersion}/hadolint-Linux-x86_64 -o hadolint \ + && mv hadolint /usr/local/bin/. \ + && chmod +x /usr/local/bin/hadolint -ARG user=vscode +# Install hyperfine +RUN curl -sSL "https://github.com/sharkdp/hyperfine/releases/download/v${hyperfineVersion}/hyperfine_${hyperfineVersion}_amd64.deb" \ + -o /tmp/hyperfine.deb \ + && apt-get install --no-install-recommends -qq -y /tmp/hyperfine.deb \ + && rm -fr /tmp/hyperfine.deb + +# Create non-root user RUN useradd -m $user \ && echo "$user:$user" | chpasswd \ + && groupadd docker \ && usermod -a --groups docker,sudo $user \ && usermod --shell /bin/bash $user \ && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \ @@ -143,9 +146,7 @@ RUN useradd -m $user \ " . ./dev-env.sh" \ " workspace-initialize-env" \ "fi" \ - "" | tee -a "/home/$user/.bashrc" \ - # Install the default version of pnpm - && corepack install --global "pnpm@${pnpmVersion}" + "" | tee -a "/home/$user/.bashrc" # Install SonarScanner CLI ARG SONAR_SCANNER_HOME=/opt/sonar-scanner @@ -159,23 +160,31 @@ RUN curl https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-s && chown -R ${user}:${user} "${SONAR_SCANNER_HOME}" \ && chmod -R 777 "${SONAR_USER_HOME}" +# Cleanup +RUN apt-get -y autoclean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* \ + && pip install --no-cache-dir pipenv + +# Switch to non-root user USER $user -# Install browsers used for e2e testing with Playwright +# Install the global version of pnpm +RUN corepack install --global "pnpm@${pnpmVersion}" + +# Install browsers for Playwright # Note: The version of Playwright should be the same as the one used by your project (package.json) RUN npx playwright@${playwrightVersion} install --with-deps \ chromium \ firefox \ - webkit \ - # Install pyenv as the non-root user - && curl https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash - + webkit + +# Install pyenv +RUN curl https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash - -# Install Python environments +# Set up Python environments ENV PYENV_ROOT /home/${user}/.pyenv ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH -RUN pyenv install \ - 3.9.2 \ - 3.10.14 \ - 3.11.8 +RUN pyenv install 3.9.2 3.10.14 3.11.8 CMD ["bash"] \ No newline at end of file diff --git a/tools/devcontainers/sage/.devcontainer/README.md b/tools/devcontainers/sage/.devcontainer/README.md index e0e0e4b767..50be24a3c7 100644 --- a/tools/devcontainers/sage/.devcontainer/README.md +++ b/tools/devcontainers/sage/.devcontainer/README.md @@ -1 +1,5 @@ +# Sage Dev Container + +Learn how to build and run dev containers with the devcontainer CLI: + https://code.visualstudio.com/docs/remote/devcontainer-cli \ No newline at end of file diff --git a/tools/devcontainers/sage/.devcontainer/devcontainer.json b/tools/devcontainers/sage/.devcontainer/devcontainer.json index 98e4d0ddd9..99c5cf5d0b 100644 --- a/tools/devcontainers/sage/.devcontainer/devcontainer.json +++ b/tools/devcontainers/sage/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "name": "Sage Dev Container", + "name": "Sage Dev Container (Test)", "build": { "dockerfile": "Dockerfile", "args": { @@ -11,6 +11,6 @@ "shutdownAction": "stopContainer", "runArgs": [ "--name", - "sage_devcontainer" + "sage_devcontainer_testing" ] } \ No newline at end of file From 4dc475b91d16b15cdf643468b82c83723c65c4fa Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 29 Aug 2024 18:36:00 +0000 Subject: [PATCH 06/10] improve image --- .../sage/.devcontainer/Dockerfile | 51 +++++++------------ .../sage/.devcontainer/devcontainer.json | 2 +- 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/tools/devcontainers/sage/.devcontainer/Dockerfile b/tools/devcontainers/sage/.devcontainer/Dockerfile index 0c96525471..56685e849b 100644 --- a/tools/devcontainers/sage/.devcontainer/Dockerfile +++ b/tools/devcontainers/sage/.devcontainer/Dockerfile @@ -5,7 +5,7 @@ FROM ubuntu:$imageVersion # Set safer bash scripts SHELL ["/bin/bash", "-euxo", "pipefail", "-c"] -# Arguments +# Image arguments # https://github.com/nektos/act ARG actVersion="0.2.65" # https://github.com/sharkdp/hyperfine @@ -22,8 +22,6 @@ ARG trivyVersion="0.54.1" ARG renvVersion="1.0.0" # https://nodejs.org/en/about/previous-releases ARG nodeVersionMajor="20" -# https://www.npmjs.com/package/playwright -ARG playwrightVersion="1.40.1" # https://github.com/pnpm/pnpm/releases ARG pnpmVersion="9.9.0" # https://github.com/SonarSource/sonar-scanner-cli/releases @@ -81,20 +79,23 @@ RUN apt-get update -qq -y && export DEBIAN_FRONTEND=noninteractive \ # See https://github.com/hashicorp/vault/issues/10924 && setcap -r /usr/bin/vault \ # Set up UTF-8 locale - && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen + && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen \ + # Install R (must be done before clearing the apt cache) + && curl "https://cdn.rstudio.com/r/ubuntu-2204/pkgs/r-${rVersion}_1_amd64.deb" -o /tmp/r_amd64.deb \ + && gdebi --non-interactive /tmp/r_amd64.deb \ + && rm -fr /tmp/r_amd64.deb \ + && ln -s /opt/R/${rVersion}/bin/R /usr/local/bin/R \ + && ln -s /opt/R/${rVersion}/bin/Rscript /usr/local/bin/Rscript \ + && R -e "options(repos = c(POSIT = \"https://packagemanager.posit.co/all/__linux__/jammy/latest\", CRAN = \"https://mirror.las.iastate.edu/CRAN\")); install.packages(\"renv\", version = \"${renvVersion}\")" \ + # Cleanup + && apt-get -y autoclean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* # Install Poetry RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/etc/poetry python3 - --version "${poetryVersion}" \ && ln -s /etc/poetry/bin/poetry /usr/local/bin/. -# Install R -RUN curl "https://cdn.rstudio.com/r/ubuntu-2204/pkgs/r-${rVersion}_1_amd64.deb" -o /tmp/r_amd64.deb \ - && gdebi --non-interactive /tmp/r_amd64.deb \ - && rm -fr /tmp/r_amd64.deb \ - && ln -s /opt/R/${rVersion}/bin/R /usr/local/bin/R \ - && ln -s /opt/R/${rVersion}/bin/Rscript /usr/local/bin/Rscript \ - && R -e "options(repos = c(POSIT = \"https://packagemanager.posit.co/all/__linux__/jammy/latest\", CRAN = \"https://mirror.las.iastate.edu/CRAN\")); install.packages(\"renv\", version = \"${renvVersion}\")" - # Install Trivy RUN curl -fsSL "https://github.com/aquasecurity/trivy/releases/download/v${trivyVersion}/trivy_${trivyVersion}_Linux-64bit.deb" -o /tmp/trivy.deb \ && dpkg -i /tmp/trivy.deb \ @@ -103,9 +104,6 @@ RUN curl -fsSL "https://github.com/aquasecurity/trivy/releases/download/v${trivy # Install act RUN curl "https://raw.githubusercontent.com/nektos/act/v${actVersion}/install.sh" | bash - -# Install @devcontainers/cli -RUN npm install -g "@devcontainers/cli@${devcontainerCliVersion}" - # Install AWS CLI RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip \ && unzip awscliv2.zip \ @@ -116,6 +114,9 @@ RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zi && dpkg -i /tmp/session-manager-plugin.deb \ && rm -fr /tmp/session-manager-plugin.deb +# Install the devcontainer CLI +RUN npm install -g "@devcontainers/cli@${devcontainerCliVersion}" + # Install Hadolint RUN curl https://github.com/hadolint/hadolint/releases/download/v${hadolintVersion}/hadolint-Linux-x86_64 -o hadolint \ && mv hadolint /usr/local/bin/. \ @@ -160,31 +161,17 @@ RUN curl https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-s && chown -R ${user}:${user} "${SONAR_SCANNER_HOME}" \ && chmod -R 777 "${SONAR_USER_HOME}" -# Cleanup -RUN apt-get -y autoclean \ - && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* \ - && pip install --no-cache-dir pipenv - # Switch to non-root user USER $user # Install the global version of pnpm RUN corepack install --global "pnpm@${pnpmVersion}" -# Install browsers for Playwright -# Note: The version of Playwright should be the same as the one used by your project (package.json) -RUN npx playwright@${playwrightVersion} install --with-deps \ - chromium \ - firefox \ - webkit - -# Install pyenv -RUN curl https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash - - # Set up Python environments ENV PYENV_ROOT /home/${user}/.pyenv ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH -RUN pyenv install 3.9.2 3.10.14 3.11.8 +RUN pip install --no-cache-dir pipenv \ + && curl https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash - \ + && pyenv install 3.9.2 3.10.14 3.11.8 CMD ["bash"] \ No newline at end of file diff --git a/tools/devcontainers/sage/.devcontainer/devcontainer.json b/tools/devcontainers/sage/.devcontainer/devcontainer.json index 99c5cf5d0b..99955be6b7 100644 --- a/tools/devcontainers/sage/.devcontainer/devcontainer.json +++ b/tools/devcontainers/sage/.devcontainer/devcontainer.json @@ -11,6 +11,6 @@ "shutdownAction": "stopContainer", "runArgs": [ "--name", - "sage_devcontainer_testing" + "sage_devcontainer_test" ] } \ No newline at end of file From 8551b13e5b258e8dab332eeedba2f9c6d7b599cc Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 29 Aug 2024 20:15:30 +0000 Subject: [PATCH 07/10] move README --- .devcontainer/devcontainer.json | 2 +- .../sage/.devcontainer/README.md | 5 ----- tools/devcontainers/sage/README.md | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) delete mode 100644 tools/devcontainers/sage/.devcontainer/README.md create mode 100644 tools/devcontainers/sage/README.md diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1352fba0e2..0e97371af8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Sage Dev Container", - "image": "ghcr.io/sage-bionetworks/sage-devcontainer:3f79a5d", + "image": "ghcr.io/sage-bionetworks/sage-devcontainer:test", "containerEnv": { "NX_BASE": "${localEnv:NX_BASE}", "NX_BRANCH": "${localEnv:NX_BRANCH}", diff --git a/tools/devcontainers/sage/.devcontainer/README.md b/tools/devcontainers/sage/.devcontainer/README.md deleted file mode 100644 index 50be24a3c7..0000000000 --- a/tools/devcontainers/sage/.devcontainer/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Sage Dev Container - -Learn how to build and run dev containers with the devcontainer CLI: - -https://code.visualstudio.com/docs/remote/devcontainer-cli \ No newline at end of file diff --git a/tools/devcontainers/sage/README.md b/tools/devcontainers/sage/README.md new file mode 100644 index 0000000000..6a934e4167 --- /dev/null +++ b/tools/devcontainers/sage/README.md @@ -0,0 +1,19 @@ +# Sage Dev Container + +Learn how to build and run dev containers with the devcontainer CLI: + +https://code.visualstudio.com/docs/remote/devcontainer-cli + +# Build the image with devcontainer + +```console +devcontainer build \ + --image-name ghcr.io/sage-bionetworks/sage-devcontainer:test \ + --workspace-folder ../sage +``` + +# Build the image with Docker + +```console +docker build -t ghcr.io/sage-bionetworks/sage-devcontainer:test .devcontainer/ +``` \ No newline at end of file From d8ad47e3d33cfceb411f1c265c8922ead2533045 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Thu, 29 Aug 2024 23:44:30 +0000 Subject: [PATCH 08/10] parametrize the versions of python installed --- tools/devcontainers/sage/.devcontainer/Dockerfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/devcontainers/sage/.devcontainer/Dockerfile b/tools/devcontainers/sage/.devcontainer/Dockerfile index 56685e849b..7fc7e3ed60 100644 --- a/tools/devcontainers/sage/.devcontainer/Dockerfile +++ b/tools/devcontainers/sage/.devcontainer/Dockerfile @@ -5,7 +5,7 @@ FROM ubuntu:$imageVersion # Set safer bash scripts SHELL ["/bin/bash", "-euxo", "pipefail", "-c"] -# Image arguments +# List of build arguments # https://github.com/nektos/act ARG actVersion="0.2.65" # https://github.com/sharkdp/hyperfine @@ -22,8 +22,12 @@ ARG trivyVersion="0.54.1" ARG renvVersion="1.0.0" # https://nodejs.org/en/about/previous-releases ARG nodeVersionMajor="20" +# https://pypi.org/project/pipenv/ +ARG pipenvVersion="2024.0.1" # https://github.com/pnpm/pnpm/releases ARG pnpmVersion="9.9.0" +# List of Python versions separated by spaces +ARG pyenvPythonVersions="3.9.2 3.10.14 3.11.8" # https://github.com/SonarSource/sonar-scanner-cli/releases ARG sonarScannerVersion="5.0.1.3006" # https://github.com/hadolint/hadolint @@ -31,7 +35,7 @@ ARG hadolintVersion="2.12.0" # The version of this dev container image ARG devcontainerVersion="" # The username of the non-root user -ARG user=vscode +ARG user="vscode" # Set environment variables ENV DEVCONTAINER_VERSION=${devcontainerVersion} \ @@ -39,7 +43,7 @@ ENV DEVCONTAINER_VERSION=${devcontainerVersion} \ LC_ALL=en_US.UTF-8 # Install system packages -# hadolint ignore=DL3008,DL3013 +# hadolint ignore=DL3008 RUN apt-get update -qq -y && export DEBIAN_FRONTEND=noninteractive \ && apt-get install --no-install-recommends -qq -y \ ca-certificates curl git bash-completion gnupg2 lsb-release ssh sudo \ @@ -170,8 +174,8 @@ RUN corepack install --global "pnpm@${pnpmVersion}" # Set up Python environments ENV PYENV_ROOT /home/${user}/.pyenv ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH -RUN pip install --no-cache-dir pipenv \ +RUN pip install --no-cache-dir pipenv==${pipenvVersion} \ && curl https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash - \ - && pyenv install 3.9.2 3.10.14 3.11.8 + && pyenv install ${pyenvPythonVersions} CMD ["bash"] \ No newline at end of file From eff31e8559352063162b51d897a27c9fc0603ba3 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Fri, 30 Aug 2024 00:02:39 +0000 Subject: [PATCH 09/10] update devcontainer CLI version --- .github/actions/setup-dev-container/action.yml | 2 +- .github/workflows/build-devcontainer-image.yml | 2 +- .github/workflows/schematic-api-ci.yml | 2 +- tools/devcontainers/sage/.devcontainer/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-dev-container/action.yml b/.github/actions/setup-dev-container/action.yml index 610ad770ff..481d955516 100644 --- a/.github/actions/setup-dev-container/action.yml +++ b/.github/actions/setup-dev-container/action.yml @@ -45,7 +45,7 @@ runs: - name: Install the Dev Container CLI shell: bash - run: npm install -g @devcontainers/cli@0.49.0 + run: npm install -g @devcontainers/cli@0.69.0 - name: Start the dev container shell: bash diff --git a/.github/workflows/build-devcontainer-image.yml b/.github/workflows/build-devcontainer-image.yml index bd703b3a3c..374925428d 100644 --- a/.github/workflows/build-devcontainer-image.yml +++ b/.github/workflows/build-devcontainer-image.yml @@ -66,7 +66,7 @@ jobs: export DEVCONTAINER_VERSION=${{ steps.prep.outputs.devcontainer_version }} # Build the image - npm install -g @devcontainers/cli + npm install -g @devcontainers/cli@0.69.0 devcontainer build \ --image-name "${IMAGE_NAME}:${IMAGE_TAG}" \ --workspace-folder "${WORKSPACE_FOLDER}" diff --git a/.github/workflows/schematic-api-ci.yml b/.github/workflows/schematic-api-ci.yml index 2c5e756e73..2129cb116e 100644 --- a/.github/workflows/schematic-api-ci.yml +++ b/.github/workflows/schematic-api-ci.yml @@ -69,7 +69,7 @@ jobs: ${{ runner.os }}-gradle- - name: Install the Dev Container CLI - run: npm install -g @devcontainers/cli@0.49.0 + run: npm install -g @devcontainers/cli@0.69.0 - name: Start the dev container run: | diff --git a/tools/devcontainers/sage/.devcontainer/Dockerfile b/tools/devcontainers/sage/.devcontainer/Dockerfile index 7fc7e3ed60..2b46429dda 100644 --- a/tools/devcontainers/sage/.devcontainer/Dockerfile +++ b/tools/devcontainers/sage/.devcontainer/Dockerfile @@ -11,7 +11,7 @@ ARG actVersion="0.2.65" # https://github.com/sharkdp/hyperfine ARG hyperfineVersion="1.18.0" # https://www.npmjs.com/package/@devcontainers/cli -ARG devcontainerCliVersion="0.50.2" +ARG devcontainerCliVersion="0.69.0" # https://pypi.org/project/poetry ARG poetryVersion="1.8.3" # https://docs.posit.co/resources/install-r/#specify-r-version From aa9e9e6f26718b9ede6a51dd9ca156a923ab29eb Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Fri, 30 Aug 2024 00:11:05 +0000 Subject: [PATCH 10/10] restore active dev container version --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0e97371af8..1352fba0e2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Sage Dev Container", - "image": "ghcr.io/sage-bionetworks/sage-devcontainer:test", + "image": "ghcr.io/sage-bionetworks/sage-devcontainer:3f79a5d", "containerEnv": { "NX_BASE": "${localEnv:NX_BASE}", "NX_BRANCH": "${localEnv:NX_BRANCH}",