From 55ba79a8ef68418d5e3bb4c4b2913be8803fc4c6 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Tue, 15 Apr 2025 11:02:47 -0400 Subject: [PATCH 1/3] 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. --- src/node/devcontainer-feature.json | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/node/devcontainer-feature.json b/src/node/devcontainer-feature.json index 28f628d..53c7448 100644 --- a/src/node/devcontainer-feature.json +++ b/src/node/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Node.js", "id": "node", - "version": "1.0.0", + "version": "1.1.0", "description": "Install Node.js from Nodesource's DEB repository.", "options": { "version": { @@ -17,7 +17,23 @@ "description": "Select or enter a Node.js version." } }, + "containerEnv": { + "NPM_CONFIG_CACHE": "/usr/local/npm" + }, "installsAfter": [ "ghcr.io/devcontainers/features/common-utils" - ] + ], + "mounts": [ + { + "source": "npm-cache", + "target": "/usr/local/npm", + "type": "volume" + }, + { + "source": "node_modules-cache", + "target": "${containerWorkspaceFolder}/node_modules", + "type": "volume" + } + ], + "postCreateCommand": "sudo chown -R ${USER}:${USER} /usr/local/npm ${containerWorkspaceFolder}/node_modules" } From 0bf18006cb59627180f0f1e21d8aab78fc2cb256 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Tue, 15 Apr 2025 12:05:21 -0400 Subject: [PATCH 2/3] Test known good images only --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index beb3d81..ee40aa9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,8 +18,7 @@ jobs: - postgresql-client - shellcheck baseImage: - - debian:latest - - ubuntu:latest + - mcr.microsoft.com/devcontainers/base:debian - mcr.microsoft.com/devcontainers/base:ubuntu continue-on-error: true steps: From afe50b11a5756e2c9470b91d92c83969f41d6d5e Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Tue, 15 Apr 2025 12:08:24 -0400 Subject: [PATCH 3/3] Use known good image in scenario, too --- test/node/scenarios.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/node/scenarios.json b/test/node/scenarios.json index 469f26f..7730fb1 100644 --- a/test/node/scenarios.json +++ b/test/node/scenarios.json @@ -1,6 +1,6 @@ { "node-20": { - "image": "debian:latest", + "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { "node": { "version": "20"