Skip to content

Instantly share code, notes, and snippets.

@nielsmaerten
Created May 4, 2020 16:32
Show Gist options
  • Save nielsmaerten/72040f5e36f329bd82ea1da67d8dfd14 to your computer and use it in GitHub Desktop.
Save nielsmaerten/72040f5e36f329bd82ea1da67d8dfd14 to your computer and use it in GitHub Desktop.
Devcontainer for Node in VS Code

Node Devcontainer for VSCode

  • This container definition has an anonymous volume that will mount to /workspace/node_modules.
    This drastically improves IO performance :)
  • yarn install && touch node_modules/.gitkeep runs post container creation
    Commit the .gitkeep to source control, but leave the rest of node_modules ignored.
    This is because the folder needs to exist for it to be mountable
// 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.112.0/containers/typescript-node-12
{
"name": "Node.js 12 & TypeScript",
"dockerFile": "Dockerfile",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint",
"ms-vscode.vscode-typescript-tslint-plugin"
],
"mounts": [
"target=/workspace/node_modules,type=volume,consistency=cached",
],
// 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": "yarn install && touch node_modules/.gitkeep",
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "node"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment