Skip to content

Commit 28a302c

Browse files
committed
feat: Add Claude Code and GitHub CLI to devcontainer
- Add install script for Claude Code CLI - Add GitHub CLI installation - Add Kind and kubectl install scripts - Update postCreateCommand with proper installation sequence
1 parent f4fbefd commit 28a302c

6 files changed

Lines changed: 169 additions & 34 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
{
22
"image": "mcr.microsoft.com/vscode/devcontainers/base:ubuntu",
33
"features": {
4+
"ghcr.io/devcontainers/features/github-cli:1": {},
45
"ghcr.io/devcontainers/features/go:1": {
56
"version": "1.22"
67
},
7-
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
8+
"ghcr.io/devcontainers/features/common-utils:2": {
9+
"username": "vscode"
10+
},
11+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
12+
"ghcr.io/devcontainers/features/node:1": { "version": "lts" }
813
},
14+
"remoteUser": "vscode",
915
"postCreateCommand": ".devcontainer/postCreateCommand.sh",
10-
"postStartCommand": ".devcontainer/postStartCommand.sh",
1116
"workspaceFolder": "/home/vscode/idpbuilder",
1217
"workspaceMount": "source=${localWorkspaceFolder},target=/home/vscode/idpbuilder,type=bind",
1318
"hostRequirements": {
1419
"cpus": 4
1520
},
1621
"remoteEnv": {
1722
"PATH": "${containerEnv:PATH}:/home/vscode/idpbuilder"
18-
}
23+
},
24+
"customizations": {
25+
"vscode": {
26+
"extensions": [
27+
"golang.Go",
28+
"ms-kubernetes-tools.vscode-kubernetes-tools",
29+
"anthropic.claude-dev"
30+
]
31+
}
32+
},
33+
"forwardPorts": [6789, 8080]
1934
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# Script to install claude-code CLI tool
4+
set -e
5+
6+
echo "🤖 Installing claude-code CLI tool..."
7+
8+
# Source Node.js environment from common locations
9+
if [ -f "/usr/local/share/nvm/nvm.sh" ]; then
10+
echo "🔧 Sourcing NVM environment..."
11+
export NVM_DIR="/usr/local/share/nvm"
12+
source "$NVM_DIR/nvm.sh"
13+
fi
14+
15+
# Add common Node.js paths to PATH
16+
export PATH="/usr/local/share/nodejs/bin:/usr/local/bin:$PATH"
17+
18+
# Wait for npm to become available (with timeout)
19+
echo "⏳ Waiting for npm to become available..."
20+
for i in {1..30}; do
21+
if command -v npm >/dev/null 2>&1; then
22+
echo "✅ npm found!"
23+
break
24+
fi
25+
echo "⏳ Attempt $i/30: npm not yet available, waiting 2 seconds..."
26+
sleep 2
27+
done
28+
29+
# Install claude-code globally via npm
30+
if command -v npm >/dev/null 2>&1; then
31+
echo "📦 Installing claude-code via npm..."
32+
npm install -g @anthropic-ai/claude-code
33+
echo "✅ claude-code installation completed"
34+
else
35+
echo "❌ Error: npm still not found after waiting. Node.js may not be properly installed."
36+
echo "ℹ️ Available commands:"
37+
which node || echo " - node: not found"
38+
which npm || echo " - npm: not found"
39+
echo "ℹ️ Current PATH: $PATH"
40+
exit 1
41+
fi
42+
43+
# Verify installation
44+
if command -v claude-code >/dev/null 2>&1; then
45+
echo "🎉 claude-code is now available in PATH"
46+
claude-code --version
47+
else
48+
echo "⚠️ Warning: claude-code may not be in PATH yet, but installation completed"
49+
fi

.devcontainer/install-kind.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Install KIND (Kubernetes IN Docker)
5+
KIND_VERSION="v0.23.0" # Change as needed
6+
7+
echo "Installing KIND ${KIND_VERSION}..."
8+
9+
# Try to install to /usr/local/bin/kind with sudo, fallback to user local bin
10+
if sudo curl -Lo /usr/local/bin/kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64 2>/dev/null && sudo chmod +x /usr/local/bin/kind 2>/dev/null; then
11+
echo "KIND installed to /usr/local/bin/kind"
12+
else
13+
echo "Installing KIND to user local bin..."
14+
mkdir -p /home/vscode/.local/bin
15+
curl -Lo /home/vscode/.local/bin/kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64
16+
chmod +x /home/vscode/.local/bin/kind
17+
echo "KIND installed to /home/vscode/.local/bin/kind"
18+
fi
19+
20+
echo "KIND installed!"

