Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,30 @@ This project provides a Coder v2+ template for DDEV-based development environmen
**Key Technologies:**
- **Terraform (HCL)** - Infrastructure as Code for Coder templates
- **Docker + Sysbox** - Nested containerization without privileged mode
- **DDEV v1.24.10** - PHP/Node/Python development environment tool
- **DDEV** - PHP/Node/Python development environment tool (supports 20+ project types)
- **VS Code for Web** - Browser-based IDE via official Coder module
- **Ubuntu 24.04** - Base container OS

**Note:** User-facing documentation has moved to `/docs/`. This file focuses on developer/contributor guidance.

## Essential Commands

### Template Management
```bash
# Deploy or update template
coder templates push --directory coder-ddev coder-ddev --yes
coder templates push --directory ddev-user ddev-user --yes

# List all templates
coder templates list

# Delete template (must delete workspaces first)
coder templates delete coder-ddev --yes
coder templates delete ddev-user --yes
```

### Workspace Management
```bash
# Create workspace
coder create --template coder-ddev <workspace-name> --yes
coder create --template ddev-user <workspace-name> --yes

# List workspaces
coder list
Expand All @@ -56,15 +58,22 @@ docker build -t randyfay/coder-ddev:v0.1 .
docker push randyfay/coder-ddev:v0.1

# Update version for new releases
echo "v0.2" > ../coder-ddev/VERSION
echo "v0.2" > ../VERSION
docker build -t randyfay/coder-ddev:v0.2 .
docker push randyfay/coder-ddev:v0.2
```

