Skip to content

Production-ready automation for deploying enterprise-grade Coder development environments on Scaleway Kubernetes, featuring 20+ workspace templates, comprehensive CI/CD workflows, and AI-enhanced development with Claude Code Flow integration.

License

Notifications You must be signed in to change notification settings

pacphi/bootstrap-coder-on-scaleway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

88 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bootstrap Coder on Scaleway

Production-ready automation for deploying enterprise-grade Coder development environments on Scaleway Kubernetes, featuring 20+ workspace templates, comprehensive CI/CD workflows, and AI-enhanced development with Claude Code Flow integration.

πŸ“‹ Prerequisites

Before deploying Coder on Scaleway, ensure you have the following:

1. Scaleway Account

2. Required Tools

Install the following tools on your local machine:

macOS (using Homebrew)

# Install all required tools
brew install terraform kubectl helm jq curl

# Alternative: Install specific versions
brew install terraform@1.12
brew install kubernetes-cli@1.32
brew install helm@3.12

Ubuntu/Debian

# Update package index
sudo apt-get update

# Install basic tools
sudo apt-get install -y curl jq git

# Install Terraform
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform

# Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

# Install Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

RHEL/CentOS/Fedora

# Install basic tools
sudo yum install -y curl jq git

# Install Terraform
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install terraform

# Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

# Install Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

Windows (using Chocolatey or Scoop)

# Using Chocolatey
choco install terraform kubernetes-cli kubernetes-helm jq curl git

# Using Scoop
scoop install terraform kubectl helm jq curl git

Verify Installation

# Check all tools are installed with correct versions
terraform version   # Must be >= 1.12.0
kubectl version --client   # Must be >= 1.32.0
helm version        # Must be >= 3.12.0
jq --version        # Any recent version
curl --version      # Any recent version
git --version       # Any recent version

3. Environment Variables

Set up your Scaleway credentials:

# Required credentials
export SCW_ACCESS_KEY="your-scaleway-access-key"
export SCW_SECRET_KEY="your-scaleway-secret-key"
export SCW_DEFAULT_PROJECT_ID="your-project-id"
export SCW_DEFAULT_ORGANIZATION_ID="your-organization-id"

# Optional: Set default region (defaults to fr-par)
export SCW_DEFAULT_REGION="fr-par"
export SCW_DEFAULT_ZONE="fr-par-1"

# Save to your shell profile for persistence
echo 'export SCW_ACCESS_KEY="your-scaleway-access-key"' >> ~/.bashrc
echo 'export SCW_SECRET_KEY="your-scaleway-secret-key"' >> ~/.bashrc
echo 'export SCW_DEFAULT_PROJECT_ID="your-project-id"' >> ~/.bashrc
echo 'export SCW_DEFAULT_ORGANIZATION_ID="your-organization-id"' >> ~/.bashrc

4. Optional Tools

GitHub CLI (Required for GitHub Actions deployment)

If you plan to use GitHub Actions for deployment:

# macOS
brew install gh

# Ubuntu/Debian
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update && sudo apt install gh

# RHEL/CentOS/Fedora
sudo dnf install 'dnf-command(config-manager)'
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh

# Windows
choco install gh          # Chocolatey
scoop install gh          # Scoop

# Authenticate with GitHub
gh auth login

5. Verify Prerequisites

Once everything is installed, verify your setup:

# Clone the repository
git clone https://github.com/your-org/bootstrap-coder-on-scaleway.git
cd bootstrap-coder-on-scaleway

# Run prerequisite check
./scripts/test-runner.sh --suite=prerequisites

6. GitHub Actions Configuration (Optional)

For automatic staging deployments via GitHub Actions:

Repository Secret Configuration:

# In your GitHub repository settings, add this secret:
ENABLE_AUTO_STAGING_DEPLOY=true  # Enables automatic staging deployment on push/PR

Note: This is a feature flag that controls continuous deployment. Set to true only when you want automatic deployments enabled. When not set or set to any other value, automatic deployments are disabled while manual deployments continue to work.

⚑ Quick Start

Important: Ensure you've completed all Prerequisites before proceeding.

Two-Phase Deployment Architecture

This project uses a two-phase deployment strategy for better reliability and troubleshooting:

  • Phase 1 (Infrastructure): Deploy Kubernetes cluster, database, networking, and security
  • Phase 2 (Coder Application): Deploy the Coder platform with workspace templates

