Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit f1c9ab4

Browse files
committed
Use NVM to install Node in .NET Core repos so new versions can be installed.
1 parent db9844b commit f1c9ab4

File tree

6 files changed

+96
-43
lines changed

6 files changed

+96
-43
lines changed

containers/dotnetcore-2.1/.devcontainer/Dockerfile

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
44
#-------------------------------------------------------------------------------------------------------------
5-
6-
FROM mcr.microsoft.com/dotnet/core/sdk:2.1
5+
ARG DOTNETCORE_VESRION=2.1
6+
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNETCORE_VESRION}
77

88
# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
99
# this user's GID/UID must match your local user UID/GID to avoid permission issues
@@ -15,7 +15,8 @@ ARG USER_GID=$USER_UID
1515

1616
# [Optional] Version of Node.js to install.
1717
ARG INSTALL_NODE="true"
18-
ARG NODE_MAJOR_VERSION="10"
18+
ARG NODE_VERSION="lts/*"
19+
ENV NVM_DIR=/home/vscode/.nvm
1920

2021
# [Optional] Install the Azure CLI
2122
ARG INSTALL_AZURE_CLI="false"
@@ -30,10 +31,34 @@ RUN apt-get update \
3031
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
3132
&& apt-get -y install git iproute2 procps lsb-release \
3233
#
34+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
35+
&& groupadd --gid $USER_GID $USERNAME \
36+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
37+
# [Optional] Add sudo support for the non-root user
38+
&& apt-get install -y sudo \
39+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
40+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
41+
#
3342
# [Optional] Install Node.js for ASP.NET Core Web Applicationss
3443
&& if [ "$INSTALL_NODE" = "true" ]; then \
35-
curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR_VERSION.x | bash - \
36-
&& apt-get install -y nodejs; \
44+
#
45+
# Install nvm and Node
46+
mkdir ${NVM_DIR} \
47+
&& curl -so- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash 2>&1 \
48+
&& chown -R vscode:vscode ${NVM_DIR} \
49+
&& /bin/bash -c "source $NVM_DIR/nvm.sh \
50+
&& nvm install ${NODE_VERSION} \
51+
&& nvm alias default ${NODE_VERSION}" 2>&1 \
52+
&& INIT_STRING='[ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \\. "$NVM_DIR/bash_completion"' \
53+
&& echo $INIT_STRING >> /home/vscode/.bashrc \
54+
&& echo $INIT_STRING >> /home/vscode/.zshrc \
55+
&& echo $INIT_STRING >> /root/.zshrc \
56+
#
57+
# Install yarn
58+
&& curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - 2>/dev/null \
59+
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
60+
&& apt-get update \
61+
&& apt-get -y install --no-install-recommends yarn; \
3762
fi \
3863
#
3964
# [Optional] Install the Azure CLI
@@ -45,14 +70,6 @@ RUN apt-get update \
4570
&& apt-get install -y azure-cli; \
4671
fi \
4772
#
48-
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
49-
&& groupadd --gid $USER_GID $USERNAME \
50-
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
51-
# [Optional] Add sudo support for the non-root user
52-
&& apt-get install -y sudo \
53-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
54-
&& chmod 0440 /etc/sudoers.d/$USERNAME \
55-
#
5673
# Clean up
5774
&& apt-get autoremove -y \
5875
&& apt-get clean -y \

containers/dotnetcore-2.1/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Given how frequently ASP.NET applications use Node.js for front end code, this c
7373

7474
```Dockerfile
7575
ARG INSTALL_NODE="true"
76-
ARG NODE_MAJOR_VERSION="10"
76+
ARG NODE_VERSION="10"
7777
```
7878

7979
If you would like to install the Azure CLI update this line in `.devcontainer/Dockerfile`:

containers/dotnetcore-2.2/.devcontainer/Dockerfile

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
44
#-------------------------------------------------------------------------------------------------------------
55

6-
FROM mcr.microsoft.com/dotnet/core/sdk:2.2
6+
ARG DOTNETCORE_VESRION=2.2
7+
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNETCORE_VESRION}
78

8-
## This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
9+
# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
910
# this user's GID/UID must match your local user UID/GID to avoid permission issues
1011
# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
1112
# https://aka.ms/vscode-remote/containers/non-root-user for details.
@@ -15,7 +16,8 @@ ARG USER_GID=$USER_UID
1516

1617
# [Optional] Version of Node.js to install.
1718
ARG INSTALL_NODE="true"
18-
ARG NODE_MAJOR_VERSION="10"
19+
ARG NODE_VERSION="lts/*"
20+
ENV NVM_DIR=/home/vscode/.nvm
1921

