From 1c8fd2a9405772bdeacce4cda095daa2656f8ee8 Mon Sep 17 00:00:00 2001 From: Chuck Lantz Date: Tue, 11 Aug 2020 12:57:47 -0700 Subject: [PATCH] Update to 0.134.0 definition --- .devcontainer/Dockerfile | 89 ++++----- .devcontainer/devcontainer.json | 51 ++++-- .../library-scripts/common-debian.sh | 171 ++++++++++++++++++ .../library-scripts/gradle-debian.sh | 70 +++++++ .devcontainer/library-scripts/maven-debian.sh | 75 ++++++++ .devcontainer/library-scripts/node-debian.sh | 102 +++++++++++ .devcontainer/maven-settings.xml | 6 - 7 files changed, 487 insertions(+), 77 deletions(-) create mode 100644 .devcontainer/library-scripts/common-debian.sh create mode 100644 .devcontainer/library-scripts/gradle-debian.sh create mode 100644 .devcontainer/library-scripts/maven-debian.sh create mode 100644 .devcontainer/library-scripts/node-debian.sh delete mode 100644 .devcontainer/maven-settings.xml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9f4482a..2849abc 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,61 +1,46 @@ -#------------------------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. -#------------------------------------------------------------------------------------------------------------- +# Update the VARIANT arg in devcontainer.json to pick a Java version >= 11 +ARG VARIANT=11 +FROM openjdk:${VARIANT}-jdk-buster -FROM mcr.microsoft.com/java/jdk:8u232-zulu-ubuntu - -# Avoid warnings by switching to noninteractive -ENV DEBIAN_FRONTEND=noninteractive - -# 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. +# Options for setup script +ARG INSTALL_ZSH="true" +ARG UPGRADE_PACKAGES="false" ARG USERNAME=vscode ARG USER_UID=1000 ARG USER_GID=$USER_UID -# Maven settings +# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. +COPY library-scripts/*.sh /tmp/library-scripts/ +RUN /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \ + && if [ ! -d "/docker-java-home" ]; then ln -s "${JAVA_HOME}" /docker-java-home; fi \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts/common-debian.sh + +# [Optional] Install Maven +ARG INSTALL_MAVEN="false" ARG MAVEN_VERSION=3.6.3 -ARG MAVEN_SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0 +ARG MAVEN_DOWNLOAD_SHA="no-check" ENV MAVEN_HOME=/usr/local/share/maven -COPY maven-settings.xml ${MAVEN_HOME}/ref/ +RUN if [ "${INSTALL_MAVEN}" = "true" ]; then /bin/bash /tmp/library-scripts/maven-debian.sh ${MAVEN_VERSION} ${MAVEN_HOME} ${USERNAME} ${MAVEN_DOWNLOAD_SHA}; fi \ + && rm -f /tmp/library-scripts/maven-debian.sh -# Configure apt and install packages -RUN apt-get update \ - && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ - # - # Verify git and needed tools are installed - && apt-get -y install \ - git \ - iproute2 \ - procps \ - curl \ - apt-transport-https \ - gnupg2 \ - lsb-release \ - # - # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. - && groupadd --gid $USER_GID $USERNAME \ - && useradd -s /bin/bash --uid ${USER_UID} --gid ${USER_GID} -m $USERNAME \ - # [Optional] Add sudo support for the non-root user - && apt-get install -y sudo \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - # - # Install Maven - && mkdir -p ${MAVEN_HOME} ${MAVEN_HOME}/ref \ - && curl -fsSL -o /tmp/apache-maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ - && echo "${MAVEN_SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \ - && tar -xzf /tmp/apache-maven.tar.gz -C ${MAVEN_HOME} --strip-components=1 \ - && rm -f /tmp/apache-maven.tar.gz \ - && ln -s ${MAVEN_HOME}/bin/mvn /usr/local/bin/mvn \ - # - # Clean up - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* +# [Optional] Install Gradle +ARG INSTALL_GRADLE="false" +ARG GRADLE_VERSION=5.4.1 +ARG GRADLE_DOWNLOAD_SHA="no-check" +ENV GRADLE_HOME=/usr/local/share/gradle +RUN if [ "${INSTALL_GRADLE}" = "true" ]; then /bin/bash /tmp/library-scripts/gradle-debian.sh ${GRADLE_VERSION} ${GRADLE_HOME} ${USERNAME} ${GRADLE_DOWNLOAD_SHA}; fi \ + && rm -f /tmp/library-scripts/gradle-debian.sh -# Switch back to dialog for any ad-hoc use of apt-get -ENV DEBIAN_FRONTEND=dialog \ No newline at end of file +# [Optional] Install Node.js for use with web applications - update the INSTALL_NODE arg in devcontainer.json to enable. +ARG INSTALL_NODE="false" +ARG NODE_VERSION="lts/*" +ENV NVM_DIR=/usr/local/share/nvm +ENV NVM_SYMLINK_CURRENT=true \ + PATH=${NVM_DIR}/current/bin:${PATH} +COPY library-scripts/node-debian.sh /tmp/library-scripts/ +RUN if [ "$INSTALL_NODE" = "true" ]; then /bin/bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}"; fi \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts/node-debian.sh + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6eca1b6..56b5429 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,27 +1,40 @@ +// 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.134.0/containers/java { - "name": "Java Sample", - "dockerFile": "Dockerfile", - - // Use 'settings' to set *default* container specific settings.json values on container create. - // You can edit these settings after create using File > Preferences > Settings > Remote. - "settings": { - "terminal.integrated.shell.linux": "/bin/bash", - "java.home": "/usr/lib/jvm/zulu-8-azure-amd64" + "name": "Java", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update the VARIANT arg to pick a Java version >= 11 + "VARIANT": "11", + // Options to install Maven or Gradle + "INSTALL_MAVEN": "true", + "MAVEN_VERSION": "3.6.3", + "INSTALL_GRADLE": "false", + "GRADLE_VERSION": "5.4.1", + "INSTALL_NODE": "false", + "NODE_VERSION": "lts/*" + } }, - // Use 'appPort' to create a container with published ports. If the port isn't working, be sure - // your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost. - // "appPort": [], + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "java.home": "/docker-java-home" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "vscjava.vscode-java-pack" + ], - // Uncomment the next line to run commands after the container is created. + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. // "postCreateCommand": "java -version", // Comment out the next line to run as root - "remoteUser": "vscode", + "remoteUser": "vscode" - // Add the IDs of extensions you want installed when the container is created in the array below. - "extensions": [ - "ms-azuretools.vscode-azurefunctions", - "vscjava.vscode-java-pack" - ] -} \ No newline at end of file +} diff --git a/.devcontainer/library-scripts/common-debian.sh b/.devcontainer/library-scripts/common-debian.sh new file mode 100644 index 0000000..e756809 --- /dev/null +++ b/.devcontainer/library-scripts/common-debian.sh @@ -0,0 +1,171 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] + +INSTALL_ZSH=${1:-"true"} +USERNAME=${2:-"vscode"} +USER_UID=${3:-1000} +USER_GID=${4:-1000} +UPGRADE_PACKAGES=${5:-"true"} + +set -e + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run a root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Treat a user name of "none" as root +if [ "${USERNAME}" = "none" ] || [ "${USERNAME}" = "root" ]; then + USERNAME=root + USER_UID=0 + USER_GID=0 +fi + +# Load markers to see which steps have already run +MARKER_FILE="/usr/local/etc/vscode-dev-containers/common" +if [ -f "${MARKER_FILE}" ]; then + echo "Marker file found:" + cat "${MARKER_FILE}" + source "${MARKER_FILE}" +fi + +# Ensure apt is in non-interactive to avoid prompts +export DEBIAN_FRONTEND=noninteractive + +# Function to call apt-get if needed +apt-get-update-if-needed() +{ + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update + else + echo "Skipping apt-get update." + fi +} + +# Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies +if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then + apt-get-update-if-needed + + PACKAGE_LIST="apt-utils \ + git \ + openssh-client \ + less \ + iproute2 \ + procps \ + curl \ + wget \ + unzip \ + nano \ + jq \ + lsb-release \ + ca-certificates \ + apt-transport-https \ + dialog \ + gnupg2 \ + libc6 \ + libgcc1 \ + libgssapi-krb5-2 \ + libicu[0-9][0-9] \ + liblttng-ust0 \ + libstdc++6 \ + zlib1g \ + locales \ + sudo" + + # Install libssl1.1 if available + if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then + PACKAGE_LIST="${PACKAGE_LIST} libssl1.1" + fi + + # Install appropriate version of libssl1.0.x if available + LIBSSL=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '') + if [ "$(echo "$LIBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then + if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then + # Debian 9 + PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.2" + elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then + # Ubuntu 18.04, 16.04, earlier + PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.0" + fi + fi + + echo "Packages to verify are installed: ${PACKAGE_LIST}" + apt-get -y install --no-install-recommends ${PACKAGE_LIST} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 ) + + PACKAGES_ALREADY_INSTALLED="true" +fi + +# Get to latest versions of all packages +if [ "${UPGRADE_PACKAGES}" = "true" ]; then + apt-get-update-if-needed + apt-get -y upgrade --no-install-recommends + apt-get autoremove -y +fi + +# Ensure at least the en_US.UTF-8 UTF-8 locale is available. +# Common need for both applications and things like the agnoster ZSH theme. +if [ "${LOCALE_ALREADY_SET}" != "true" ]; then + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen + locale-gen + LOCALE_ALREADY_SET="true" +fi + +# Create or update a non-root user to match UID/GID - see https://aka.ms/vscode-remote/containers/non-root-user. +if id -u $USERNAME > /dev/null 2>&1; then + # User exists, update if needed + if [ "$USER_GID" != "$(id -G $USERNAME)" ]; then + groupmod --gid $USER_GID $USERNAME + usermod --gid $USER_GID $USERNAME + fi + if [ "$USER_UID" != "$(id -u $USERNAME)" ]; then + usermod --uid $USER_UID $USERNAME + fi +else + # Create user + groupadd --gid $USER_GID $USERNAME + useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME +fi + +# Add add sudo support for non-root user +if [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then + echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME + chmod 0440 /etc/sudoers.d/$USERNAME + EXISTING_NON_ROOT_USER="${USERNAME}" +fi + +# Ensure ~/.local/bin is in the PATH for root and non-root users for bash. (zsh is later) +if [ "${DOT_LOCAL_ALREADY_ADDED}" != "true" ]; then + echo "export PATH=\$PATH:\$HOME/.local/bin" | tee -a /root/.bashrc >> /home/$USERNAME/.bashrc + chown $USER_UID:$USER_GID /home/$USERNAME/.bashrc + DOT_LOCAL_ALREADY_ADDED="true" +fi + +# Optionally install and configure zsh +if [ "${INSTALL_ZSH}" = "true" ] && [ ! -d "/root/.oh-my-zsh" ] && [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then + apt-get-update-if-needed + apt-get install -y zsh + curl -fsSLo- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash 2>&1 + echo "export PATH=\$PATH:\$HOME/.local/bin" >> /root/.zshrc + if [ "${USERNAME}" != "root" ]; then + cp -fR /root/.oh-my-zsh /home/$USERNAME + cp -f /root/.zshrc /home/$USERNAME + sed -i -e "s/\/root\/.oh-my-zsh/\/home\/$USERNAME\/.oh-my-zsh/g" /home/$USERNAME/.zshrc + chown -R $USER_UID:$USER_GID /home/$USERNAME/.oh-my-zsh /home/$USERNAME/.zshrc + fi + ZSH_ALREADY_INSTALLED="true" +fi + +# Write marker file +mkdir -p "$(dirname "${MARKER_FILE}")" +echo -e "\ + PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\ + LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\ + EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\ + DOT_LOCAL_ALREADY_ADDED=${DOT_LOCAL_ALREADY_ADDED}\n\ + ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}" diff --git a/.devcontainer/library-scripts/gradle-debian.sh b/.devcontainer/library-scripts/gradle-debian.sh new file mode 100644 index 0000000..a477fcd --- /dev/null +++ b/.devcontainer/library-scripts/gradle-debian.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +# Syntax: ./gradle-debian.sh [gradle home] [non-root-user] [gradle SHA 256] + +GRADLE_VERSION=$1 +GRADLE_HOME=${2:-"/usr/local/share/gradle"} +USERNAME=${3:-"vscode"} +GRADLE_DOWNLOAD_SHA=${4:-"no-check"} + +set -e + +if [ -d "${GRADLE_HOME}" ]; then + echo "Gradle already installed." + exit 0 +fi + +if [ -z "$1" ]; then + echo -e "Required argument missing.\n\ngradle-debian.sh [gradle home] [non-root-user] [gradle SHA 256]" + exit 1 +fi + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run a root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Treat a user name of "none" or non-existant user as root +if [ "${USERNAME}" = "none" ] && ! id -u ${USERNAME} > /dev/null 2>&1; then + USERNAME=root +fi + +# Install curl, apt-get dependencies if missing +if ! type curl > /dev/null 2>&1; then + export DEBIAN_FRONTEND=noninteractive + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + apt-get update + fi + apt-get -y install --no-install-recommends ca-certificates curl gnupg2 +fi + +# Function to su if user exists and is not root +suIf() { + if [ "${USERNAME}" != "root" ]; then + su ${USERNAME} -c "$@" + else + "$@" + fi +} + +# Install Gradle +echo "Downloading Gradle..." +suIf "$(cat \ +<< EOF + mkdir -p /tmp/downloads + curl -sSL --output /tmp/downloads/archive-gradle.zip https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip + ([ "${GRADLE_DOWNLOAD_SHA}" = "no-check" ] || echo "${GRADLE_DOWNLOAD_SHA} */tmp/downloads/archive-gradle.zip" | sha256sum --check - ) + unzip -q /tmp/downloads/archive-gradle.zip -d /tmp/downloads/ +EOF +)" +mv -f /tmp/downloads/gradle* ${GRADLE_HOME} +chown ${USERNAME}:root ${GRADLE_HOME} +ln -s ${GRADLE_HOME}/bin/gradle /usr/local/bin/gradle +rm -rf /tmp/downloads +echo "Done." + + diff --git a/.devcontainer/library-scripts/maven-debian.sh b/.devcontainer/library-scripts/maven-debian.sh new file mode 100644 index 0000000..c1ce947 --- /dev/null +++ b/.devcontainer/library-scripts/maven-debian.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +# Syntax: ./maven-debian.sh [maven home] [non-root user] [maven SHA 512] + +MAVEN_VERSION=$1 +MAVEN_HOME=${2:-"/usr/local/share/maven"} +USERNAME=${3:-"vscode"} +MAVEN_DOWNLOAD_SHA=${4:-"no-check"} + +set -e + +if [ -d "${MAVEN_HOME}" ]; then + echo "Maven already installed." + exit 0 +fi + +if [ -z "$1" ]; then + echo -e "Required argument missing.\n\nmaven-debian.sh [maven home] [non-root user] [maven SHA 512]" + exit 1 +fi + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run a root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Treat a user name of "none" or non-existant user as root +if [ "${USERNAME}" = "none" ] && ! id -u ${USERNAME} > /dev/null 2>&1; then + USERNAME=root +fi + +# Install curl, apt-get dependencies if missing +if ! type curl > /dev/null 2>&1; then + export DEBIAN_FRONTEND=noninteractive + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + apt-get update + fi + apt-get -y install --no-install-recommends ca-certificates curl gnupg2 +fi + +# Function to su if user exists and is not root +suIf() { + if [ "${USERNAME}" != "root" ]; then + su ${USERNAME} -c "$@" + else + "$@" + fi +} + +# Creat folder, add maven settings +mkdir -p ${MAVEN_HOME} ${MAVEN_HOME}/ref +tee ${MAVEN_HOME}/ref/maven-settings.xml > /dev/null \ +<< EOF + + ${MAVEN_HOME}/ref/repository + +EOF +chown -R ${USERNAME}:root ${MAVEN_HOME} + +# Install Maven +echo "Downloading Maven..." +suIf "$(cat \ +<< EOF + curl -fsSL -o /tmp/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz + ([ "${MAVEN_DOWNLOAD_SHA}" = "dev-mode" ] || echo "${MAVEN_DOWNLOAD_SHA} */tmp/maven.tar.gz" | sha512sum -c - ) + tar -xzf /tmp/maven.tar.gz -C ${MAVEN_HOME} --strip-components=1 + rm -f /tmp/maven.tar.gz +EOF +)" +ln -s ${MAVEN_HOME}/bin/mvn /usr/local/bin/mvn +echo "Done." diff --git a/.devcontainer/library-scripts/node-debian.sh b/.devcontainer/library-scripts/node-debian.sh new file mode 100644 index 0000000..a6c4e59 --- /dev/null +++ b/.devcontainer/library-scripts/node-debian.sh @@ -0,0 +1,102 @@ +#!/bin/bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +# Syntax: ./node-debian.sh + +export NVM_DIR=${1:-"/usr/local/share/nvm"} +export NODE_VERSION=${2:-"lts/*"} +USERNAME=${3:-"vscode"} + +set -e + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run a root. Use sudo, su, or add "USER root" to\nyour Dockerfile before running this script.' + exit 1 +fi + +# Ensure apt is in non-interactive to avoid prompts +export DEBIAN_FRONTEND=noninteractive + +# Install curl, apt-get dependencies if missing +if ! type curl > /dev/null 2>&1; then + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + apt-get update + fi + apt-get -y install --no-install-recommends apt-transport-https ca-certificates curl gnupg2 +fi + +# Treat a user name of "none" as root +if [ "${USERNAME}" = "none" ]; then + USERNAME=root +fi + +if [ "${NODE_VERSION}" = "none" ]; then + export NODE_VERSION= +fi + +# Install yarn +if type yarn > /dev/null 2>&1; then + echo "Yarn already installed." +else + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - 2>/dev/null + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list + apt-get update + apt-get -y install --no-install-recommends yarn +fi + +# Install the specified node version if NVM directory already exists, then exit +if [ -d "${NVM_DIR}" ]; then + echo "NVM already installed." + if [ "${NODE_VERSION}" != "" ]; then + suIf "nvm install ${NODE_VERSION}" + fi + exit 0 +fi + +mkdir -p ${NVM_DIR} + +# Set up non-root user if applicable +if [ "${USERNAME}" != "root" ] && id -u $USERNAME > /dev/null 2>&1; then + tee -a /home/${USERNAME}/.bashrc /home/${USERNAME}/.zshrc >> /root/.zshrc \ +<< EOF +EOF + + # Add NVM init and add code to update NVM ownership if UID/GID changes + tee -a /root/.bashrc /root/.zshrc /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc \ +< /dev/null 2>&1; then + su ${USERNAME} -c "$@" + else + "$@" + fi + +} + +# Run NVM installer as non-root if needed +suIf "$(cat \ +<< EOF + curl -so- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash + if [ "${NODE_VERSION}" != "" ]; then + source $NVM_DIR/nvm.sh + nvm alias default ${NODE_VERSION} + fi +EOF +)" 2>&1 + diff --git a/.devcontainer/maven-settings.xml b/.devcontainer/maven-settings.xml deleted file mode 100644 index 50439ab..0000000 --- a/.devcontainer/maven-settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - /usr/share/maven/ref/repository - \ No newline at end of file