Benefits: Infrastructure failures don't block cluster access, better separation of concerns, independent retry capability, and immediate kubeconfig access for troubleshooting.

Manual Deployment

Deploy your first Coder environment in minutes:

# 1. Verify prerequisites are met
./scripts/test-runner.sh --suite=prerequisites

# 2. Deploy complete environment (both phases automatically)
./scripts/lifecycle/setup.sh --env=dev --template=python-django-crewai

# πŸŽ‰ Your Coder instance will be available at the provided URL
# πŸ’‘ First deployment takes ~10-15 minutes

GitHub Actions Deployment

Deploy using GitHub Actions with automated two-phase workflow:

# Prerequisites: GitHub CLI (gh) must be installed
# Fork the repository and configure secrets
gh repo fork pacphi/bootstrap-coder-on-scaleway
gh secret set SCW_ACCESS_KEY --body "your-access-key"
gh secret set SCW_SECRET_KEY --body "your-secret-key"
gh secret set SCW_DEFAULT_PROJECT_ID --body "your-project-id"
gh secret set SCW_DEFAULT_ORGANIZATION_ID --body "your-organziation-id"

# Deploy complete environment (both phases)
gh workflow run deploy-environment.yml \
  -f environment=dev \
  -f template=python-django-crewai \
  -f enable_monitoring=true

# Or deploy infrastructure only for troubleshooting
gh workflow run deploy-infrastructure.yml \
  -f environment=dev

# Monitor deployment progress
gh run watch

What Happens Next?

Phase 1 - Infrastructure Deployment (~10 min):

  • βœ… Kubernetes cluster creation with auto-scaling
  • βœ… Managed PostgreSQL database provisioning
  • βœ… VPC networking and security groups
  • βœ… Load balancer and SSL configuration
  • βœ… Kubeconfig uploaded for immediate cluster access

Phase 2 - Coder Application Deployment (~5 min):

  • βœ… Coder platform installation and configuration
  • βœ… OAuth integration and user management
  • βœ… Workspace template deployment (if specified)
  • βœ… Final health checks and validation

Key Advantage: If Phase 2 fails, you still have full cluster access via kubeconfig to troubleshoot and retry Coder deployment independently.

πŸ—οΈ Multi-Environment Architecture

Environment Monthly Cost Use Case Resources
Development €53.70 Personal dev, learning 2Γ—GP1-XS nodes, DB-DEV-S
Staging €97.85 Team testing, CI/CD 3Γ—GP1-S nodes, DB-GP-S
Production €374.50 Enterprise, high availability 5Γ—GP1-M nodes, DB-GP-M HA

🎯 Available Templates

Backend (7 templates)

Java Spring, Python Django+CrewAI, Go Fiber, Ruby Rails, PHP Symfony, Rust Actix Web, .NET Core

Frontend (4 templates)

React+TypeScript, Angular, Vue+Nuxt, Svelte Kit

AI-Enhanced (2 templates)

Claude Code Flow Base/Enterprise with 87 MCP tools, swarm/hive-mind modes

DevOps (3 templates)

Docker Compose, Kubernetes+Helm, Terraform+Ansible

Data/ML (2 templates)

Jupyter+Python, R Studio

Mobile (3 templates)

Flutter, React Native, Ionic

πŸ“– Documentation

πŸ€– GitHub Actions CI/CD

Two-Phase Deployment Workflows

Complete Environment Deployment (Recommended):

# Deploy both infrastructure and Coder application
gh workflow run deploy-environment.yml \
  -f environment=staging \
  -f template=react-typescript \
  -f enable_monitoring=true

Phase-Specific Deployments:

# Deploy infrastructure only (Phase 1)
gh workflow run deploy-infrastructure.yml \
  -f environment=dev \
  -f region=fr-par

# Deploy Coder application only (Phase 2) - requires existing infrastructure
gh workflow run deploy-coder.yml \
  -f environment=dev \
  -f template=python-django-crewai

Teardown Environment

# Complete teardown (both phases)
gh workflow run teardown-environment.yml \
  -f environment=dev \
  -f confirmation="I understand this will destroy the environment" \
  -f create_backup=true

# Selective teardown options
gh workflow run teardown-environment.yml \
  -f environment=dev \
  -f teardown_mode=coder_only  # Keep infrastructure, remove Coder only

Template Validation

# Validate all templates and infrastructure
gh workflow run validate-templates.yml \
  -f validation_scope=comprehensive \
  -f test_deployments=true

