Skip to content

Commit bcfad1b

Browse files
committed
Add javascript-node and typescript-node
1 parent 9e6ef98 commit bcfad1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+17088
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Smoke test "javascript-node" build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
paths:
10+
- src/javascript-node/**
11+
- .github/workflows/smoke-javascript-node.yaml
12+
- .github/actions/**
13+
- build/**
14+
jobs:
15+
smoke-test:
16+
name: Smoke test
17+
runs-on: ubuntu-latest
18+
steps:
19+
20+
- name: Checkout
21+
id: checkout
22+
uses: actions/checkout@v3
23+
24+
- name: Smoke test
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
id: smoke_test
28+
uses: ./.github/actions/smoke-test
29+
with:
30+
image: javascript-node
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Smoke test "typescript-node" build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
paths:
10+
- src/typescript-node/**
11+
- .github/workflows/smoke-typescript-node.yaml
12+
- .github/actions/**
13+
- build/**
14+
jobs:
15+
smoke-test:
16+
name: Smoke test
17+
runs-on: ubuntu-latest
18+
steps:
19+
20+
- name: Checkout
21+
id: checkout
22+
uses: actions/checkout@v3
23+
24+
- name: Smoke test
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
id: smoke_test
28+
uses: ./.github/actions/smoke-test
29+
with:
30+
image: typescript-node
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "Node.js",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
// Update 'VARIANT' to pick a Node version: 18, 16, 14.
6+
// Append -bullseye or -buster to pin to an OS version.
7+
// Use -bullseye variants on local arm64/Apple Silicon.
8+
"args": { "VARIANT": "16-bullseye" }
9+
},
10+
"features": {
11+
"ghcr.io/devcontainers/features/common-utils:1": {
12+
"installZsh": "true",
13+
"username": "vscode",
14+
"uid": "1000",
15+
"gid": "1000",
16+
"upgradePackages": "true"
17+
},
18+
"ghcr.io/devcontainers/features/node:1": {
19+
"version": "none"
20+
}
21+
},
22+
"overrideFeatureInstallOrder": [
23+
"common-utils"
24+
],
25+
26+
// Configure tool-specific properties.
27+
"customizations": {
28+
// Configure properties specific to VS Code.
29+
"vscode": {
30+
// Add the IDs of extensions you want installed when the container is created.
31+
"extensions": [
32+
"dbaeumer.vscode-eslint"
33+
]
34+
}
35+
},
36+
37+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
38+
// "forwardPorts": [],
39+
40+
// Use 'postCreateCommand' to run commands after the container is created.
41+
// "postCreateCommand": "yarn install",
42+
43+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
44+
"remoteUser": "node"
45+
}

src/javascript-node/.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
README.md
2+
test-project
3+
history
4+
manifest.json
5+
.npmignore
6+
meta.env

src/javascript-node/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
2+
ARG VARIANT=16-bullseye
3+
FROM node:${VARIANT}
4+
5+
# [Optional] Uncomment this section to install additional OS packages.
6+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
7+
# && apt-get -y install --no-install-recommends <your-package-list-here>
8+
9+
# [Optional] Uncomment if you want to install an additional version of node using nvm
10+
# ARG EXTRA_NODE_VERSION=10
11+
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
12+
13+
# [Optional] Uncomment if you want to install more global node modules
14+
# RUN su node -c "npm install -g <your-package-list-here>"

src/javascript-node/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Node.js & JavaScript
2+
3+
## Summary
4+
5+
*Develop Node.js based applications. Includes Node.js, eslint, nvm, and yarn.*
6+
7+
| Metadata | Value |
8+
|----------|-------|
9+
| *Contributors* | The VS Code Team |
10+
| *Categories* | Core, Languages |
11+
| *Definition type* | Dockerfile |
12+
| *Published image* | mcr.microsoft.com/vscode/devcontainers/javascript-node |
13+
| *Available image variants* | 18 / 18-bullseye, 16 / 16-bullseye, 14 / 14-bullseye, 18-buster, 16-buster, 14-buster ([full list](https://mcr.microsoft.com/v2/vscode/devcontainers/javascript-node/tags/list)) |
14+
| *Published image architecture(s)* | x86-64, arm64/aarch64 for `bullseye` variants |
15+
| *Works in Codespaces* | Yes |
16+
| *Container host OS support* | Linux, macOS, Windows |
17+
| *Container OS* | Debian |
18+
| *Languages, platforms* | Node.js, JavaScript |
19+
20+
See **[history](history)** for information on the contents of published images.
21+
22+
## Using this definition
23+
24+
While the definition itself works unmodified, you can select the version of Node.js the container uses by updating the `VARIANT` arg in the included `devcontainer.json` (and rebuilding if you've already created the container).
25+
26+
```jsonc
27+
// Or you can use 16-bullseye or 16-buster if you want to pin to an OS version
28+
"args": { "VARIANT": "16" }
29+
```
30+
31+
You can also directly reference pre-built versions of `.devcontainer/base.Dockerfile` by using the `image` property in `.devcontainer/devcontainer.json` or updating the `FROM` statement in your own `Dockerfile` with one of the following:
32+
33+
- `mcr.microsoft.com/vscode/devcontainers/javascript-node` (latest)
34+
- `mcr.microsoft.com/vscode/devcontainers/javascript-node:18` (or `18-bullseye`, `18-buster` to pin to an OS version)
35+
- `mcr.microsoft.com/vscode/devcontainers/javascript-node:16` (or `16-bullseye`, `16-buster` to pin to an OS version)
36+
- `mcr.microsoft.com/vscode/devcontainers/javascript-node:14` (or `14-bullseye`, `14-buster` to pin to an OS version)
37+
38+
You can decide how often you want updates by referencing a [semantic version](https://semver.org/) of each image. For example:
39+
40+
- `mcr.microsoft.com/vscode/devcontainers/typescript-node:0-16` (or `0-16-bullseye`, `0-16-buster`)
41+
- `mcr.microsoft.com/vscode/devcontainers/typescript-node:0.204-16` (or `0.204-16-bullseye`, `0.204-16-buster`)
42+
- `mcr.microsoft.com/vscode/devcontainers/typescript-node:0.204.0-16` (or `0.204.0-16-bullseye`, `0.204.0-16-buster`)
43+
44+
However, we only do security patching on the latest [non-breaking, in support](https://github.com/microsoft/vscode-dev-containers/issues/532) versions of images (e.g. `0-16`). You may want to run `apt-get update && apt-get upgrade` in your Dockerfile if you lock to a more specific version to at least pick up OS security updates.
45+
46+
See [history](history) for information on the contents of each version and [here for a complete list of available tags](https://mcr.microsoft.com/v2/vscode/devcontainers/typescript-node/tags/list).
47+
48+
Alternatively, you can use the contents of `base.Dockerfile` to fully customize your container's contents or to build it for a container host architecture not supported by the image.
49+
50+
Beyond Node.js and `git`, this image / `Dockerfile` includes `eslint`, `zsh`, [Oh My Zsh!](https://ohmyz.sh/), a non-root `vscode` user with `sudo` access, and a set of common dependencies for development. [Node Version Manager](https://github.com/nvm-sh/nvm) (`nvm`) is also included in case you need to use a different version of Node.js than the one included in the image.
51+
52+
### Adding the definition to a project or codespace
53+
54+
1. If this is your first time using a development container, please see getting started information on [setting up](https://aka.ms/vscode-remote/containers/getting-started) Remote-Containers or [creating a codespace](https://aka.ms/ghcs-open-codespace) using GitHub Codespaces.
55+
56+
2. To use the pre-built image:
57+
1. Start VS Code and open your project folder or connect to a codespace.
58+
2. Press <kbd>F1</kbd> select and **Add Development Container Configuration Files...** command for **Remote-Containers** or **Codespaces**.
59+
3. Select this definition. You may also need to select **Show All Definitions...** for it to appear.
60+
61+
3. To build a custom version of the image instead:
62+
1. Clone this repository locally.
63+
2. Start VS Code and open your project folder or connect to a codespace.
64+
3. Use your local operating system's file explorer to drag-and-drop the locally cloned copy of the `.devcontainer` folder for this definition into the VS Code file explorer for your opened project or codespace.
65+
4. Update `.devcontainer/devcontainer.json` to reference `"dockerfile": "base.Dockerfile"`.
66+
67+
4. After following step 2 or 3, the contents of the `.devcontainer` folder in your project can be adapted to meet your needs.
68+
69+
5. Finally, press <kbd>F1</kbd> and run **Remote-Containers: Reopen Folder in Container** or **Codespaces: Rebuild Container** to start using the definition.
70+
71+
## Testing the definition
72+
73+
This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps:
74+
75+
1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
76+
2. Clone this repository.
77+
3. Start VS Code, press <kbd>F1</kbd>, and select **Remote-Containers: Open Folder in Container...**
78+
4. Select the `containers/javascript-node` folder.
79+
5. After the folder has opened in the container, press <kbd>F5</kbd> to start the project. This will automatically run `npm install` before starting it.
80+
6. Once the project is running, press <kbd>F1</kbd> and select **Remote-Containers: Forward Port from Container...**
81+
7. Select port 3000 and click the "Open Browser" button in the notification that appears.
82+
8. You should see "Hello remote world!" after the page loads.
83+
9. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing.
84+
85+
## License
86+
87+
Copyright (c) Microsoft Corporation. All rights reserved.
88+
89+
Licensed under the MIT License. See [LICENSE](https://github.com/microsoft/vscode-dev-containers/blob/main/LICENSE).

0 commit comments

Comments
 (0)