Skip to content

Commit 55ba79a

Browse files
Configure environment variables and volumes
For any app using npm packages that use this feature, we can configure the installation location (`/usr/local/npm`) and configure mounted volumes for that path and for the project's local `node_modules` folder. This should speed up repeat builds and reduce I/O to the host machine while also streamlining cross-project configuration.
1 parent ea345b5 commit 55ba79a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/node/devcontainer-feature.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Node.js",
33
"id": "node",
4-
"version": "1.0.0",
4+
"version": "1.1.0",
55
"description": "Install Node.js from Nodesource's DEB repository.",
66
"options": {
77
"version": {
@@ -17,7 +17,23 @@
1717
"description": "Select or enter a Node.js version."
1818
}
1919
},
20+
"containerEnv": {
21+
"NPM_CONFIG_CACHE": "/usr/local/npm"
22+
},
2023
"installsAfter": [
2124
"ghcr.io/devcontainers/features/common-utils"
22-
]
25+
],
26+
"mounts": [
27+
{
28+
"source": "npm-cache",
29+
"target": "/usr/local/npm",
30+
"type": "volume"
31+
},
32+
{
33+
"source": "node_modules-cache",
34+
"target": "${containerWorkspaceFolder}/node_modules",
35+
"type": "volume"
36+
}
37+
],
38+
"postCreateCommand": "sudo chown -R ${USER}:${USER} /usr/local/npm ${containerWorkspaceFolder}/node_modules"
2339
}

0 commit comments

Comments
 (0)