πŸ› οΈ Management Scripts

Comprehensive Testing

# Run all validation tests
./scripts/test-runner.sh --suite=all

# Run specific test suites
./scripts/test-runner.sh --suite=smoke,templates --format=json

# Test external integrations
./scripts/test-runner.sh --suite=integrations

Environment Validation

# Quick health check
./scripts/validate.sh --env=prod --quick

# Comprehensive validation with detailed report
./scripts/validate.sh --env=staging --comprehensive --format=json

Dynamic Scaling

# Scale cluster with cost analysis
./scripts/scale.sh --env=prod --nodes=8 --analyze-cost

# Auto-scale based on workload
./scripts/scale.sh --env=staging --auto --target-cpu=70

Automated Backups

# Complete environment backup
./scripts/lifecycle/backup.sh --env=prod --include-all

# Pre-destroy backup with retention
./scripts/lifecycle/backup.sh --env=staging --pre-destroy --retention-days=90

πŸ”§ Hooks Framework

Custom Automation

# Customize deployment lifecycle
./scripts/hooks/pre-setup.sh    # Before deployment starts
./scripts/hooks/post-setup.sh   # After deployment completes
./scripts/hooks/pre-teardown.sh # Before teardown starts
./scripts/hooks/post-teardown.sh # After teardown completes

Integration Examples

  • Slack notifications for deployment events
  • JIRA ticket creation for environment changes
  • External monitoring system registration
  • Compliance checks and audit logging
  • User notifications and workspace management

πŸ“š Complete Integration Setup Guide - Detailed documentation for configuring all external integrations

πŸš€ Key Features

πŸ—οΈ Infrastructure & Deployment

  • Multi-environment deployment with cost optimization (dev/staging/prod)
  • GitHub Actions CI/CD with automated workflows and notifications
  • Terraform automation with state management and drift detection
  • Kubernetes management on Scaleway Kapsule with auto-scaling
  • Extensible hooks framework for custom deployment logic

