Skip to content

Commit c1756cf

Browse files
MohsinHashmi-DataInnmohsin-wiserclaude
authored
fix: clean node_modules before npm ci in post-create script (#422)
* fix: remove unnecessary coder binary move step in deployment workflow * fix: clean node_modules before npm ci in post-create script Ensures npm ci succeeds by removing existing node_modules before installation. This prevents fallback to npm install and ensures reproducible, faster installations using package-lock.json. Changes: - Add rm -rf node_modules before root npm ci - Add rm -rf node_modules before frontend npm ci 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: update coder mount paths to use isolated subdirectories and /root - Update all host paths to use isolated subdirectories per tool (e.g., claude/.claude, gemini/.gemini, ssh/.ssh) - Change all container paths from /home/vscode/ to /root/ - Update environment variables (HISTFILE, GIT_CONFIG_GLOBAL) to /root/ - Add direct mount for claude.json instead of symlink - Remove symlink creation from post-start.sh This ensures proper isolation and consistency for Coder workspaces. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: use .claude.json (with dot) for host path consistency Match exact filename on both host and container paths. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Mohsin Hashmi <mhashmi@wiser.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 9bbb6be commit c1756cf

3 files changed

Lines changed: 22 additions & 24 deletions

File tree

.coder/template.tf

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ resource "docker_container" "workspace" {
294294
"MAVEN_OPTS=-Xmx2g -XX:+UseG1GC -XX:+UseStringDeduplication",
295295
"JAVA_TOOL_OPTIONS=-XX:+UseContainerSupport -XX:MaxRAMPercentage=50.0",
296296
"NODE_OPTIONS=--max-old-space-size=2048",
297-
"HISTFILE=/home/vscode/.bash_history_dir/bash_history",
298-
"GIT_CONFIG_GLOBAL=/home/vscode/.gitconfig_dir/gitconfig"
297+
"HISTFILE=/root/.bash_history_dir/bash_history",
298+
"GIT_CONFIG_GLOBAL=/root/.gitconfig_dir/gitconfig"
299299
]
300300

301301
# Workspace directory (persistent Git repository)
@@ -322,49 +322,49 @@ resource "docker_container" "workspace" {
322322

323323
# User credentials (persistent across host)
324324
volumes {
325-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/claude"
325+
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/claude/.claude"
326326
container_path = "/root/.claude"
327327
}
328328

329329
# Claude configuration file (must be pre-created as a file on host)
330330
volumes {
331-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/claude/claude.json"
331+
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/claude/.claude.json"
332332
container_path = "/root/.claude.json"
333333
}
334334

335335
volumes {
336-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/gemini"
337-
container_path = "/home/vscode/.gemini"
336+
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/gemini/.gemini"
337+
container_path = "/root/.gemini"
338338
}
339339

340340
volumes {
341-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/gh"
342-
container_path = "/home/vscode/.config/gh"
341+
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/.config/gh"
342+
container_path = "/root/.config/gh"
343343
}
344344

345345
volumes {
346-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/bash-history"
347-
container_path = "/home/vscode/.bash_history_dir"
346+
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/bash-history/.bash_history"
347+
container_path = "/root/.bash_history_dir"
348348
}
349349

350350
volumes {
351-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/gitconfig"
352-
container_path = "/home/vscode/.gitconfig_dir"
351+
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/gitconfig/.gitconfig"
352+
container_path = "/root/.gitconfig_dir"
353353
}
354354

355355
volumes {
356-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/ssh"
357-
container_path = "/home/vscode/.ssh"
356+
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/ssh/.ssh"
357+
container_path = "/root/.ssh"
358358
}
359359

360360
volumes {
361-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/docker"
362-
container_path = "/home/vscode/.docker"
361+
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/docker/.docker"
362+
container_path = "/root/.docker"
363363
}
364364

365365
volumes {
366-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/kube"
367-
container_path = "/home/vscode/.kube"
366+
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/kube/.kube"
367+
container_path = "/root/.kube"
368368
}
369369

370370
# Docker socket for Docker-in-Docker

.devcontainer/post-create.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,17 @@ ensure_dir "$TARGET_HOME/.vscode-server/extensions"
8181
echo "📦 Installing root npm dependencies..."
8282
# Try npm ci first (faster, uses lock file exactly)
8383
# Fall back to npm install if lock file is out of sync
84+
# Clean node_modules first to ensure npm ci succeeds
85+
rm -rf node_modules
8486
if ! npm ci --prefer-offline 2>/dev/null; then
8587
echo " ⚠️ npm ci failed, falling back to npm install..."
8688
npm install
8789
fi
8890

8991
echo "📦 Installing frontend dependencies..."
9092
cd apps/frontend
93+
# Clean node_modules first to ensure npm ci succeeds
94+
rm -rf node_modules
9195
if ! npm ci --legacy-peer-deps --prefer-offline 2>/dev/null; then
9296
echo " ⚠️ npm ci failed, falling back to npm install..."
9397
npm install --legacy-peer-deps

.devcontainer/post-start.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ if [ $ELAPSED -lt $TIMEOUT ]; then
4747
echo "✅ Redis is ready"
4848
fi
4949

50-
# Symlink Claude settings from persistent mount
51-
if [ -f /home/vscode/.claude/claude.json ] && [ ! -L /home/vscode/.claude.json ]; then
52-
ln -sf /home/vscode/.claude/claude.json /home/vscode/.claude.json
53-
echo "✅ Claude settings symlinked"
54-
fi
55-
5650
# Update CLI tools to latest versions (runs in background to not block startup)
5751
echo "🔧 Updating CLI tools in background..."
5852
if [ -f /usr/local/bin/install-cli-tools ]; then

0 commit comments

Comments
 (0)