Update Ruby, Rust, Go, Python to use script-library, script fixes (#530)
This commit is contained in:
Родитель
72cce6ddce
Коммит
b03e101e97
|
@ -23,7 +23,7 @@ ENV SHELL=/bin/bash \
|
|||
CARGO_HOME="/usr/local/cargo" \
|
||||
RUSTUP_HOME="/usr/local/rustup" \
|
||||
SDKMAN_DIR="/usr/local/sdkman"
|
||||
ENV PATH="${NVM_DIR}/current/bin:${DOTNET_ROOT}/tools:${SDKMAN_DIR}/bin:${SDKMAN_DIR}/candidates/java/current/bin:${SDKMAN_DIR}/candidates/gradle/current/bin:${SDKMAN_DIR}/candidates/maven/current/bin:${CARGO_HOME}/bin:${GOROOT}/bin:${PATH}:${PIPX_BIN_DIR}"
|
||||
ENV PATH="${NVM_DIR}/current/bin:${DOTNET_ROOT}/tools:${SDKMAN_DIR}/bin:${SDKMAN_DIR}/candidates/java/current/bin:${SDKMAN_DIR}/candidates/gradle/current/bin:${SDKMAN_DIR}/candidates/maven/current/bin:${CARGO_HOME}/bin:${GOROOT}/bin:${GOPATH}/bin:${PATH}:${PIPX_BIN_DIR}"
|
||||
|
||||
# Install needed utilities and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
||||
COPY library-scripts/azcli-debian.sh library-scripts/common-debian.sh library-scripts/git-lfs-debian.sh library-scripts/github-debian.sh \
|
||||
|
@ -96,14 +96,9 @@ COPY library-scripts/go-debian.sh /tmp/scripts/
|
|||
RUN bash /tmp/scripts/go-debian.sh "latest" "${GOROOT}" "${GOPATH}" "${USERNAME}" \
|
||||
&& apt-get clean -y && rm -rf /tmp/scripts
|
||||
|
||||
# Install rvm, Ruby, base gems
|
||||
COPY library-scripts/ruby-debian.sh /tmp/scripts/
|
||||
RUN bash /tmp/scripts/ruby-debian.sh "stable" "${USERNAME}" "true" \
|
||||
&& apt-get clean -y && rm -rf /tmp/scripts
|
||||
|
||||
# Install Python tools
|
||||
COPY library-scripts/python-debian.sh /tmp/scripts/
|
||||
RUN bash /tmp/scripts/python-debian.sh "stable" "/opt/python/stable" "${PIPX_HOME}" "${USERNAME}" "true" \
|
||||
RUN bash /tmp/scripts/python-debian.sh "none" "/opt/python/stable" "${PIPX_HOME}" "${USERNAME}" "true" \
|
||||
&& apt-get clean -y && rm -rf /tmp/scripts
|
||||
|
||||
# Install xdebug, link composer
|
||||
|
@ -115,6 +110,11 @@ RUN yes | pecl install xdebug \
|
|||
&& rm -rf /tmp/pear \
|
||||
&& ln -s $(which composer.phar) /usr/local/bin/composer
|
||||
|
||||
# Install rvm, Ruby, base gems
|
||||
COPY library-scripts/ruby-debian.sh /tmp/scripts/
|
||||
RUN bash /tmp/scripts/ruby-debian.sh "latest" "${USERNAME}" "true" \
|
||||
&& apt-get clean -y && rm -rf /tmp/scripts
|
||||
|
||||
# [Option] Install Docker CLI
|
||||
ARG INSTALL_DOCKER="false"
|
||||
COPY library-scripts/docker-debian.sh /tmp/scripts/
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
"settings": {
|
||||
"terminal.integrated.shell.linux": "/bin/bash",
|
||||
"go.useGoProxyToCheckForToolUpdates": false,
|
||||
"go.useLanguageServer": true,
|
||||
"go.gopath": "/go",
|
||||
"go.goroot": "/usr/local/go",
|
||||
"go.toolsGopath": "/go/bin",
|
||||
"python.pythonPath": "/opt/python/latest/bin/python",
|
||||
"python.linting.enabled": true,
|
||||
"python.linting.pylintEnabled": true,
|
||||
|
|
|
@ -27,6 +27,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
@ -56,7 +57,7 @@ GO_INSTALL_SCRIPT="$(cat <<EOF
|
|||
rm -f /tmp/go.tar.gz
|
||||
EOF
|
||||
)"
|
||||
if ! type go > /dev/null 2>&1; then
|
||||
if [ "${TARGET_GO_VERSION}" != "none" ] && ! type go > /dev/null 2>&1; then
|
||||
mkdir -p "${TARGET_GOROOT}" "${TARGET_GOPATH}"
|
||||
chown ${USERNAME}:root "${TARGET_GOROOT}" "${TARGET_GOPATH}"
|
||||
su ${USERNAME} -c "${GO_INSTALL_SCRIPT}"
|
||||
|
@ -105,15 +106,15 @@ if [ "${INSTALL_GO_TOOLS}" = "true" ]; then
|
|||
go build -o gocode-gomod github.com/stamblerre/gocode
|
||||
|
||||
# golangci-lint
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin 2>&1
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${TARGET_GOPATH}/bin 2>&1
|
||||
|
||||
# Move Go tools into path and clean up
|
||||
mv /tmp/gotools/bin/* /usr/local/bin/
|
||||
mv gocode-gomod /usr/local/bin/
|
||||
mv /tmp/gotools/bin/* ${TARGET_GOPATH}/bin/
|
||||
mv gocode-gomod ${TARGET_GOPATH}/bin/
|
||||
rm -rf /tmp/gotools
|
||||
fi
|
||||
|
||||
# Add GOPATH variable and bin directory into PATH in bashrc/zshrc files (unless disabled)
|
||||
updaterc "export GOPATH=\"${TARGET_GOPATH}\"\nexport GOROOT=\"${TARGET_GOROOT}\"\nexport PATH=\"\${GOROOT}/bin:\${PATH}\""
|
||||
updaterc "export GOPATH=\"${TARGET_GOPATH}\"\nexport GOROOT=\"${TARGET_GOROOT}\"\nexport PATH=\"\${GOROOT}/bin:\${GOPATH}/bin:\${PATH}\""
|
||||
echo "Done!"
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -28,6 +28,13 @@ if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
|
|||
USERNAME=root
|
||||
fi
|
||||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install curl, zip, unzip if missing
|
||||
|
@ -43,10 +50,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
curl -sSL "https://get.sdkman.io?rcupdate=false" | bash
|
||||
chown -R "${USERNAME}" "${SDKMAN_DIR}"
|
||||
# Add sourcing of sdkman into bashrc/zshrc files (unless disabled)
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
RC_SNIPPET="export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
|
||||
echo -e ${RC_SNIPPET} | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
updaterc "export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
|
||||
fi
|
||||
|
||||
if [ "${JAVA_VERSION}" != "none" ]; then
|
||||
|
|
|
@ -30,6 +30,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -63,6 +63,10 @@ mkdir -p ${NVM_DIR}
|
|||
chown ${USERNAME} ${NVM_DIR}
|
||||
su ${USERNAME} -c "$(cat << EOF
|
||||
set -e
|
||||
|
||||
# Do not update profile - we'll do this manually
|
||||
export PROFILE=/dev/null
|
||||
|
||||
curl -so- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
|
||||
source ${NVM_DIR}/nvm.sh
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
|
@ -73,13 +77,27 @@ EOF
|
|||
)" 2>&1
|
||||
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc with NVM scripts..."
|
||||
(cat <<EOF
|
||||
export NVM_DIR="${NVM_DIR}"
|
||||
sudoIf()
|
||||
{
|
||||
if [ "\$(id -u)" -ne 0 ]; then
|
||||
sudo "\$@"
|
||||
else
|
||||
"\$@"
|
||||
fi
|
||||
}
|
||||
if [ "\$(stat -c '%U' \$NVM_DIR)" != "${USERNAME}" ]; then
|
||||
if [ "\$(id -u)" -eq 0 ] || type sudo > /dev/null 2>&1; then
|
||||
echo "Fixing permissions of \"\$NVM_DIR\"..."
|
||||
sudoIf chown -R ${USERNAME}:root \$NVM_DIR
|
||||
else
|
||||
echo "Warning: NVM directory is not owned by ${USERNAME} and sudo is not installed. Unable to correct permissions."
|
||||
fi
|
||||
fi
|
||||
[ -s "\$NVM_DIR/nvm.sh" ] && . "\$NVM_DIR/nvm.sh"
|
||||
[ -s "\$NVM_DIR/bash_completion" ] && . "\$NVM_DIR/bash_completion"
|
||||
if [ "\$(stat -c '%U' \$NVM_DIR)" != "${USERNAME}" ]; then
|
||||
sudo chown -R ${USERNAME}:root \$NVM_DIR
|
||||
fi
|
||||
EOF
|
||||
) | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
|
|
|
@ -27,6 +27,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
# Syntax: ./ruby-debian.sh [Ruby version] [non-root user] [Add rvm to rc files flag]
|
||||
|
||||
RUBY_VERSION=${1:-"stable"}
|
||||
RUBY_VERSION=${1:-"latest"}
|
||||
USERNAME=${2:-"vscode"}
|
||||
UPDATE_RC=${3:-"true"}
|
||||
INSTALL_RUBY_TOOLS=${6:-"true"}
|
||||
|
||||
set -e
|
||||
|
||||
|
@ -22,45 +23,70 @@ if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
|
|||
USERNAME=root
|
||||
fi
|
||||
|
||||
# Determine appropriate settings for rvm
|
||||
DEFAULT_GEMS="rake ruby-debug-ide debase"
|
||||
if [ "${RUBY_VERSION}" = "none" ]; then
|
||||
RVM_INSTALL_ARGS=""
|
||||
else
|
||||
if [ "${RUBY_VERSION}" = "latest" ] || [ "${RUBY_VERSION}" = "current" ] || [ "${RUBY_VERSION}" = "lts" ]; then
|
||||
RVM_INSTALL_ARGS="--ruby"
|
||||
RUBY_VERSION=""
|
||||
else
|
||||
RVM_INSTALL_ARGS="--ruby=${RUBY_VERSION}"
|
||||
fi
|
||||
if [ "${INSTALL_RUBY_TOOLS}" = "true" ]; then
|
||||
SKIP_GEM_INSTALL="true"
|
||||
else
|
||||
DEFAULT_GEMS=""
|
||||
fi
|
||||
fi
|
||||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install curl, software-properties-common, gnupg2 if missing
|
||||
if ! dpkg -s curl ca-certificates software-properties-common gnupg2 > /dev/null 2>&1; then
|
||||
# Install curl, software-properties-common, build-essential, gnupg2 if missing
|
||||
if ! dpkg -s curl ca-certificates software-properties-common build-essential gnupg2 > /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 curl ca-certificates software-properties-common gnupg2
|
||||
apt-get -y install --no-install-recommends curl ca-certificates software-properties-common build-essential gnupg2
|
||||
fi
|
||||
|
||||
# Just install Ruby if RVM already installed
|
||||
if [ -d "/usr/local/rvm" ]; then
|
||||
echo "Ruby Version Manager already exists. Installing specified Ruby version."
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm install ${RUBY_VERSION}"
|
||||
source /usr/local/rvm/scripts/rvm
|
||||
rvm cleanup all
|
||||
gem cleanup
|
||||
exit 0
|
||||
echo "Ruby Version Manager already exists."
|
||||
if [ "${RUBY_VERSION}" != "none" ]; then
|
||||
echo "Installing specified Ruby version."
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm install ruby ${RUBY_VERSION}"
|
||||
fi
|
||||
SKIP_GEM_INSTALL="false"
|
||||
else
|
||||
# Use a temporary locaiton for gpg keys to avoid polluting image
|
||||
export GNUPGHOME="/tmp/rvm-gnupg"
|
||||
mkdir -p ${GNUPGHOME}
|
||||
echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf
|
||||
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB 2>&1
|
||||
# Install RVM
|
||||
curl -sSL https://get.rvm.io | bash -s stable --ignore-dotfiles ${RVM_INSTALL_ARGS} --with-default-gems="${DEFAULT_GEMS}" 2>&1
|
||||
usermod -aG rvm ${USERNAME}
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system"
|
||||
rm -rf ${GNUPGHOME}
|
||||
fi
|
||||
if [ "${INSTALL_RUBY_TOOLS}" = "true" ] && [ "${SKIP_GEM_INSTALL}" != "true" ]; then
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && gem install ${DEFAULT_GEMS}"
|
||||
fi
|
||||
|
||||
# Use a temporary locaiton for gpg keys to avoid polluting image
|
||||
export GNUPGHOME="/tmp/rvm-gnupg"
|
||||
mkdir -p ${GNUPGHOME}
|
||||
echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf
|
||||
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB 2>&1 \
|
||||
# VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it
|
||||
updaterc "if ! grep rvm_silence_path_mismatch_check_flag \$HOME/.rvmrc > /dev/null 2>&1; then echo 'rvm_silence_path_mismatch_check_flag=1' >> \$HOME/.rvmrc; fi\nsource /usr/local/rvm/scripts/rvm"
|
||||
|
||||
# Install RVM
|
||||
curl -sSL https://get.rvm.io | bash -s "${RUBY_VERSION}" --ruby --with-default-gems="rake ruby-debug-ide debase" 2>&1
|
||||
usermod -aG rvm ${USERNAME}
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system"
|
||||
rm -rf ${GNUPGHOME}
|
||||
# Clean up
|
||||
source /usr/local/rvm/scripts/rvm
|
||||
rvm cleanup all
|
||||
gem cleanup
|
||||
updaterc "source /usr/local/rvm/scripts/rvm"
|
||||
echo "Done!"
|
||||
echo "Done!"
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Syntax: ./rust-debian.sh [CARGO_HOME] [RUSTUP_HOME] [non-root user] [add CARGO/RUSTUP_HOME to rc files flag]
|
||||
# Syntax: ./rust-debian.sh [CARGO_HOME] [RUSTUP_HOME] [non-root user] [add CARGO/RUSTUP_HOME to rc files flag] [whether to update rust]
|
||||
|
||||
export CARGO_HOME=${1:-"/usr/local/cargo"}
|
||||
export RUSTUP_HOME=${2:-"/usr/local/rustup"}
|
||||
USERNAME=${3:-"vscode"}
|
||||
UPDATE_RC=${4:-"true"}
|
||||
UPDATE_RUST=${5:-"true"}
|
||||
|
||||
set -e
|
||||
|
||||
|
@ -25,6 +26,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
@ -50,11 +52,14 @@ else
|
|||
echo "Rust already installed. Skipping."
|
||||
fi
|
||||
|
||||
echo "Installing common Rust dependencies..."
|
||||
su ${USERNAME} -c "$(cat << EOF
|
||||
set -e
|
||||
export PATH=${PATH}:${CARGO_HOME}/bin
|
||||
rustup update 2>&1
|
||||
if [ "${UPDATE_RUST}" = "true" ]; then
|
||||
echo "Updating Rust..."
|
||||
rustup update 2>&1
|
||||
fi
|
||||
echo "Installing common Rust dependencies..."
|
||||
rustup component add rls rust-analysis rust-src rustfmt clippy 2>&1
|
||||
EOF
|
||||
)"
|
||||
|
|
|
@ -7,7 +7,7 @@ BASH_PROMPT="PS1='\[\e]0;\u: \w\a\]\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]
|
|||
FISH_PROMPT="function fish_prompt\n set_color green\n echo -n (whoami)\n set_color normal\n echo -n \":\"\n set_color blue\n echo -n (pwd)\n set_color normal\n echo -n \"> \"\nend\n"
|
||||
|
||||
{ echo && echo $BASH_PROMPT ; } | tee -a /root/.bashrc /home/${USERNAME}/.bashrc >> /etc/skel/.bashrc
|
||||
{ echo && echo -e "export PATH=\$HOME/.dotnet:\$PATH:\$HOME/.npm-global/bin" ; } | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
{ echo && echo -e "export PATH=\$HOME/.dotnet:${SECURE_PATH_BASE}:\$PATH:\$HOME/.npm-global/bin" ; } | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
echo "Defaults secure_path=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:${SECURE_PATH_BASE}\"" >> /etc/sudoers.d/securepath
|
||||
|
||||
# Install and setup fish
|
||||
|
|
|
@ -1,60 +1,21 @@
|
|||
ARG VARIANT=1
|
||||
FROM golang:${VARIANT}
|
||||
|
||||
# Options for setup script
|
||||
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
||||
ARG INSTALL_ZSH="true"
|
||||
ARG UPGRADE_PACKAGES="false"
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=$USER_UID
|
||||
|
||||
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
||||
COPY library-scripts/common-debian.sh /tmp/library-scripts/
|
||||
RUN bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \
|
||||
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
|
||||
|
||||
# Install Go tools
|
||||
ARG GO_TOOLS_WITH_MODULES="\
|
||||
golang.org/x/tools/gopls \
|
||||
honnef.co/go/tools/... \
|
||||
golang.org/x/tools/cmd/gorename \
|
||||
golang.org/x/tools/cmd/goimports \
|
||||
golang.org/x/tools/cmd/guru \
|
||||
golang.org/x/lint/golint \
|
||||
github.com/mdempsky/gocode \
|
||||
github.com/cweill/gotests/... \
|
||||
github.com/haya14busa/goplay/cmd/goplay \
|
||||
github.com/sqs/goreturns \
|
||||
github.com/josharian/impl \
|
||||
github.com/davidrjenni/reftools/cmd/fillstruct \
|
||||
github.com/uudashr/gopkgs/v2/cmd/gopkgs \
|
||||
github.com/ramya-rao-a/go-outline \
|
||||
github.com/acroca/go-symbols \
|
||||
github.com/godoctor/godoctor \
|
||||
github.com/rogpeppe/godef \
|
||||
github.com/zmb3/gogetdoc \
|
||||
github.com/fatih/gomodifytags \
|
||||
github.com/mgechev/revive \
|
||||
github.com/go-delve/delve/cmd/dlv"
|
||||
RUN mkdir -p /tmp/gotools \
|
||||
&& cd /tmp/gotools \
|
||||
&& export GOPATH=/tmp/gotools \
|
||||
&& export GOCACHE=/tmp/gotools/cache \
|
||||
# Go tools w/module support
|
||||
&& export GO111MODULE=on \
|
||||
&& (echo "${GO_TOOLS_WITH_MODULES}" | xargs -n 1 go get -x )2>&1 \
|
||||
# gocode-gomod
|
||||
&& export GO111MODULE=auto \
|
||||
&& go get -x -d github.com/stamblerre/gocode 2>&1 \
|
||||
&& go build -o gocode-gomod github.com/stamblerre/gocode \
|
||||
# golangci-lint
|
||||
&& curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin 2>&1 \
|
||||
# Move Go tools into path and clean up
|
||||
&& mv /tmp/gotools/bin/* /usr/local/bin/ \
|
||||
&& mv gocode-gomod /usr/local/bin/ \
|
||||
&& rm -rf /tmp/gotools
|
||||
|
||||
ENV GO111MODULE=auto
|
||||
COPY library-scripts/go-debian.sh /tmp/library-scripts/
|
||||
RUN bash /tmp/library-scripts/go-debian.sh "none" "/usr/local/go" "${GOPATH}" "${USERNAME}" "false" \
|
||||
&& apt-get clean -y && rm -rf /tmp/library-scripts
|
||||
|
||||
# [Option] Install Node.js
|
||||
ARG INSTALL_NODE="true"
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
"settings": {
|
||||
"terminal.integrated.shell.linux": "/bin/bash",
|
||||
"go.useGoProxyToCheckForToolUpdates": false,
|
||||
"go.gopath": "/go"
|
||||
"go.useLanguageServer": true,
|
||||
"go.gopath": "/go",
|
||||
"go.goroot": "/usr/local/go",
|
||||
"go.toolsGopath": "/go/bin"
|
||||
},
|
||||
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
#!/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: ./go-debian.sh [Go version] [Go install path] [GOPATH] [non-root user] [Add GOPATH, GOROOT to rc files flag] [install tools]
|
||||
|
||||
TARGET_GO_VERSION=${1:-"latest"}
|
||||
TARGET_GOROOT=${2:-"/usr/local/go"}
|
||||
TARGET_GOPATH=${3:-"/go"}
|
||||
USERNAME=${4:-"vscode"}
|
||||
UPDATE_RC=${5:-"true"}
|
||||
INSTALL_GO_TOOLS=${6:-"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" or non-existant user as root
|
||||
if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
|
||||
USERNAME=root
|
||||
fi
|
||||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install curl, tar, git, other dependencies if missing
|
||||
if ! dpkg -s curl ca-certificates tar git g++ gcc libc6-dev make pkg-config > /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 curl ca-certificates tar git g++ gcc libc6-dev make pkg-config
|
||||
fi
|
||||
|
||||
# Get latest version number if latest is specified
|
||||
if [ "${TARGET_GO_VERSION}" = "latest" ] || [ "${TARGET_GO_VERSION}" = "current" ] || [ "${TARGET_GO_VERSION}" = "lts" ]; then
|
||||
TARGET_GO_VERSION=$(curl -sSL "https://golang.org/VERSION?m=text" | sed -n '/^go/s///p' )
|
||||
fi
|
||||
|
||||
# Install Go
|
||||
GO_INSTALL_SCRIPT="$(cat <<EOF
|
||||
set -e
|
||||
echo "Downloading Go ${TARGET_GO_VERSION}..."
|
||||
curl -sSL -o /tmp/go.tar.gz "https://golang.org/dl/go${TARGET_GO_VERSION}.linux-amd64.tar.gz"
|
||||
echo "Extracting Go ${TARGET_GO_VERSION}..."
|
||||
tar -xzf /tmp/go.tar.gz -C "${TARGET_GOROOT}" --strip-components=1
|
||||
rm -f /tmp/go.tar.gz
|
||||
EOF
|
||||
)"
|
||||
if [ "${TARGET_GO_VERSION}" != "none" ] && ! type go > /dev/null 2>&1; then
|
||||
mkdir -p "${TARGET_GOROOT}" "${TARGET_GOPATH}"
|
||||
chown ${USERNAME}:root "${TARGET_GOROOT}" "${TARGET_GOPATH}"
|
||||
su ${USERNAME} -c "${GO_INSTALL_SCRIPT}"
|
||||
else
|
||||
echo "Go already installed. Skipping."
|
||||
fi
|
||||
|
||||
# Install Go tools
|
||||
GO_TOOLS_WITH_MODULES="\
|
||||
golang.org/x/tools/gopls \
|
||||
honnef.co/go/tools/... \
|
||||
golang.org/x/tools/cmd/gorename \
|
||||
golang.org/x/tools/cmd/goimports \
|
||||
golang.org/x/tools/cmd/guru \
|
||||
golang.org/x/lint/golint \
|
||||
github.com/mdempsky/gocode \
|
||||
github.com/cweill/gotests/... \
|
||||
github.com/haya14busa/goplay/cmd/goplay \
|
||||
github.com/sqs/goreturns \
|
||||
github.com/josharian/impl \
|
||||
github.com/davidrjenni/reftools/cmd/fillstruct \
|
||||
github.com/uudashr/gopkgs/v2/cmd/gopkgs \
|
||||
github.com/ramya-rao-a/go-outline \
|
||||
github.com/acroca/go-symbols \
|
||||
github.com/godoctor/godoctor \
|
||||
github.com/rogpeppe/godef \
|
||||
github.com/zmb3/gogetdoc \
|
||||
github.com/fatih/gomodifytags \
|
||||
github.com/mgechev/revive \
|
||||
github.com/go-delve/delve/cmd/dlv"
|
||||
if [ "${INSTALL_GO_TOOLS}" = "true" ]; then
|
||||
echo "Installing common Go tools..."
|
||||
export PATH=${TARGET_GOROOT}/bin:${PATH}
|
||||
mkdir -p /tmp/gotools
|
||||
cd /tmp/gotools
|
||||
export GOPATH=/tmp/gotools
|
||||
export GOCACHE=/tmp/gotools/cache
|
||||
|
||||
# Go tools w/module support
|
||||
export GO111MODULE=on
|
||||
(echo "${GO_TOOLS_WITH_MODULES}" | xargs -n 1 go get -v )2>&1
|
||||
|
||||
# gocode-gomod
|
||||
export GO111MODULE=auto
|
||||
go get -v -d github.com/stamblerre/gocode 2>&1
|
||||
go build -o gocode-gomod github.com/stamblerre/gocode
|
||||
|
||||
# golangci-lint
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${TARGET_GOPATH}/bin 2>&1
|
||||
|
||||
# Move Go tools into path and clean up
|
||||
mv /tmp/gotools/bin/* ${TARGET_GOPATH}/bin/
|
||||
mv gocode-gomod ${TARGET_GOPATH}/bin/
|
||||
rm -rf /tmp/gotools
|
||||
fi
|
||||
|
||||
# Add GOPATH variable and bin directory into PATH in bashrc/zshrc files (unless disabled)
|
||||
updaterc "export GOPATH=\"${TARGET_GOPATH}\"\nexport GOROOT=\"${TARGET_GOROOT}\"\nexport PATH=\"\${GOROOT}/bin:\${GOPATH}/bin:\${PATH}\""
|
||||
echo "Done!"
|
||||
|
|
@ -32,7 +32,7 @@ RUN mkdir -p ${NPM_GLOBAL} \
|
|||
&& npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& sudo -u ${USERNAME} npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& echo "if [ \"\$(stat -c '%U' ${NPM_GLOBAL})\" != \"${USERNAME}\" ]; then sudo chown -R ${USER_UID}:root ${NPM_GLOBAL} ${NVM_DIR}; fi" \
|
||||
| tee -a /root/.bashrc /root/.zshrc /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc
|
||||
| tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
|
||||
# Install eslint globally
|
||||
RUN sudo -u ${USERNAME} npm install -g eslint
|
||||
|
|
|
@ -17,28 +17,12 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
|||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
|
||||
|
||||
# Setup default python tools in a venv via pipx to avoid conflicts
|
||||
ARG DEFAULT_UTILS="\
|
||||
pylint \
|
||||
flake8 \
|
||||
autopep8 \
|
||||
black \
|
||||
yapf \
|
||||
mypy \
|
||||
pydocstyle \
|
||||
pycodestyle \
|
||||
bandit \
|
||||
virtualenv"
|
||||
ENV PIPX_HOME=/usr/local/py-utils
|
||||
ENV PIPX_BIN_DIR=${PIPX_HOME}/bin
|
||||
ENV PIPX_HOME=/usr/local/py-utils \
|
||||
PIPX_BIN_DIR=/usr/local/py-utils/bin
|
||||
ENV PATH=${PATH}:${PIPX_BIN_DIR}
|
||||
RUN mkdir -p ${PIPX_BIN_DIR} \
|
||||
&& export PYTHONUSERBASE=/tmp/pip-tmp \
|
||||
&& export PIP_CACHE_DIR=/tmp/pip-tmp/cache \
|
||||
&& pip3 install --disable-pip-version-check --no-warn-script-location --no-cache-dir --user pipx \
|
||||
&& /tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx \
|
||||
&& echo "${DEFAULT_UTILS}" | xargs -n 1 /tmp/pip-tmp/bin/pipx install --system-site-packages --pip-args=--no-cache-dir --pip-args=--force-reinstall \
|
||||
&& chown -R ${USER_UID}:${USER_GID} ${PIPX_HOME} \
|
||||
&& rm -rf /tmp/pip-tmp
|
||||
COPY .devcontainer/library-scripts/python-debian.sh /tmp/library-scripts/
|
||||
RUN bash /tmp/library-scripts/python-debian.sh "none" "/usr/local" "${PIPX_HOME}" "${USERNAME}" "false" \
|
||||
&& apt-get clean -y && rm -rf /tmp/library-scripts
|
||||
|
||||
# [Option] Install Node.js
|
||||
ARG INSTALL_NODE="true"
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
#!/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: ./python-debian.sh [Python Version] [Python intall path] [PIPX_HOME] [non-root user] [Update rc files flag] [install tools]
|
||||
|
||||
PYTHON_VERSION=${1:-"3.8.3"}
|
||||
PYTHON_INSTALL_PATH=${2:-"/usr/local/python${PYTHON_VERSION}"}
|
||||
export PIPX_HOME=${3:-"/usr/local/py-utils"}
|
||||
USERNAME=${4:-"vscode"}
|
||||
UPDATE_RC=${5:-"true"}
|
||||
INSTALL_PYTHON_TOOLS=${6:-"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" or non-existant user as root
|
||||
if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
|
||||
USERNAME=root
|
||||
fi
|
||||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install python from source if needed
|
||||
if [ "${PYTHON_VERSION}" != "none" ]; then
|
||||
|
||||
if [ -d "${PYTHON_INSTALL_PATH}" ]; then
|
||||
echo "Path ${PYTHON_INSTALL_PATH} already exists. Assuming Python already installed."
|
||||
else
|
||||
echo "Building Python ${PYTHON_VERSION} from source..."
|
||||
# Install prereqs if missing
|
||||
PREREQ_PKGS="curl ca-certificates tar make build-essential libffi-dev \
|
||||
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
|
||||
libncurses5-dev libncursesw5-dev xz-utils tk-dev"
|
||||
if ! dpkg -s ${PREREQ_PKGS} > /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 ${PREREQ_PKGS}
|
||||
fi
|
||||
|
||||
# Download and build from src
|
||||
mkdir -p /tmp/python-src "${PYTHON_INSTALL_PATH}"
|
||||
cd /tmp/python-src
|
||||
curl -sSL -o /tmp/python-dl.tgz "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz"
|
||||
tar -xzf /tmp/python-dl.tgz -C "/tmp/python-src" --strip-components=1
|
||||
./configure --prefix="${PYTHON_INSTALL_PATH}" --enable-optimizations --with-ensurepip=install
|
||||
make -j 8
|
||||
make install
|
||||
rm -rf /tmp/python-dl.tgz /tmp/python-src
|
||||
cd /tmp
|
||||
chown -R ${USERNAME} "${PYTHON_INSTALL_PATH}"
|
||||
ln -s ${PYTHON_INSTALL_PATH}/bin/python3 ${PYTHON_INSTALL_PATH}/bin/python
|
||||
ln -s ${PYTHON_INSTALL_PATH}/bin/pip3 ${PYTHON_INSTALL_PATH}/bin/pip
|
||||
ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle
|
||||
ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc
|
||||
ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config
|
||||
updaterc "export PATH=${PYTHON_INSTALL_PATH}/bin:\${PATH}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If not installing python tools, exit
|
||||
if [ "${INSTALL_PYTHON_TOOLS}" != "true" ]; then
|
||||
echo "Done!"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
DEFAULT_UTILS="\
|
||||
pylint \
|
||||
flake8 \
|
||||
autopep8 \
|
||||
black \
|
||||
yapf \
|
||||
mypy \
|
||||
pydocstyle \
|
||||
pycodestyle \
|
||||
bandit \
|
||||
pipenv \
|
||||
virtualenv"
|
||||
|
||||
export PIPX_BIN_DIR=${PIPX_HOME}/bin
|
||||
export PATH=${PYTHON_INSTALL_PATH}/bin:${PIPX_BIN_DIR}:${PATH}
|
||||
mkdir -p ${PIPX_BIN_DIR}
|
||||
chown -R ${USERNAME} ${PIPX_HOME} ${PIPX_BIN_DIR}
|
||||
su ${USERNAME} -c "$(cat << EOF
|
||||
set -e
|
||||
echo "Installing Python tools..."
|
||||
export PIPX_HOME=${PIPX_HOME}
|
||||
export PIPX_BIN_DIR=${PIPX_BIN_DIR}
|
||||
export PYTHONUSERBASE=/tmp/pip-tmp
|
||||
export PIP_CACHE_DIR=/tmp/pip-tmp/cache
|
||||
export PATH=${PATH}
|
||||
pip3 install --disable-pip-version-check --no-warn-script-location --no-cache-dir --user pipx
|
||||
/tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx
|
||||
echo "${DEFAULT_UTILS}" | xargs -n 1 /tmp/pip-tmp/bin/pipx install --system-site-packages --pip-args=--no-cache-dir --pip-args=--force-reinstall
|
||||
chown -R ${USERNAME} ${PIPX_HOME}
|
||||
rm -rf /tmp/pip-tmp
|
||||
EOF
|
||||
)"
|
||||
updaterc "export PIPX_HOME=${PIPX_HOME}\nexport PIPX_BIN_DIR=${PIPX_BIN_DIR}\nexport PATH=\${PATH}:\${PIPX_BIN_DIR}"
|
|
@ -1,7 +1,7 @@
|
|||
ARG VARIANT=2
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/ruby:${VARIANT}
|
||||
|
||||
# [Optional] Install a version of Node.js using nvm for front end dev
|
||||
# [Option] Install Node.js
|
||||
ARG INSTALL_NODE="true"
|
||||
ARG NODE_VERSION="lts/*"
|
||||
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
|
||||
|
|
|
@ -2,34 +2,29 @@
|
|||
ARG VARIANT=2
|
||||
FROM ruby:${VARIANT}
|
||||
|
||||
# Options for setup script
|
||||
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
||||
ARG INSTALL_ZSH="true"
|
||||
ARG UPGRADE_PACKAGES="true"
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=$USER_UID
|
||||
|
||||
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
||||
COPY library-scripts/common-debian.sh /tmp/library-scripts/
|
||||
COPY library-scripts/common-debian.sh library-scripts/ruby-debian.sh /tmp/library-scripts/
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
|
||||
&& apt-get purge -y imagemagick imagemagick-6-common \
|
||||
# Install common packages, non-root user, core build tools
|
||||
# Install common packages, non-root user, rvm, core build tools
|
||||
&& bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \
|
||||
&& apt-get install -y build-essential \
|
||||
&& bash /tmp/library-scripts/ruby-debian.sh "none" "${USERNAME}" "true" "true" \
|
||||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
|
||||
|
||||
# Install Ruby tools
|
||||
RUN gem install rake ruby-debug-ide debase
|
||||
|
||||
# [Optional] Install Node.js for use with web applications - update the INSTALL_NODE arg in devcontainer.json to enable.
|
||||
# [Option] Install Node.js
|
||||
ARG INSTALL_NODE="true"
|
||||
ARG NODE_VERSION="none"
|
||||
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 \
|
||||
RUN if [ "$INSTALL_NODE" = "true" ]; then 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
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
|
|
|
@ -63,6 +63,10 @@ mkdir -p ${NVM_DIR}
|
|||
chown ${USERNAME} ${NVM_DIR}
|
||||
su ${USERNAME} -c "$(cat << EOF
|
||||
set -e
|
||||
|
||||
# Do not update profile - we'll do this manually
|
||||
export PROFILE=/dev/null
|
||||
|
||||
curl -so- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
|
||||
source ${NVM_DIR}/nvm.sh
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
|
@ -73,13 +77,27 @@ EOF
|
|||
)" 2>&1
|
||||
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc with NVM scripts..."
|
||||
(cat <<EOF
|
||||
export NVM_DIR="${NVM_DIR}"
|
||||
sudoIf()
|
||||
{
|
||||
if [ "\$(id -u)" -ne 0 ]; then
|
||||
sudo "\$@"
|
||||
else
|
||||
"\$@"
|
||||
fi
|
||||
}
|
||||
if [ "\$(stat -c '%U' \$NVM_DIR)" != "${USERNAME}" ]; then
|
||||
if [ "\$(id -u)" -eq 0 ] || type sudo > /dev/null 2>&1; then
|
||||
echo "Fixing permissions of \"\$NVM_DIR\"..."
|
||||
sudoIf chown -R ${USERNAME}:root \$NVM_DIR
|
||||
else
|
||||
echo "Warning: NVM directory is not owned by ${USERNAME} and sudo is not installed. Unable to correct permissions."
|
||||
fi
|
||||
fi
|
||||
[ -s "\$NVM_DIR/nvm.sh" ] && . "\$NVM_DIR/nvm.sh"
|
||||
[ -s "\$NVM_DIR/bash_completion" ] && . "\$NVM_DIR/bash_completion"
|
||||
if [ "\$(stat -c '%U' \$NVM_DIR)" != "${USERNAME}" ]; then
|
||||
sudo chown -R ${USERNAME}:root \$NVM_DIR
|
||||
fi
|
||||
EOF
|
||||
) | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
#!/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: ./ruby-debian.sh [Ruby version] [non-root user] [Add rvm to rc files flag]
|
||||
|
||||
RUBY_VERSION=${1:-"latest"}
|
||||
USERNAME=${2:-"vscode"}
|
||||
UPDATE_RC=${3:-"true"}
|
||||
INSTALL_RUBY_TOOLS=${6:-"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" or non-existant user as root
|
||||
if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
|
||||
USERNAME=root
|
||||
fi
|
||||
|
||||
# Determine appropriate settings for rvm
|
||||
DEFAULT_GEMS="rake ruby-debug-ide debase"
|
||||
if [ "${RUBY_VERSION}" = "none" ]; then
|
||||
RVM_INSTALL_ARGS=""
|
||||
else
|
||||
if [ "${RUBY_VERSION}" = "latest" ] || [ "${RUBY_VERSION}" = "current" ] || [ "${RUBY_VERSION}" = "lts" ]; then
|
||||
RVM_INSTALL_ARGS="--ruby"
|
||||
RUBY_VERSION=""
|
||||
else
|
||||
RVM_INSTALL_ARGS="--ruby=${RUBY_VERSION}"
|
||||
fi
|
||||
if [ "${INSTALL_RUBY_TOOLS}" = "true" ]; then
|
||||
SKIP_GEM_INSTALL="true"
|
||||
else
|
||||
DEFAULT_GEMS=""
|
||||
fi
|
||||
fi
|
||||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install curl, software-properties-common, build-essential, gnupg2 if missing
|
||||
if ! dpkg -s curl ca-certificates software-properties-common build-essential gnupg2 > /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 curl ca-certificates software-properties-common build-essential gnupg2
|
||||
fi
|
||||
|
||||
# Just install Ruby if RVM already installed
|
||||
if [ -d "/usr/local/rvm" ]; then
|
||||
echo "Ruby Version Manager already exists."
|
||||
if [ "${RUBY_VERSION}" != "none" ]; then
|
||||
echo "Installing specified Ruby version."
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm install ruby ${RUBY_VERSION}"
|
||||
fi
|
||||
SKIP_GEM_INSTALL="false"
|
||||
else
|
||||
# Use a temporary locaiton for gpg keys to avoid polluting image
|
||||
export GNUPGHOME="/tmp/rvm-gnupg"
|
||||
mkdir -p ${GNUPGHOME}
|
||||
echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf
|
||||
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB 2>&1
|
||||
# Install RVM
|
||||
curl -sSL https://get.rvm.io | bash -s stable --ignore-dotfiles ${RVM_INSTALL_ARGS} --with-default-gems="${DEFAULT_GEMS}" 2>&1
|
||||
usermod -aG rvm ${USERNAME}
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system"
|
||||
rm -rf ${GNUPGHOME}
|
||||
fi
|
||||
if [ "${INSTALL_RUBY_TOOLS}" = "true" ] && [ "${SKIP_GEM_INSTALL}" != "true" ]; then
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && gem install ${DEFAULT_GEMS}"
|
||||
fi
|
||||
|
||||
# VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it
|
||||
updaterc "if ! grep rvm_silence_path_mismatch_check_flag \$HOME/.rvmrc > /dev/null 2>&1; then echo 'rvm_silence_path_mismatch_check_flag=1' >> \$HOME/.rvmrc; fi\nsource /usr/local/rvm/scripts/rvm"
|
||||
|
||||
# Clean up
|
||||
source /usr/local/rvm/scripts/rvm
|
||||
rvm cleanup all
|
||||
gem cleanup
|
||||
echo "Done!"
|
|
@ -1,25 +1,19 @@
|
|||
FROM rust:1
|
||||
|
||||
# Options for setup script
|
||||
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
||||
ARG INSTALL_ZSH="true"
|
||||
ARG UPGRADE_PACKAGES="false"
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=$USER_UID
|
||||
|
||||
# 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 apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
|
||||
&& apt-get purge -y imagemagick imagemagick-6-common \
|
||||
# Install common packages, non-root user, updated lldb, dependencies
|
||||
&& bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \
|
||||
&& apt-get install -y lldb python3-minimal libpython3.7 \
|
||||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
|
||||
|
||||
# Install Rust components
|
||||
RUN rustup update 2>&1 \
|
||||
&& rustup component add rls rust-analysis rust-src rustfmt clippy 2>&1
|
||||
&& bash /tmp/library-scripts/rust-debian.sh "${CARGO_HOME}" "${RUSTUP_HOME}" "${USERNAME}" "false" "true" \
|
||||
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
#!/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: ./rust-debian.sh [CARGO_HOME] [RUSTUP_HOME] [non-root user] [add CARGO/RUSTUP_HOME to rc files flag] [whether to update rust]
|
||||
|
||||
export CARGO_HOME=${1:-"/usr/local/cargo"}
|
||||
export RUSTUP_HOME=${2:-"/usr/local/rustup"}
|
||||
USERNAME=${3:-"vscode"}
|
||||
UPDATE_RC=${4:-"true"}
|
||||
UPDATE_RUST=${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" or non-existant user as root
|
||||
if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
|
||||
USERNAME=root
|
||||
fi
|
||||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install curl, lldb, python3-minimal,and rust dependencies if missing
|
||||
if ! dpkg -s curl ca-certificates lldb python3-minimal gcc libc6-dev > /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 curl ca-certificates gcc libc6-dev
|
||||
apt-get -y install lldb python3-minimal libpython3.?
|
||||
fi
|
||||
|
||||
# Install Rust
|
||||
if ! type rustup > /dev/null 2>&1; then
|
||||
echo "Installing Rust..."
|
||||
mkdir -p "${CARGO_HOME}" "${RUSTUP_HOME}"
|
||||
chown ${USERNAME}:root "${CARGO_HOME}" "${RUSTUP_HOME}"
|
||||
su ${USERNAME} -c "curl --tlsv1.2 https://sh.rustup.rs -sSf | bash -s -- -y --no-modify-path --profile minimal 2>&1"
|
||||
else
|
||||
echo "Rust already installed. Skipping."
|
||||
fi
|
||||
|
||||
su ${USERNAME} -c "$(cat << EOF
|
||||
set -e
|
||||
export PATH=${PATH}:${CARGO_HOME}/bin
|
||||
if [ "${UPDATE_RUST}" = "true" ]; then
|
||||
echo "Updating Rust..."
|
||||
rustup update 2>&1
|
||||
fi
|
||||
echo "Installing common Rust dependencies..."
|
||||
rustup component add rls rust-analysis rust-src rustfmt clippy 2>&1
|
||||
EOF
|
||||
)"
|
||||
|
||||
# Add CARGO_HOME, RUSTUP_HOME and bin directory into bashrc/zshrc files (unless disabled)
|
||||
updaterc "export CARGO_HOME=\"${CARGO_HOME}\"\nexport RUSTUP_HOME=\"${RUSTUP_HOME}\"\nexport PATH=\"\${CARGO_HOME}/bin:\${PATH}\""
|
||||
echo "Done!"
|
||||
|
|
@ -27,6 +27,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
@ -56,7 +57,7 @@ GO_INSTALL_SCRIPT="$(cat <<EOF
|
|||
rm -f /tmp/go.tar.gz
|
||||
EOF
|
||||
)"
|
||||
if ! type go > /dev/null 2>&1; then
|
||||
if [ "${TARGET_GO_VERSION}" != "none" ] && ! type go > /dev/null 2>&1; then
|
||||
mkdir -p "${TARGET_GOROOT}" "${TARGET_GOPATH}"
|
||||
chown ${USERNAME}:root "${TARGET_GOROOT}" "${TARGET_GOPATH}"
|
||||
su ${USERNAME} -c "${GO_INSTALL_SCRIPT}"
|
||||
|
@ -105,15 +106,15 @@ if [ "${INSTALL_GO_TOOLS}" = "true" ]; then
|
|||
go build -o gocode-gomod github.com/stamblerre/gocode
|
||||
|
||||
# golangci-lint
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin 2>&1
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${TARGET_GOPATH}/bin 2>&1
|
||||
|
||||
# Move Go tools into path and clean up
|
||||
mv /tmp/gotools/bin/* /usr/local/bin/
|
||||
mv gocode-gomod /usr/local/bin/
|
||||
mv /tmp/gotools/bin/* ${TARGET_GOPATH}/bin/
|
||||
mv gocode-gomod ${TARGET_GOPATH}/bin/
|
||||
rm -rf /tmp/gotools
|
||||
fi
|
||||
|
||||
# Add GOPATH variable and bin directory into PATH in bashrc/zshrc files (unless disabled)
|
||||
updaterc "export GOPATH=\"${TARGET_GOPATH}\"\nexport GOROOT=\"${TARGET_GOROOT}\"\nexport PATH=\"\${GOROOT}/bin:\${PATH}\""
|
||||
updaterc "export GOPATH=\"${TARGET_GOPATH}\"\nexport GOROOT=\"${TARGET_GOROOT}\"\nexport PATH=\"\${GOROOT}/bin:\${GOPATH}/bin:\${PATH}\""
|
||||
echo "Done!"
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -28,6 +28,13 @@ if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
|
|||
USERNAME=root
|
||||
fi
|
||||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install curl, zip, unzip if missing
|
||||
|
@ -43,10 +50,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
curl -sSL "https://get.sdkman.io?rcupdate=false" | bash
|
||||
chown -R "${USERNAME}" "${SDKMAN_DIR}"
|
||||
# Add sourcing of sdkman into bashrc/zshrc files (unless disabled)
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
RC_SNIPPET="export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
|
||||
echo -e ${RC_SNIPPET} | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
updaterc "export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
|
||||
fi
|
||||
|
||||
if [ "${JAVA_VERSION}" != "none" ]; then
|
||||
|
|
|
@ -30,6 +30,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -63,6 +63,10 @@ mkdir -p ${NVM_DIR}
|
|||
chown ${USERNAME} ${NVM_DIR}
|
||||
su ${USERNAME} -c "$(cat << EOF
|
||||
set -e
|
||||
|
||||
# Do not update profile - we'll do this manually
|
||||
export PROFILE=/dev/null
|
||||
|
||||
curl -so- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
|
||||
source ${NVM_DIR}/nvm.sh
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
|
@ -73,13 +77,27 @@ EOF
|
|||
)" 2>&1
|
||||
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc with NVM scripts..."
|
||||
(cat <<EOF
|
||||
export NVM_DIR="${NVM_DIR}"
|
||||
sudoIf()
|
||||
{
|
||||
if [ "\$(id -u)" -ne 0 ]; then
|
||||
sudo "\$@"
|
||||
else
|
||||
"\$@"
|
||||
fi
|
||||
}
|
||||
if [ "\$(stat -c '%U' \$NVM_DIR)" != "${USERNAME}" ]; then
|
||||
if [ "\$(id -u)" -eq 0 ] || type sudo > /dev/null 2>&1; then
|
||||
echo "Fixing permissions of \"\$NVM_DIR\"..."
|
||||
sudoIf chown -R ${USERNAME}:root \$NVM_DIR
|
||||
else
|
||||
echo "Warning: NVM directory is not owned by ${USERNAME} and sudo is not installed. Unable to correct permissions."
|
||||
fi
|
||||
fi
|
||||
[ -s "\$NVM_DIR/nvm.sh" ] && . "\$NVM_DIR/nvm.sh"
|
||||
[ -s "\$NVM_DIR/bash_completion" ] && . "\$NVM_DIR/bash_completion"
|
||||
if [ "\$(stat -c '%U' \$NVM_DIR)" != "${USERNAME}" ]; then
|
||||
sudo chown -R ${USERNAME}:root \$NVM_DIR
|
||||
fi
|
||||
EOF
|
||||
) | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
|
|
|
@ -27,6 +27,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
# Syntax: ./ruby-debian.sh [Ruby version] [non-root user] [Add rvm to rc files flag]
|
||||
|
||||
RUBY_VERSION=${1:-"stable"}
|
||||
RUBY_VERSION=${1:-"latest"}
|
||||
USERNAME=${2:-"vscode"}
|
||||
UPDATE_RC=${3:-"true"}
|
||||
INSTALL_RUBY_TOOLS=${6:-"true"}
|
||||
|
||||
set -e
|
||||
|
||||
|
@ -22,45 +23,70 @@ if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
|
|||
USERNAME=root
|
||||
fi
|
||||
|
||||
# Determine appropriate settings for rvm
|
||||
DEFAULT_GEMS="rake ruby-debug-ide debase"
|
||||
if [ "${RUBY_VERSION}" = "none" ]; then
|
||||
RVM_INSTALL_ARGS=""
|
||||
else
|
||||
if [ "${RUBY_VERSION}" = "latest" ] || [ "${RUBY_VERSION}" = "current" ] || [ "${RUBY_VERSION}" = "lts" ]; then
|
||||
RVM_INSTALL_ARGS="--ruby"
|
||||
RUBY_VERSION=""
|
||||
else
|
||||
RVM_INSTALL_ARGS="--ruby=${RUBY_VERSION}"
|
||||
fi
|
||||
if [ "${INSTALL_RUBY_TOOLS}" = "true" ]; then
|
||||
SKIP_GEM_INSTALL="true"
|
||||
else
|
||||
DEFAULT_GEMS=""
|
||||
fi
|
||||
fi
|
||||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install curl, software-properties-common, gnupg2 if missing
|
||||
if ! dpkg -s curl ca-certificates software-properties-common gnupg2 > /dev/null 2>&1; then
|
||||
# Install curl, software-properties-common, build-essential, gnupg2 if missing
|
||||
if ! dpkg -s curl ca-certificates software-properties-common build-essential gnupg2 > /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 curl ca-certificates software-properties-common gnupg2
|
||||
apt-get -y install --no-install-recommends curl ca-certificates software-properties-common build-essential gnupg2
|
||||
fi
|
||||
|
||||
# Just install Ruby if RVM already installed
|
||||
if [ -d "/usr/local/rvm" ]; then
|
||||
echo "Ruby Version Manager already exists. Installing specified Ruby version."
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm install ${RUBY_VERSION}"
|
||||
source /usr/local/rvm/scripts/rvm
|
||||
rvm cleanup all
|
||||
gem cleanup
|
||||
exit 0
|
||||
echo "Ruby Version Manager already exists."
|
||||
if [ "${RUBY_VERSION}" != "none" ]; then
|
||||
echo "Installing specified Ruby version."
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm install ruby ${RUBY_VERSION}"
|
||||
fi
|
||||
SKIP_GEM_INSTALL="false"
|
||||
else
|
||||
# Use a temporary locaiton for gpg keys to avoid polluting image
|
||||
export GNUPGHOME="/tmp/rvm-gnupg"
|
||||
mkdir -p ${GNUPGHOME}
|
||||
echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf
|
||||
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB 2>&1
|
||||
# Install RVM
|
||||
curl -sSL https://get.rvm.io | bash -s stable --ignore-dotfiles ${RVM_INSTALL_ARGS} --with-default-gems="${DEFAULT_GEMS}" 2>&1
|
||||
usermod -aG rvm ${USERNAME}
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system"
|
||||
rm -rf ${GNUPGHOME}
|
||||
fi
|
||||
if [ "${INSTALL_RUBY_TOOLS}" = "true" ] && [ "${SKIP_GEM_INSTALL}" != "true" ]; then
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && gem install ${DEFAULT_GEMS}"
|
||||
fi
|
||||
|
||||
# Use a temporary locaiton for gpg keys to avoid polluting image
|
||||
export GNUPGHOME="/tmp/rvm-gnupg"
|
||||
mkdir -p ${GNUPGHOME}
|
||||
echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf
|
||||
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB 2>&1 \
|
||||
# VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it
|
||||
updaterc "if ! grep rvm_silence_path_mismatch_check_flag \$HOME/.rvmrc > /dev/null 2>&1; then echo 'rvm_silence_path_mismatch_check_flag=1' >> \$HOME/.rvmrc; fi\nsource /usr/local/rvm/scripts/rvm"
|
||||
|
||||
# Install RVM
|
||||
curl -sSL https://get.rvm.io | bash -s "${RUBY_VERSION}" --ruby --with-default-gems="rake ruby-debug-ide debase" 2>&1
|
||||
usermod -aG rvm ${USERNAME}
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system"
|
||||
rm -rf ${GNUPGHOME}
|
||||
# Clean up
|
||||
source /usr/local/rvm/scripts/rvm
|
||||
rvm cleanup all
|
||||
gem cleanup
|
||||
updaterc "source /usr/local/rvm/scripts/rvm"
|
||||
echo "Done!"
|
||||
echo "Done!"
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Syntax: ./rust-debian.sh [CARGO_HOME] [RUSTUP_HOME] [non-root user] [add CARGO/RUSTUP_HOME to rc files flag]
|
||||
# Syntax: ./rust-debian.sh [CARGO_HOME] [RUSTUP_HOME] [non-root user] [add CARGO/RUSTUP_HOME to rc files flag] [whether to update rust]
|
||||
|
||||
export CARGO_HOME=${1:-"/usr/local/cargo"}
|
||||
export RUSTUP_HOME=${2:-"/usr/local/rustup"}
|
||||
USERNAME=${3:-"vscode"}
|
||||
UPDATE_RC=${4:-"true"}
|
||||
UPDATE_RUST=${5:-"true"}
|
||||
|
||||
set -e
|
||||
|
||||
|
@ -25,6 +26,7 @@ fi
|
|||
|
||||
function updaterc() {
|
||||
if [ "${UPDATE_RC}" = "true" ]; then
|
||||
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
|
||||
echo -e "$1" | tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
fi
|
||||
}
|
||||
|
@ -50,11 +52,14 @@ else
|
|||
echo "Rust already installed. Skipping."
|
||||
fi
|
||||
|
||||
echo "Installing common Rust dependencies..."
|
||||
su ${USERNAME} -c "$(cat << EOF
|
||||
set -e
|
||||
export PATH=${PATH}:${CARGO_HOME}/bin
|
||||
rustup update 2>&1
|
||||
if [ "${UPDATE_RUST}" = "true" ]; then
|
||||
echo "Updating Rust..."
|
||||
rustup update 2>&1
|
||||
fi
|
||||
echo "Installing common Rust dependencies..."
|
||||
rustup component add rls rust-analysis rust-src rustfmt clippy 2>&1
|
||||
EOF
|
||||
)"
|
||||
|
|
Загрузка…
Ссылка в новой задаче