🎯 Templates & Development

  • 21+ production-ready templates across all major frameworks
  • AI-enhanced development with Claude Code Flow integration (87 MCP tools)
  • Dynamic template discovery with automatic validation
  • Multi-language support (Java, Python, Go, Rust, JS/TS, C#, PHP, Ruby)
  • Specialized templates for data science, DevOps, and mobile development

πŸ”’ Security & Compliance

  • Enterprise security with Pod Security Standards and RBAC
  • Network policies and traffic isolation
  • Encrypted secrets management with Kubernetes
  • Audit logging and compliance tracking
  • Environment-specific security policies (dev/staging/prod)

πŸ“Š Monitoring & Operations

  • Cost management with real-time tracking and budget alerts
  • Comprehensive monitoring with Prometheus/Grafana stacks
  • Health checks and automated validation
  • Performance metrics and resource optimization
  • External system integration (Slack, monitoring, etc.)

πŸ’Ύ Backup & Recovery

  • Automated backups with configurable retention policies
  • Disaster recovery procedures with point-in-time restoration
  • Pre-destroy backups to prevent data loss
  • Multi-format exports (infrastructure, configs, data)
  • Backup verification and integrity checks

⚑ Performance & Scaling

  • Dynamic cluster scaling with cost analysis
  • Auto-scaling policies based on CPU/memory metrics
  • Resource quotas and limit enforcement
  • Load balancing with SSL termination
  • Performance optimization recommendations

πŸ›‘οΈ Enterprise Ready

βœ… Security: Pod Security Standards, Network Policies, RBAC, encrypted secrets βœ… Monitoring: Prometheus metrics, Grafana dashboards, alerting βœ… Compliance: Audit logging, cost tracking, resource quotas βœ… Scalability: Auto-scaling nodes (3-15), high availability database βœ… Reliability: Automated backups, disaster recovery, health checks

πŸš€ Advanced Usage Examples

Complete Development Workflow

# 1. Deploy development environment with AI template (two-phase automatic)
./scripts/lifecycle/setup.sh --env=dev --template=claude-flow-base

# 2. Validate deployment
./scripts/validate.sh --env=dev --quick

# 3. Scale for team development
./scripts/scale.sh --env=dev --nodes=4

# 4. Create backup before major changes
./scripts/lifecycle/backup.sh --env=dev --include-workspaces

# 5. Run comprehensive tests
./scripts/test-runner.sh --suite=integration --env=dev

Production Deployment with Monitoring

# Deploy production with all enterprise features (two-phase automatic)
./scripts/lifecycle/setup.sh \
  --env=prod \
  --template=java-spring \
  --enable-monitoring \
  --enable-ha \
  --cost-budget=400

# Validate production readiness
./scripts/validate.sh --env=prod --comprehensive

# Set up automated scaling
./scripts/scale.sh --env=prod --auto --min-nodes=5 --max-nodes=15

Troubleshooting with Two-Phase Architecture

# If Coder deployment fails, infrastructure is still accessible:

# 1. Use kubeconfig from Phase 1 to investigate
export KUBECONFIG=~/.kube/config-coder-dev
kubectl get pods -n coder
kubectl describe deployment coder -n coder

# 2. Retry only Coder deployment (Phase 2)
gh workflow run deploy-coder.yml -f environment=dev

# 3. Or use manual deployment for Phase 2
cd environments/dev/coder
terraform init && terraform apply

CI/CD Pipeline Integration

# GitHub Actions example - Two-Phase Deployment
name: Deploy Staging on PR
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  deploy-staging:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy complete environment (two-phase)
        uses: ./.github/workflows/deploy-environment.yml
        with:
          environment: staging
          template: react-typescript
          enable_monitoring: true
          auto_approve: true

Environment Structure

The two-phase architecture organizes environments with separate configurations:

environments/
β”œβ”€β”€ dev/
β”‚   β”œβ”€β”€ infra/          # Phase 1: Infrastructure (cluster, database, networking)
β”‚   β”‚   β”œβ”€β”€ main.tf
β”‚   β”‚   β”œβ”€β”€ providers.tf
β”‚   β”‚   └── outputs.tf
β”‚   └── coder/          # Phase 2: Coder application deployment
β”‚       β”œβ”€β”€ main.tf
β”‚       β”œβ”€β”€ providers.tf
β”‚       └── outputs.tf
β”œβ”€β”€ staging/
β”‚   β”œβ”€β”€ infra/
β”‚   └── coder/
└── prod/
    β”œβ”€β”€ infra/
    └── coder/

πŸ” Troubleshooting

Common Issues

Prerequisites Missing

# Check system requirements
./scripts/test-runner.sh --suite=prerequisites

Template Deployment Fails

# Validate templates
./scripts/test-runner.sh --suite=templates

# Check template syntax
gh workflow run validate-templates.yml -f validation_scope=syntax

Two-Phase Deployment Issues

# Infrastructure deployment failed (Phase 1)
# Check Scaleway console and workflow logs
gh run list --workflow=deploy-infrastructure.yml

# Coder deployment failed (Phase 2) - Infrastructure still accessible
# Use kubeconfig to troubleshoot
export KUBECONFIG=~/.kube/config-coder-<env>
kubectl get storageclass  # Check if scw-bssd storage class exists
kubectl get pvc -n coder  # Check persistent volume claims

# Retry only Coder deployment
gh workflow run deploy-coder.yml -f environment=<env>

Cost Overruns

# Analyze current costs
./scripts/utils/cost-calculator.sh --env=all --detailed

# Set budget alerts
./scripts/utils/cost-calculator.sh --env=prod --set-budget=300 --alert-threshold=80

Scaling Issues

# Check cluster capacity
./scripts/validate.sh --env=prod --focus=resources

# Analyze scaling recommendations
./scripts/scale.sh --env=prod --analyze-only

Support Channels

🀝 Contributing

We welcome contributions! Please see our Contributing Guidelines and check out open issues.

Development Setup

# Fork and clone the repository
gh repo fork your-org/bootstrap-coder-on-scaleway
cd bootstrap-coder-on-scaleway

# Run comprehensive tests
./scripts/test-runner.sh --suite=all

# Deploy test environment
./scripts/lifecycle/setup.sh --env=dev --template=python-django-crewai

πŸ“„ License

MIT License - see LICENSE for details.


πŸš€ Ready to get started? Choose your deployment method:

  • Quick Start: ./scripts/lifecycle/setup.sh --env=dev --template=react-typescript
  • GitHub Actions: gh workflow run deploy-environment.yml
  • Comprehensive Setup: Check the Usage Guide

Need help? Check the documentation or create an issue πŸ“ž

About

Production-ready automation for deploying enterprise-grade Coder development environments on Scaleway Kubernetes, featuring 20+ workspace templates, comprehensive CI/CD workflows, and AI-enhanced development with Claude Code Flow integration.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •