Skip to content

Commit 11490cd

Browse files
committed
Fix devcontainer configuration with ubuntu user for proper permissions
- Switch from custom vscode user to existing ubuntu user (UID 1000) - Configure Oh My Zsh and Claude Code for ubuntu user - Update docker-compose volume mounts to use ubuntu paths - Add proper shell history and PATH configuration - This should resolve shell history permission issues with Docker volumes
1 parent f3ecb99 commit 11490cd

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

.devcontainer/Dockerfile

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ RUN apt-get update && apt-get install -y \
1010
&& rm -rf /var/lib/apt/lists/*
1111

1212
# Install Claude Code
13-
RUN curl -fsSL https://claude.ai/install.sh | bash
13+
RUN curl -fsSL https://claude.ai/install.sh | bash && \
14+
# Ensure claude is in PATH
15+
if [ -f ~/.local/bin/claude ]; then ln -sf ~/.local/bin/claude /usr/local/bin/claude; fi && \
16+
if [ -f ~/bin/claude ]; then ln -sf ~/bin/claude /usr/local/bin/claude; fi && \
17+
# Add common binary paths to PATH
18+
echo 'export PATH="$HOME/.local/bin:$HOME/bin:$PATH"' >> /root/.bashrc && \
19+
echo 'export PATH="$HOME/.local/bin:$HOME/bin:$PATH"' >> /root/.zshrc
1420

1521
# Install AWS CLI
1622
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
@@ -48,6 +54,7 @@ RUN mkdir -p /root/.shell_history && \
4854
echo 'shopt -s histappend' >> /root/.bashrc && \
4955
echo 'export PROMPT_COMMAND="history -a; history -c; history -r"' >> /root/.bashrc && \
5056
# Zsh configuration
57+
echo 'export PATH="$HOME/.local/bin:$HOME/bin:$PATH"' >> /root/.zshrc && \
5158
echo 'export HISTFILE=/root/.shell_history/.zsh_history' >> /root/.zshrc && \
5259
echo 'export HISTSIZE=10000' >> /root/.zshrc && \
5360
echo 'export SAVEHIST=10000' >> /root/.zshrc && \
@@ -56,4 +63,33 @@ RUN mkdir -p /root/.shell_history && \
5663
echo 'setopt HIST_SAVE_NO_DUPS' >> /root/.zshrc && \
5764
echo 'setopt SHARE_HISTORY' >> /root/.zshrc
5865

59-
# Maven images typically run as root by default, which is fine for devcontainers
66+
# Configure existing ubuntu user for Claude Code compatibility (use existing UID 1000)
67+
RUN usermod --shell /bin/zsh ubuntu && \
68+
# Give ubuntu sudo access
69+
echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
70+
71+
# Switch to ubuntu user and set up user-specific configurations
72+
USER ubuntu
73+
74+
# Install Oh My Zsh for ubuntu user and configure shell
75+
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended && \
76+
mkdir -p /home/ubuntu/.shell_history /home/ubuntu/.config && \
77+
# Install Claude Code for ubuntu user
78+
curl -fsSL https://claude.ai/install.sh | bash && \
79+
# Add PATH configuration
80+
echo 'export PATH="$HOME/.local/bin:$HOME/bin:$PATH"' >> /home/ubuntu/.zshrc && \
81+
# Add shell history configuration
82+
echo 'export HISTFILE=/home/ubuntu/.shell_history/.zsh_history' >> /home/ubuntu/.zshrc && \
83+
echo 'export HISTSIZE=10000' >> /home/ubuntu/.zshrc && \
84+
echo 'export SAVEHIST=10000' >> /home/ubuntu/.zshrc && \
85+
echo 'setopt HIST_IGNORE_DUPS' >> /home/ubuntu/.zshrc && \
86+
echo 'setopt HIST_IGNORE_ALL_DUPS' >> /home/ubuntu/.zshrc && \
87+
echo 'setopt HIST_SAVE_NO_DUPS' >> /home/ubuntu/.zshrc && \
88+
echo 'setopt SHARE_HISTORY' >> /home/ubuntu/.zshrc
89+
90+
# Ensure proper ownership of directories that will be mounted as volumes
91+
USER root
92+
RUN chown -R ubuntu:ubuntu /home/ubuntu/.shell_history /home/ubuntu/.config
93+
94+
# Switch back to ubuntu user
95+
USER ubuntu

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
}
1717
},
1818
"postCreateCommand": "echo 'Java development environment with Claude Code ready'",
19-
"remoteUser": "root"
19+
"remoteUser": "ubuntu"
2020
}

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ services:
77
dockerfile: Dockerfile
88
volumes:
99
- .:/workspace:cached
10-
- devcontainer-shell-history:/root/.shell_history
11-
- claude-auth:/root/.config/claude
12-
- github-cli-auth:/root/.config/gh
10+
- devcontainer-shell-history:/home/ubuntu/.shell_history
11+
- claude-auth:/home/ubuntu/.config/claude
12+
- github-cli-auth:/home/ubuntu/.config/gh
1313
working_dir: /workspace
1414
command: sleep infinity
1515
depends_on:

0 commit comments

Comments
 (0)