@@ -11,13 +11,12 @@ RUN apk add --no-cache \
1111 bash \
1212 && rm -rf /var/cache/apk/*
1313
14- # Install npm packages globally
15- RUN npm install -g @anthropic-ai/claude-code@2.0.21 \
16- && npm cache clean --force
14+ # Create non-root user first
15+ RUN adduser -D -s /bin/bash devusr \
16+ && addgroup devusr wheel \
17+ && echo 'devusr ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
1718
18- # Install uv Python package manager
19- RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
20- && rm -rf /tmp/*
19+ # uv will be installed later as devusr
2120
2221# Install Go - multi-platform support for amd64 and arm64
2322ARG TARGETPLATFORM
@@ -31,29 +30,29 @@ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
3130 && rm "go1.24.7.linux-${GO_ARCH}.tar.gz" \
3231 && ln -sf /usr/local/go/bin/go /usr/bin/go
3332
34- # Install Rust - minimal profile to save space
33+ # Install Rust as devusr with minimal profile to save space
34+ USER devusr
3535ENV RUSTUP_PROFILE=minimal
36+ ENV HOME=/home/devusr
3637RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal \
37- && chmod +x /root/.cargo/env
38-
39- # Create non-root user
40- RUN adduser -D -s /bin/bash devusr \
41- && addgroup devusr wheel \
42- && echo 'devusr ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
43-
44- # Copy tool installations to user and set ownership
45- RUN cp -r /root/.cargo /home/devusr/ \
46- && cp -r /root/.rustup /home/devusr/ \
47- && cp -r /root/.local /home/devusr/ \
48- && chown -R devusr:devusr /home/devusr/.cargo /home/devusr/.rustup /home/devusr/.local \
38+ && chmod +x /home/devusr/.cargo/env \
4939 # Remove unnecessary Rust components to save space (~180M savings)
5040 && rm -rf /home/devusr/.rustup/toolchains/stable-*/share/doc \
5141 && rm -rf /home/devusr/.rustup/toolchains/stable-*/share/man \
5242 && rm -rf /home/devusr/.rustup/toolchains/stable-*/lib/rustlib/*/bin \
5343 && rm -f /home/devusr/.rustup/toolchains/stable-*/lib/rustlib/*/lib/libtest-*.rlib
5444
45+ # Install Claude Code and uv as devusr
46+ RUN npm config set prefix '~/.npm-global' \
47+ && npm install -g @anthropic-ai/claude-code@2.0.21 \
48+ && curl -LsSf https://astral.sh/uv/install.sh | sh \
49+ && rm -rf /tmp/*
50+
51+ # Switch back to root for remaining installations
52+ USER root
53+
5554# Set PATH for all tools (using literal paths since HOME expands at runtime)
56- ENV PATH="/home/devusr/.cargo/bin:/usr/local/go/bin:/home/devusr/.local/bin:$PATH"
55+ ENV PATH="/home/devusr/.cargo/bin:/usr/local/go/bin:/home/devusr/.local/bin:/home/devusr/.npm-global/bin:/usr/local/bin: $PATH"
5756
5857# Set working directory
5958WORKDIR /devbox
0 commit comments