### DDEV Commands (within workspace)
```bash
# Initialize DDEV in project directory
ddev config --project-type=drupal10 --docroot=web
# Replace <project-type> with your type: php, wordpress, laravel, drupal, etc.
ddev config --project-type=<project-type> --docroot=web

# Common examples:
# ddev config --project-type=wordpress --docroot=web
# ddev config --project-type=laravel --docroot=public
# ddev config --project-type=drupal --docroot=web
# ddev config --project-type=php --docroot=web

# Start DDEV environment
ddev start
Expand Down Expand Up @@ -125,7 +134,7 @@ The template uses **Sysbox-runc** instead of privileged Docker containers:
**Critical:** The `/home/coder` volume mount hides image contents, so files must be copied from `/home/coder-files/` during startup script execution.

### Startup Script Flow
The startup script in `coder-ddev/scripts/startup.sh` performs:
The startup script is inline in `ddev-user/template.tf` (inside the `coder_agent` resource's `startup_script` field). It performs:
1. **Permissions** - Fix ownership of `/home/coder` volume
2. **Home initialization** - Copy skeleton files if first run
3. **Git SSH setup** - Configure Coder's GitSSH wrapper
Expand All @@ -143,11 +152,11 @@ The startup script in `coder-ddev/scripts/startup.sh` performs:
- **Isolation**: Each workspace gets separate host directory and Docker volume

### Terraform Variables
Key template variables in `coder-ddev/template.tf`:
Key template variables in `ddev-user/template.tf`:
- `workspace_image_registry` - Docker registry URL (default: `index.docker.io/randyfay/coder-ddev`)
- `image_version` - Image tag (default: read from `VERSION` file or `v0.1`)
- `cpu` / `memory` - Resource limits (defaults: 4 cores, 8GB RAM)
- `node_version` - Node.js version (default: `20`)
- `node_version` - Node.js version (default: `24`, informational only — Node is pre-installed in image)
- `docker_gid` - Docker group GID (default: `988`)
- `registry_username` / `registry_password` - Registry authentication (optional)

Expand Down Expand Up @@ -186,10 +195,11 @@ The `image/Dockerfile` builds the base workspace image:
1. **Base packages** - curl, wget, git, vim, sudo, build tools, bash-completion
2. **User setup** - Rename ubuntu user → coder (UID 1000)
3. **Scripts copy** - `COPY scripts /home/coder-files` (outside volume mount)
4. **Python/Node** - Install Python 3, Node.js 22.x LTS
4. **Python/Node** - Install Python 3, Node.js 24.x LTS
5. **Global npm tools** - OpenSpec, TypeScript (in image, re-attempted in startup)
6. **Docker daemon** - `docker-ce`, `docker-ce-cli`, `containerd`, systemd for Sysbox
7. **DDEV** - v1.24.10 from official apt package (pkg.ddev.com)
7. **DDEV** - from official apt package (pkg.ddev.com)
8. **Homebrew (Linuxbrew)** - `bats-core`, `bats-support`, `bats-assert`, `go`, `golangci-lint`

### Important Build Notes
- User `coder` gets passwordless sudo: `coder ALL=(ALL) NOPASSWD:ALL`
Expand Down Expand Up @@ -249,12 +259,11 @@ Additional logs in workspace:

## Important Code Locations

- `coder-ddev/template.tf` - Main Terraform template definition
- `coder-ddev/scripts/startup.sh` - Workspace startup script with Docker/DDEV initialization
- `coder-ddev/template.tf:183-239` - Coder agent configuration
- `coder-ddev/template.tf:242-248` - VS Code for Web module (official Coder module)
- `coder-ddev/template.tf:250-263` - Graceful DDEV shutdown script
- `coder-ddev/template.tf:268-332` - Docker container resource
- `ddev-user/template.tf` - Main Terraform template definition (startup script is inline in coder_agent)
- `ddev-user/template.tf` - Coder agent configuration with inline startup script
- `ddev-user/template.tf` - VS Code for Web module (official Coder module)
- `ddev-user/template.tf` - Graceful DDEV shutdown script (coder_script resource)
- `ddev-user/template.tf` - Docker container resource
- `image/Dockerfile` - Base image build instructions
- `image/scripts/.ddev/global_config.yaml` - DDEV defaults
- `VERSION` - Image version used by template (read automatically)
Expand Down
72 changes: 64 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# DDEV Coder Template

Coder workspace template for Drupal development with ddev, Docker-in-Docker support, Node.js, and Git.
Coder workspace template for DDEV-based development with Docker-in-Docker support, Node.js, and Git.

## Features

- **Custom Base Image**: Ubuntu LTS with curl/wget/sudo pre-installed
- **Docker-in-Docker**: Full Docker support for ddev (using Sysbox runtime)
- **Node.js/npm**: LTS version
- **ddev**: Latest version pre-installed
- **PHP/Composer**: Via ddev containers
- **Custom Base Image**: Ubuntu 24.04 LTS with essential development tools
- **Docker-in-Docker**: Full Docker support for DDEV (using Sysbox runtime)
- **Node.js/npm**: LTS version (configurable)
- **DDEV**: Pre-installed and ready to use
- **VS Code for Web**: Browser-based IDE with full extension support
- **PHP/Python/Node Projects**: Support for 20+ project types via DDEV

## Configuration

Expand Down Expand Up @@ -73,9 +74,38 @@ make deploy-no-cache # Clean build and deploy

**Note:** Keep the VERSION file and template.tf `image_version` in sync manually when releasing new versions.

## Template Structure
## Supported Project Types

DDEV supports 20+ project types out of the box. All work identically in Coder workspaces.

**Static Sites:**
- HTML, Jekyll, Hugo, any static site generator

**Generic:**
- Custom PHP, Go, Rust, or any web application

See [DDEV Documentation](https://docs.ddev.com/) for full list and configuration.

## Documentation

**New to Coder?**
- 📘 [Getting Started Guide](./docs/user/getting-started.md) - Create your first workspace
- 📗 [Using Workspaces](./docs/user/using-workspaces.md) - Daily workflows and tips

**Administrators:**
- 📕 [Operations Guide](./docs/admin/operations-guide.md) - Deploy and manage template
- 📙 [User Management](./docs/admin/user-management.md) - Users, roles, permissions
- 📔 [Troubleshooting](./docs/admin/troubleshooting.md) - Debug common issues

**DDEV Experts:**
- 🔍 [Comparison to Local DDEV](./docs/architecture/comparison-to-local.md) - Architecture, tradeoffs, migration

**Developers/Contributors:**
- 🤖 [CLAUDE.md](./CLAUDE.md) - AI-assisted development guide

📚 **[Full Documentation Index](./docs/README.md)**

Templates are organized in directories where **the directory name is the template name**:
## Template Structure

```
coder-ddev/
Expand Down Expand Up @@ -149,3 +179,29 @@ coder create --template ddev-user <workspace-name>
# Drupal core development environment
coder create --template ddev-drupal-core <workspace-name>
```

**Access your project:**
- Open Coder dashboard
- Find your workspace
- Click on port **80** or **443** under "Apps"

**📖 [Full Getting Started Guide](./docs/user/getting-started.md)**

### For Administrators

Deploy template and manage infrastructure:

```bash
# Build and push Docker image
cd image
docker build -t randyfay/coder-ddev:v0.1 .
docker push randyfay/coder-ddev:v0.1

# Deploy template to Coder
coder templates push --directory ddev-user ddev-user --yes

# Or use Makefile
make deploy # Build + push image + push template
```

**📖 [Full Operations Guide](./docs/admin/operations-guide.md)**
Loading