2022
# [Optional] Install the Azure CLI
2123
ARG INSTALL_AZURE_CLI="false"
@@ -30,10 +32,34 @@ RUN apt-get update \
3032
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
3133
&& apt-get -y install git iproute2 procps lsb-release \
3234
#
35+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
36+
&& groupadd --gid $USER_GID $USERNAME \
37+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
38+
# [Optional] Add sudo support for the non-root user
39+
&& apt-get install -y sudo \
40+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
41+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
42+
#
3343
# [Optional] Install Node.js for ASP.NET Core Web Applicationss
3444
&& if [ "$INSTALL_NODE" = "true" ]; then \
35-
curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR_VERSION.x | bash - \
36-
&& apt-get install -y nodejs; \
45+
#
46+
# Install nvm and Node
47+
mkdir ${NVM_DIR} \
48+
&& curl -so- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash 2>&1 \
49+
&& chown -R vscode:vscode ${NVM_DIR} \
50+
&& /bin/bash -c "source $NVM_DIR/nvm.sh \
51+
&& nvm install ${NODE_VERSION} \
52+
&& nvm alias default ${NODE_VERSION}" 2>&1 \
53+
&& INIT_STRING='[ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \\. "$NVM_DIR/bash_completion"' \
54+
&& echo $INIT_STRING >> /home/vscode/.bashrc \
55+
&& echo $INIT_STRING >> /home/vscode/.zshrc \
56+
&& echo $INIT_STRING >> /root/.zshrc \
57+
#
58+
# Install yarn
59+
&& curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - 2>/dev/null \
60+
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
61+
&& apt-get update \
62+
&& apt-get -y install --no-install-recommends yarn; \
3763
fi \
3864
#
3965
# [Optional] Install the Azure CLI
@@ -45,14 +71,6 @@ RUN apt-get update \
4571
&& apt-get install -y azure-cli; \
4672
fi \
4773
#
48-
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
49-
&& groupadd --gid $USER_GID $USERNAME \
50-
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
51-
# [Optional] Add sudo support for the non-root user
52-
&& apt-get install -y sudo \
53-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
54-
&& chmod 0440 /etc/sudoers.d/$USERNAME \
55-
#
5674
# Clean up
5775
&& apt-get autoremove -y \
5876
&& apt-get clean -y \

containers/dotnetcore-2.2/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Given how frequently ASP.NET applications use Node.js for front end code, this c
7373

7474
```Dockerfile
7575
ARG INSTALL_NODE="true"
76-
ARG NODE_MAJOR_VERSION="10"
76+
ARG NODE_VERSION="10"
7777
```
7878

7979
If you would like to install the Azure CLI update this line in `.devcontainer/Dockerfile`:

containers/dotnetcore-3.0/.devcontainer/Dockerfile

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
44
#-------------------------------------------------------------------------------------------------------------
55

6-
FROM mcr.microsoft.com/dotnet/core/sdk:3.0
6+
ARG DOTNETCORE_VESRION=3.0
7+
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNETCORE_VESRION}
78

89
# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
910
# this user's GID/UID must match your local user UID/GID to avoid permission issues
@@ -15,7 +16,8 @@ ARG USER_GID=$USER_UID
1516

1617
# [Optional] Version of Node.js to install.
1718
ARG INSTALL_NODE="true"
18-
ARG NODE_MAJOR_VERSION="10"
19+
ARG NODE_VERSION="lts/*"
20+
ENV NVM_DIR=/home/vscode/.nvm
1921

2022
# [Optional] Install the Azure CLI
2123
ARG INSTALL_AZURE_CLI="false"
@@ -30,10 +32,34 @@ RUN apt-get update \
3032
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
3133
&& apt-get -y install git iproute2 procps lsb-release \
3234
#
35+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
36+
&& groupadd --gid $USER_GID $USERNAME \
37+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
38+
# [Optional] Add sudo support for the non-root user
39+
&& apt-get install -y sudo \
40+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
41+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
42+
#
3343
# [Optional] Install Node.js for ASP.NET Core Web Applicationss
3444
&& if [ "$INSTALL_NODE" = "true" ]; then \
35-
curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR_VERSION.x | bash - \
36-
&& apt-get install -y nodejs; \
45+
#
46+
# Install nvm and Node
47+
mkdir ${NVM_DIR} \
48+
&& curl -so- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash 2>&1 \
49+
&& chown -R vscode:vscode ${NVM_DIR} \
50+
&& /bin/bash -c "source $NVM_DIR/nvm.sh \
51+
&& nvm install ${NODE_VERSION} \
52+
&& nvm alias default ${NODE_VERSION}" 2>&1 \
53+
&& INIT_STRING='[ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \\. "$NVM_DIR/bash_completion"' \
54+
&& echo $INIT_STRING >> /home/vscode/.bashrc \
55+
&& echo $INIT_STRING >> /home/vscode/.zshrc \
56+
&& echo $INIT_STRING >> /root/.zshrc \
57+
#
58+
# Install yarn
59+
&& curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - 2>/dev/null \
60+
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
61+
&& apt-get update \
62+
&& apt-get -y install --no-install-recommends yarn; \
3763
fi \
3864
#
3965
# [Optional] Install the Azure CLI
@@ -45,14 +71,6 @@ RUN apt-get update \
4571
&& apt-get install -y azure-cli; \
4672
fi \
4773
#
48-
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
49-
&& groupadd --gid $USER_GID $USERNAME \
50-
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
51-
# [Optional] Add sudo support for the non-root user
52-
&& apt-get install -y sudo \
53-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
54-
&& chmod 0440 /etc/sudoers.d/$USERNAME \
55-
#
5674
# Clean up
5775
&& apt-get autoremove -y \
5876
&& apt-get clean -y \

containers/dotnetcore-3.0/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# C# (latest .NET Core)
1+
# C# (.NET Core 3.0)
22

33
## Summary
44

5-
*Develop C# and .NET Core (latest) based applications. Includes all needed SDKs, extensions, and dependencies.*
5+
*Develop C# and .NET Core 3.0 based applications. Includes all needed SDKs, extensions, and dependencies.*
66

77
| Metadata | Value |
88
|----------|-------|
@@ -73,7 +73,7 @@ Given how frequently ASP.NET applications use Node.js for front end code, this c
7373

7474
```Dockerfile
7575
ARG INSTALL_NODE="true"
76-
ARG NODE_MAJOR_VERSION="10"
76+
ARG NODE_VERSION="10"
7777
```
7878

7979
If you would like to install the Azure CLI update this line in `.devcontainer/Dockerfile`:

0 commit comments

Comments
 (0)