Skip to content

Commit 30366da

Browse files
jharrilimiamsolankiamit
authored andcommitted
Add devcontainer files (#40)
1 parent ea193ef commit 30366da

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
FROM node:12
7+
8+
# Avoid warnings by switching to noninteractive
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# The node image includes a non-root user with sudo access. Use the "remoteUser"
12+
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
13+
# will be updated to match your local UID/GID (when using the dockerFile property).
14+
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
15+
ARG USERNAME=node
16+
ARG USER_UID=1000
17+
ARG USER_GID=$USER_UID
18+
19+
# Configure apt and install packages
20+
RUN apt-get update \
21+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
22+
#
23+
# Verify git and needed tools are installed
24+
&& apt-get -y install git iproute2 procps \
25+
#
26+
# Remove outdated yarn from /opt and install via package
27+
# so it can be easily updated via apt-get upgrade yarn
28+
&& rm -rf /opt/yarn-* \
29+
&& rm -f /usr/local/bin/yarn \
30+
&& rm -f /usr/local/bin/yarnpkg \
31+
&& apt-get install -y curl apt-transport-https lsb-release \
32+
&& curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - 2>/dev/null \
33+
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
34+
&& apt-get update \
35+
&& apt-get -y install --no-install-recommends yarn \
36+
#
37+
# Install tslint and typescript globally
38+
&& npm install -g tslint eslint typescript \
39+
#
40+
# [Optional] Update a non-root user to UID/GID if needed.
41+
&& if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
42+
groupmod --gid $USER_GID $USERNAME \
43+
&& usermod --uid $USER_UID --gid $USER_GID $USERNAME \
44+
&& chown -R $USER_UID:$USER_GID /home/$USERNAME; \
45+
fi \
46+
# [Optional] Add add sudo support for non-root user
47+
&& apt-get install -y sudo \
48+
&& echo node ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
49+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
50+
#
51+
# Clean up
52+
&& apt-get autoremove -y \
53+
&& apt-get clean -y \
54+
&& rm -rf /var/lib/apt/lists/*
55+
56+
# Switch back to dialog for any ad-hoc use of apt-get
57+
ENV DEBIAN_FRONTEND=dialog

.devcontainer/devcontainer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
2+
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/typescript-node-12
3+
{
4+
"name": "Local Storage",
5+
"dockerFile": "Dockerfile",
6+
7+
// Use 'settings' to set *default* container specific settings.json values on container create.
8+
// You can edit these settings after create using File > Preferences > Settings > Remote.
9+
"settings": {
10+
"terminal.integrated.shell.linux": "/bin/bash"
11+
},
12+
13+
// Use 'appPort' to create a container with published ports. If the port isn't working, be sure
14+
// your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost.
15+
// "appPort": [],
16+
17+
// Uncomment the next line to run commands after the container is created.
18+
// "postCreateCommand": "yarn install",
19+
20+
// Uncomment the next line to have VS Code connect as an existing non-root user in the container.
21+
// On Linux, by default, the container user's UID/GID will be updated to match your local user. See
22+
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
23+
// "remoteUser": "node",
24+
25+
// Add the IDs of extensions you want installed when the container is created in the array below.
26+
"extensions": [
27+
"dbaeumer.vscode-eslint",
28+
"aaron-bond.better-comments",
29+
"streetsidesoftware.code-spell-checker",
30+
"ms-vscode.vscode-typescript-tslint-plugin"
31+
]
32+
}

0 commit comments

Comments
 (0)