Skip to content

Commit c5bb390

Browse files
authored
fix: Update devcontainer.json for speed
1 parent 33e5d02 commit c5bb390

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

.devcontainer/devcontainer.json

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,40 @@
22
{
33
"name": "QuickSite Node Template",
44
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
5+
6+
// Use the same user defined in the base image (recommended)
7+
"remoteUser": "node",
8+
9+
// Optional but very useful for CLI work
10+
"features": {
11+
"ghcr.io/devcontainers/features/git:1": {}
12+
},
13+
514
"customizations": {
615
"vscode": {
716
"settings": {
8-
"npm.packageManager": "npm"
9-
}
17+
"npm.packageManager": "npm",
18+
"editor.formatOnSave": true
19+
},
20+
"extensions": [
21+
"esbenp.prettier-vscode",
22+
"dbaeumer.vscode-eslint",
23+
"eamodio.gitlens"
24+
]
1025
}
1126
},
1227

13-
// 1. Install dependencies immediately after the container is built.
28+
// Install dependencies *once* when container is created
1429
"postCreateCommand": "npm ci",
1530

16-
// 2. Run the build and start the server after the user attaches.
17-
// We use 'npm start' because your package.json already defines it as:
18-
// "start": "npm run build && node serve.js"
31+
// Keep your auto-start behavior, but optional
1932
"postAttachCommand": "npm start",
2033

21-
// 3. Optional: Set VS Code to automatically forward the port 4920
34+
// Automatically reinstall on source updates (faster than postCreateCommand rerun)
35+
"updateContentCommand": "npm ci",
36+
2237
"forwardPorts": [4920],
2338

24-
// 4. Optional: Instruct VS Code to open the browser automatically
2539
"portsAttributes": {
2640
"4920": {
2741
"label": "Dev Server",
@@ -31,5 +45,10 @@
3145
"revealAtStart": true,
3246
"closeAction": "notify"
3347
}
34-
}
48+
},
49+
50+
// Persist npm cache to speed up rebuilds
51+
"mounts": [
52+
"source=node_modules_cache,target=/tmp/npmcache,type=cache"
53+
]
3554
}

0 commit comments

Comments
 (0)