Created
March 28, 2025 16:41
-
-
Save AdrianVollmer/9255ea465feb1dd5cdfc9d65cd9447a9 to your computer and use it in GitHub Desktop.
podman-claude-code.sh
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
#!/bin/bash | |
# Podman runner for claude-code. Hint: Create alias for claude-code: | |
# alias claude="podman-claude-code.sh claude" | |
# Configuration | |
NODE_IMAGE="docker.io/library/node:slim" | |
DERIVED_IMAGE="localhost/claude-code:latest" | |
CONTAINER_NAME="podman-claude-code-runner" | |
NODE_HOME_ROOT="${HOME}/.local/share/podman-claude-code/root" | |
# Create necessary directories for persistence | |
mkdir -p "${NODE_HOME_ROOT}" | |
# Build the derived image with git and python if it doesn't exist | |
if ! podman image exists "${DERIVED_IMAGE}"; then | |
echo "Building derived image with git and python..." | |
podman build -t "${DERIVED_IMAGE}" - <<EOF | |
FROM ${NODE_IMAGE} | |
RUN apt-get update && apt-get install -y git python3 python-is-python3 python3-pip && apt-get clean | |
RUN mkdir -p /root/.npm-global && \ | |
npm config set prefix '/root/.npm-global' && \ | |
npm install -g @anthropic-ai/claude-code | |
ENV PATH=/root/.npm-global/bin:$PATH | |
EOF | |
fi | |
# Run the Node.js command in a Podman container | |
podman run --rm \ | |
--name "${CONTAINER_NAME}-$(date +%s)" \ | |
-e 'ANTHROPIC_*' \ | |
-e 'CLAUDE_*' \ | |
-v "$(pwd):/app" \ | |
-v "${NODE_HOME_ROOT}:/root:z" \ | |
-w /app \ | |
-it \ | |
"${DERIVED_IMAGE}" \ | |
sh -c "$*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment