Created
June 23, 2025 20:55
-
-
Save paulschick/71afa4e780b92d9ee2a20fdc5a1aa314 to your computer and use it in GitHub Desktop.
Dockerfile for running Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:18-slim | |
ARG CLAUDE_VERSION=latest | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
ca-certificates \ | |
curl \ | |
gosu && \ | |
apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
# Create non-root user with specific UID/GID for better compatibility | |
RUN groupadd -g 1001 codeuser && \ | |
useradd -u 1001 -g 1001 -m -s /bin/bash codeuser | |
# Set working directory and fix permissions | |
WORKDIR /app | |
RUN chown -R codeuser:codeuser /app | |
USER codeuser | |
# Install Claude CLI as non-root user | |
RUN npm config set prefix '/home/codeuser/.npm-global' && \ | |
npm install -g @anthropic-ai/claude-code@${CLAUDE_VERSION} | |
# Add npm global bin to PATH | |
ENV PATH="/home/codeuser/.npm-global/bin:$PATH" | |
# Health check to ensure claude CLI is available | |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ | |
CMD claude --version || exit 1 | |
# Switch back to root for entrypoint (needed for user switching via gosu) | |
USER root | |
CMD ["bash"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment