Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,66 +1,58 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu

RUN apt-get update && apt-get install -y curl git alsa-utils sox \
RUN apt-get update && apt-get install -y curl git alsa-utils sox build-essential pkg-config libssl-dev libasound2-dev \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs

# Install pnpm
RUN npm install -g pnpm

# Setup pnpm for vscode user and install global packages
USER vscode
ENV SHELL=/bin/bash
ENV PNPM_HOME="/home/vscode/.local/share/pnpm"
ENV PATH="${PNPM_HOME}:${PATH}"
ENV RUSTUP_HOME="/home/vscode/.rustup"
ENV CARGO_HOME="/home/vscode/.cargo"
ENV PATH="${CARGO_HOME}/bin:${PNPM_HOME}:${PATH}"
Comment on lines +12 to +14

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Global CARGO_HOME/RUSTUP_HOME point into /home/vscode

Setting these globally means subsequent root RUN steps may write root-owned files under /home/vscode. This interacts with the cargo install below.

Either (a) run all cargo/rustup operations as vscode, or (b) override/unset these ENV vars before running root-only steps. See fix on Lines 29-30.


🏁 Script executed:

#!/bin/bash
# Inspect the Dockerfile content around the env settings and user context
sed -n '1,60p' .devcontainer/Dockerfile

# Check for any USER directives (to see if subsequent steps switch to non-root)
grep -n '^USER ' .devcontainer/Dockerfile || true

# Locate any cargo install commands (to see if they're run as root)
grep -n 'cargo install' .devcontainer/Dockerfile || true

Length of output: 2778


Run the cargo install step under USER vscode or clear CARGO_HOME/RUSTUP_HOME before switching to root
Global CARGO_HOME/RUSTUP_HOME persist into the root context, so the RUN cargo install similarity-ts on .devcontainer/Dockerfile (around lines 25–30) will write root-owned files into /home/vscode/.cargo. Either move that RUN back under USER vscode or unset/override those ENV vars immediately before the root-level cargo install.

🤖 Prompt for AI Agents
In .devcontainer/Dockerfile around lines 12–14 and the subsequent cargo install
at ~25–30, CARGO_HOME/RUSTUP_HOME are set to /home/vscode and persist into the
root context, causing root-owned files when running RUN cargo install
similarity-ts; to fix, either move the RUN cargo install so it executes while
USER vscode is active (i.e., run it before switching to root or explicitly run
that layer under USER vscode), or immediately before the root-level cargo
install unset or override CARGO_HOME and RUSTUP_HOME (or point them to root's
paths) so the install writes to root-owned directories. Ensure the chosen change
prevents writing into /home/vscode as root.

RUN bash -c "pnpm setup" \
&& echo "export PNPM_HOME=\"/home/vscode/.local/share/pnpm\"" >> /home/vscode/.bashrc \
&& echo "export PATH=\"\$PNPM_HOME:\$PATH\"" >> /home/vscode/.bashrc \
&& echo "export RUSTUP_HOME=\"/home/vscode/.rustup\"" >> /home/vscode/.bashrc \
&& echo "export CARGO_HOME=\"/home/vscode/.cargo\"" >> /home/vscode/.bashrc \
&& echo "export PATH=\"\$CARGO_HOME/bin:\$PATH\"" >> /home/vscode/.bashrc \
&& curl -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain stable \
&& bash -lc "rustup component add rustfmt clippy" \
&& bash -c "source /home/vscode/.bashrc && pnpm add -g supabase"

# Switch back to root for remaining operations
USER root

# Install global packages
RUN npm install -g typescript eslint @anthropic-ai/claude-code @openai/codex vercel

# Install Cursor Agent
RUN cargo install similarity-ts

Comment on lines +29 to +30

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix root-owned Cargo install into /home/vscode

cargo install currently runs as root while CARGO_HOME=/home/vscode/.cargo, creating root-owned files the vscode user cannot manage.

-RUN cargo install similarity-ts
+USER vscode
+# Install as non-root to keep ~/.cargo owned by vscode and lock deps for reproducibility
+RUN bash -lc 'cargo install --locked similarity-ts'
+USER root
🤖 Prompt for AI Agents
In .devcontainer/Dockerfile around lines 29-30, cargo install is being executed
as root while CARGO_HOME is /home/vscode/.cargo, producing root-owned files; run
the install as the vscode user (or set --root to /home/vscode/.cargo) so files
are owned by vscode. Modify the Dockerfile to either set ENV
CARGO_HOME=/home/vscode/.cargo && USER vscode before the RUN cargo install step
(then switch back to root if needed), or invoke cargo install with --root
/home/vscode/.cargo and ensure ownership is chowned to vscode afterward.

USER vscode
RUN curl https://cursor.com/install -fsS | bash \
&& echo 'export PATH="$HOME/.local/bin:$PATH"' >> /home/vscode/.bashrc
USER root

# Git aliases for common commands
RUN echo "alias gco='git checkout'" >> /home/vscode/.bashrc \
&& echo "alias gst='git status'" >> /home/vscode/.bashrc \
&& echo "alias gad='git add'" >> /home/vscode/.bashrc \
&& echo "alias gcm='git commit -m'" >> /home/vscode/.bashrc \
&& echo "alias gps='git push'" >> /home/vscode/.bashrc \
&& echo "alias gpl='git pull'" >> /home/vscode/.bashrc

# Setup directories
RUN mkdir -p /home/vscode/.claude /home/vscode/.cursor /home/vscode/.openai /home/vscode/.codex \
&& chown -R vscode:vscode /home/vscode/.claude /home/vscode/.cursor /home/vscode/.openai /home/vscode/.codex

# Copy default Claude settings
COPY --chown=vscode:vscode .devcontainer/claude-settings.json /home/vscode/.claude/settings.json

# Copy Codex configuration
COPY --chown=vscode:vscode .devcontainer/codex-config.json /home/vscode/.codex/config.json

# Copy Claude commands
COPY --chown=vscode:vscode .claude/commands /home/vscode/.claude/commands

# Copy Claude agents
COPY --chown=vscode:vscode .claude/agents /home/vscode/.claude/agents

# Change default shell to bash
RUN chsh -s /bin/bash vscode

# Setup .bash_profile
RUN echo 'source ~/.bashrc' >> /home/vscode/.bash_profile \
&& chown vscode:vscode /home/vscode/.bash_profile

# Husky用の設定
COPY package.json package-lock.json /tmp/
COPY .husky /tmp/.husky/
RUN cd /tmp && npm ci && npm run prepare || true