|
2 | 2 | { |
3 | 3 | "name": "QuickSite Node Template", |
4 | 4 | "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 | + |
5 | 14 | "customizations": { |
6 | 15 | "vscode": { |
7 | 16 | "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 | + ] |
10 | 25 | } |
11 | 26 | }, |
12 | 27 |
|
13 | | - // 1. Install dependencies immediately after the container is built. |
| 28 | + // Install dependencies *once* when container is created |
14 | 29 | "postCreateCommand": "npm ci", |
15 | 30 |
|
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 |
19 | 32 | "postAttachCommand": "npm start", |
20 | 33 |
|
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 | + |
22 | 37 | "forwardPorts": [4920], |
23 | 38 |
|
24 | | - // 4. Optional: Instruct VS Code to open the browser automatically |
25 | 39 | "portsAttributes": { |
26 | 40 | "4920": { |
27 | 41 | "label": "Dev Server", |
|
31 | 45 | "revealAtStart": true, |
32 | 46 | "closeAction": "notify" |
33 | 47 | } |
34 | | - } |
| 48 | + }, |
| 49 | + |
| 50 | + // Persist npm cache to speed up rebuilds |
| 51 | + "mounts": [ |
| 52 | + "source=node_modules_cache,target=/tmp/npmcache,type=cache" |
| 53 | + ] |
35 | 54 | } |
0 commit comments