Skip to content

Commit 7ecd87c

Browse files
MohsinHashmi-DataInnmohsin-wiserclaude
authored
fix: standardize to vscode user across all configurations (#438)
* fix: standardize to vscode user across all configurations - Update Dockerfile to set default USER to vscode before CMD This ensures container starts as vscode user even without devcontainer.json - Update Coder template.tf to use /home/vscode/ paths instead of /root/ - Environment variables: HISTFILE, GIT_CONFIG_GLOBAL - All volume mounts: .claude, .gemini, .m2, .npm, .vscode-server, etc. - Remove duplicate .claude.json file mount (now part of .claude/ directory) This aligns all deployment methods (local Docker, devcontainer, Coder) to consistently use the vscode non-root user for security and consistency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: use bash shell for maven settings copy on windows Force bash shell instead of PowerShell for the Maven settings copy step to ensure cross-platform compatibility. PowerShell doesn't support `mkdir -p` the same way as Unix shells. Fixes failing Windows matrix test in CI. 🤖 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 d2f125f commit 7ecd87c

3 files changed

Lines changed: 19 additions & 20 deletions

File tree

.coder/template.tf

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

297297
# Workspace directory (persistent Git repository)
@@ -303,64 +303,58 @@ resource "docker_container" "workspace" {
303303
# Cache volumes (rebuilds are OK)
304304
volumes {
305305
volume_name = docker_volume.vscode_extensions.name
306-
container_path = "/root/.vscode-server/extensions"
306+
container_path = "/home/vscode/.vscode-server/extensions"
307307
}
308308

309309
volumes {
310310
volume_name = docker_volume.maven_cache.name
311-
container_path = "/root/.m2"
311+
container_path = "/home/vscode/.m2"
312312
}
313313

314314
volumes {
315315
volume_name = docker_volume.npm_cache.name
316-
container_path = "/root/.npm"
316+
container_path = "/home/vscode/.npm"
317317
}
318318

319319
# User credentials (persistent across host)
320320
volumes {
321321
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/claude/.claude"
322-
container_path = "/root/.claude"
323-
}
324-
325-
# Claude configuration file (must be pre-created as a file on host)
326-
volumes {
327-
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/claude/.claude.json"
328-
container_path = "/root/.claude.json"
322+
container_path = "/home/vscode/.claude"
329323
}
330324

331325
volumes {
332326
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/gemini/.gemini"
333-
container_path = "/root/.gemini"
327+
container_path = "/home/vscode/.gemini"
334328
}
335329

336330
volumes {
337331
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/.config/gh"
338-
container_path = "/root/.config/gh"
332+
container_path = "/home/vscode/.config/gh"
339333
}
340334

341335
volumes {
342336
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/bash-history/.bash_history"
343-
container_path = "/root/.bash_history_dir"
337+
container_path = "/home/vscode/.bash_history_dir"
344338
}
345339

346340
volumes {
347341
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/gitconfig/.gitconfig"
348-
container_path = "/root/.gitconfig_dir"
342+
container_path = "/home/vscode/.gitconfig_dir"
349343
}
350344

351345
volumes {
352346
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/ssh/.ssh"
353-
container_path = "/root/.ssh"
347+
container_path = "/home/vscode/.ssh"
354348
}
355349

356350
volumes {
357351
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/docker/.docker"
358-
container_path = "/root/.docker"
352+
container_path = "/home/vscode/.docker"
359353
}
360354

361355
volumes {
362356
host_path = "/home/coder/.coder-mount/${data.coder_workspace_owner.me.name}/kube/.kube"
363-
container_path = "/root/.kube"
357+
container_path = "/home/vscode/.kube"
364358
}
365359

366360
# Docker socket for Docker-in-Docker

.devcontainer/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,13 @@ USER vscode
156156
RUN mkdir -p ~/.m2/repository ~/.m2/wrapper/dists ~/.npm ~/.cache/ms-playwright \
157157
&& chmod -R 755 ~/.m2 ~/.npm ~/.cache
158158

159-
# Reset working directory
159+
# Reset working directory and user
160160
USER root
161161
WORKDIR /workspaces
162162

163+
# Set default user to vscode (non-root)
164+
# This ensures container starts as vscode user even without devcontainer.json
165+
USER vscode
166+
163167
# Default command
164168
CMD ["sleep", "infinity"]

.github/workflows/matrix-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
cache: maven
5353

5454
- name: Copy Maven settings
55+
shell: bash
5556
run: |
5657
mkdir -p ~/.m2
5758
cp .devcontainer/maven-settings.xml ~/.m2/settings.xml

0 commit comments

Comments
 (0)