.devcontainer/install-kubectl.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
echo "🔧 Installing kubectl for current architecture..."
5+
6+
# Detect architecture
7+
ARCH=$(uname -m)
8+
case $ARCH in
9+
aarch64|arm64)
10+
KUBECTL_ARCH="arm64"
11+
;;
12+
x86_64|amd64)
13+
KUBECTL_ARCH="amd64"
14+
;;
15+
*)
16+
echo "❌ Unsupported architecture: $ARCH"
17+
exit 1
18+
;;
19+
esac
20+
21+
echo "📦 Detected architecture: $ARCH -> kubectl $KUBECTL_ARCH"
22+
23+
# Get latest stable version
24+
KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
25+
echo "📥 Downloading kubectl $KUBECTL_VERSION for $KUBECTL_ARCH..."
26+
27+
# Download kubectl binary
28+
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${KUBECTL_ARCH}/kubectl"
29+
30+
# Make it executable
31+
chmod +x kubectl
32+
33+
# Move to system PATH
34+
sudo mv kubectl /usr/local/bin/
35+
36+
# Verify installation
37+
echo "✅ kubectl installed successfully:"
38+
kubectl version --client --output=yaml
39+
40+
echo "🎉 kubectl installation completed!"
41+
42+
# setup autocomplete for kubectl and alias k
43+
sudo apt-get update -y && sudo apt-get install bash-completion -y
44+
mkdir $HOME/.kube
45+
echo "source <(kubectl completion bash)" >> $HOME/.bashrc
46+
echo "alias k=kubectl" >> $HOME/.bashrc
47+
echo "complete -F __start_kubectl k" >> $HOME/.bashrc

.devcontainer/postCreateCommand.sh

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
#!/usr/bin/env bash
2+
echo "running setup-ssh.sh"
3+
.devcontainer/setup-ssh.sh
4+
echo "running install-kubectl.sh"
5+
.devcontainer/install-kubectl.sh
6+
echo "running install-kind.sh"
7+
.devcontainer/install-kind.sh
8+
echo "running install-claude-code.sh"
9+
.devcontainer/install-claude-code.sh
210

3-
# For Kubectl AMD64 / x86_64
4-
[ $(uname -m) = x86_64 ] && curl -sLO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
5-
# For Kubectl ARM64
6-
[ $(uname -m) = aarch64 ] && curl -sLO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
7-
chmod +x ./kubectl
8-
sudo mv ./kubectl /usr/local/bin/kubectl
9-
10-
# For Kind AMD64 / x86_64
11-
[ $(uname -m) = x86_64 ] && curl -sLo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-amd64
12-
# For Kind ARM64
13-
[ $(uname -m) = aarch64 ] && curl -sLo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-arm64
14-
chmod +x ./kind
15-
sudo mv ./kind /usr/local/bin/kind
16-
17-
# setup autocomplete for kubectl and alias k
18-
sudo apt-get update -y && sudo apt-get install bash-completion -y
19-
mkdir $HOME/.kube
20-
echo "source <(kubectl completion bash)" >> $HOME/.bashrc
21-
echo "alias k=kubectl" >> $HOME/.bashrc
22-
echo "complete -F __start_kubectl k" >> $HOME/.bashrc
2311

2412
# Configure git if environment variables are set
2513
if [ -n "$GIT_COMMITER_NAME" ]; then
@@ -33,20 +21,20 @@ if [ -n "$GIT_COMMITER_EMAIL" ]; then
3321
fi
3422

3523
# 1. Configure GPG agent
36-
mkdir -p ~/.gnupg
37-
echo "pinentry-program /usr/bin/pinentry" > ~/.gnupg/gpg-agent.conf
38-
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
24+
#mkdir -p ~/.gnupg
25+
#echo "pinentry-program /usr/bin/pinentry" > ~/.gnupg/gpg-agent.conf
26+
#echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
3927

4028
# 2. Configure GPG client
41-
echo "use-agent" > ~/.gnupg/gpg.conf
42-
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
29+
#echo "use-agent" > ~/.gnupg/gpg.conf
30+
#echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
4331

4432
# 3. Restart GPG agent and set environment
45-
gpgconf --kill gpg-agent
46-
export GPG_TTY=$(tty)
47-
echo 'export GPG_TTY=$(tty)' >> ~/.bashrc
33+
#gpgconf --kill gpg-agent
34+
#export GPG_TTY=$(tty)
35+
#echo 'export GPG_TTY=$(tty)' >> ~/.bashrc
4836

4937
# 4. Configure Git for GPG signing
50-
git config --global commit.gpgsign true
51-
git config --global tag.gpgsign true
52-
git config --global gpg.program gpg
38+
#git config --global commit.gpgsign true
39+
#git config --global tag.gpgsign true
40+
#git config --global gpg.program gpg

.devcontainer/setup-ssh.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Script to setup SSH for GitHub access
4+
set -e
5+
6+
echo "🔐 Setting up SSH for GitHub access..."
7+
8+
# Add GitHub to known hosts
9+
mkdir -p ~/.ssh
10+
ssh-keyscan -H github.com >> ~/.ssh/known_hosts 2>/dev/null || echo "Warning: Could not add github.com to known hosts"
11+
12+
# Set proper permissions
13+
chmod 700 ~/.ssh 2>/dev/null || true
14+
chmod 600 ~/.ssh/known_hosts 2>/dev/null || true
15+
16+
echo "✅ SSH setup completed"

0 commit comments

Comments
 (0)