Skip to content

Commit 918d1c3

Browse files
committed
feat: add GitHub Codespaces support for cloud development
Add comprehensive GitHub Codespaces configuration to replace GitPod as the primary cloud development environment (GitPod free tier has sunset). Changes: - Add .devcontainer/devcontainer.json with Docker-in-Docker and GitHub CLI - Add .devcontainer/setup.sh for automated environment setup - Add dockerfiles/codespacesURL.sh for Codespaces URL configuration - Add CODESPACES_MIGRATION_PLAN.md with detailed migration strategy - Update README.md with Codespaces quick start and instructions - Update .gitignore for local development files - Set default empty values for GITPOD_WORKSPACE_URL to suppress warnings Features: - Automatic yq installation for YAML processing - Port forwarding for Jenkins (8080) with public visibility - Environment-aware URL configuration using CODESPACE_NAME - Maintains backward compatibility with GitPod configuration - 60 hours/month free tier (sufficient for all tutorials) - Welcome message displayed on every terminal session The migration maintains dual support for both Codespaces and GitPod during the transition period, allowing users to choose their preferred environment.
1 parent 2f55a59 commit 918d1c3

File tree

7 files changed

+538
-9
lines changed

7 files changed

+538
-9
lines changed

.devcontainer/devcontainer.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "Jenkins Quickstart Tutorials",
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
4+
5+
"features": {
6+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
7+
"version": "latest",
8+
"dockerDashComposeVersion": "v2"
9+
},
10+
"ghcr.io/devcontainers/features/github-cli:1": {
11+
"version": "latest"
12+
}
13+
},
14+
15+
"onCreateCommand": "bash .devcontainer/setup.sh",
16+
"postStartCommand": "cat .devcontainer/welcome.txt 2>/dev/null || echo 'Run: .devcontainer/setup.sh for tutorial instructions'",
17+
18+
"forwardPorts": [8080, 3000, 5000],
19+
20+
"portsAttributes": {
21+
"8080": {
22+
"label": "Jenkins Controller",
23+
"onAutoForward": "openPreview",
24+
"protocol": "http",
25+
"visibility": "public"
26+
},
27+
"3000": {
28+
"label": "Application Port (Node/Android/Go)",
29+
"onAutoForward": "notify",
30+
"protocol": "http"
31+
},
32+
"5000": {
33+
"label": "Application Port (Multi/.NET)",
34+
"onAutoForward": "notify",
35+
"protocol": "http"
36+
}
37+
},
38+
39+
"customizations": {
40+
"vscode": {
41+
"extensions": [
42+
"ms-azuretools.vscode-docker",
43+
"redhat.vscode-yaml"
44+
],
45+
"settings": {
46+
"terminal.integrated.defaultProfile.linux": "bash"
47+
}
48+
}
49+
},
50+
51+
"remoteUser": "vscode",
52+
53+
"updateContentCommand": "echo 'Container updated successfully'"
54+
}

.devcontainer/setup.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
# GitHub Codespaces setup script for Jenkins Quickstart Tutorials
3+
# This script configures the Codespace environment and prepares Jenkins URL configuration
4+
5+
set -e # Exit on error
6+
7+
echo "================================"
8+
echo "Setting up Jenkins Tutorials Environment"
9+
echo "================================"
10+
11+
# Install yq (YAML processor) - required for JCasc configuration
12+
echo "📦 Installing yq YAML processor..."
13+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
14+
sudo chmod a+x /usr/local/bin/yq
15+
yq --version
16+
17+
# Verify Docker is available
18+
echo "🐳 Verifying Docker installation..."
19+
docker --version
20+
docker compose version
21+
22+
# Create secrets directory if it doesn't exist
23+
echo "📁 Creating secrets directory..."
24+
mkdir -p ./secrets
25+
26+
# Run Codespaces URL configuration script
27+
if [ -f "./dockerfiles/codespacesURL.sh" ]; then
28+
echo "🔧 Configuring Jenkins URLs for Codespaces..."
29+
chmod +x ./dockerfiles/codespacesURL.sh
30+
./dockerfiles/codespacesURL.sh
31+
else
32+
echo "⚠️ Warning: codespacesURL.sh not found, skipping URL configuration"
33+
fi
34+
35+
# Create welcome message for future terminal sessions
36+
WELCOME_FILE=".devcontainer/welcome.txt"
37+
cat > "$WELCOME_FILE" << 'WELCOME_EOF'
38+
39+
================================
40+
🚀 Jenkins Quickstart Tutorials
41+
================================
42+
43+
Available tutorial profiles:
44+
• default : Basic Jenkins with SSH agent
45+
• maven : Jenkins + Maven build environment
46+
• python : Jenkins + Python development
47+
• node : Jenkins + Node.js/npm
48+
• multi : Multibranch pipeline example
49+
• android : Android development
50+
• golang : Go development
51+
• cpp : C++ development
52+
• dotnet : .NET development
53+
• wizard : Jenkins setup wizard (learning)
54+
55+
Quick Start:
56+
docker compose --profile <profile-name> up -d
57+
58+
Examples:
59+
docker compose --profile maven up -d
60+
docker compose --profile node up -d
61+
62+
To build locally:
63+
docker compose -f build-docker-compose.yaml --profile <profile-name> up -d
64+
65+
WELCOME_EOF
66+
67+
# Add Jenkins URL based on environment
68+
if [ -n "$CODESPACE_NAME" ] && [ -n "$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" ]; then
69+
echo "Jenkins will be accessible at:" >> "$WELCOME_FILE"
70+
echo " https://${CODESPACE_NAME}-8080.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" >> "$WELCOME_FILE"
71+
else
72+
echo "Jenkins will be accessible at:" >> "$WELCOME_FILE"
73+
echo " http://localhost:8080" >> "$WELCOME_FILE"
74+
fi
75+
76+
echo "" >> "$WELCOME_FILE"
77+
echo "Default credentials: admin/admin" >> "$WELCOME_FILE"
78+
echo "================================" >> "$WELCOME_FILE"
79+
echo "" >> "$WELCOME_FILE"
80+
81+
# Display the welcome message
82+
cat "$WELCOME_FILE"
83+
84+
echo "✅ Setup Complete! Welcome message saved to $WELCOME_FILE"
85+
echo ""

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ secrets/*
44
03_maven_tutorial/secrets/*
55
.tutorial_running.txt
66

7+
# Local development files
8+
CLAUDE.md
9+
CONTEXT.md
10+
.devcontainer/welcome.txt

0 commit comments

Comments
 (0)