This document summarizes all improvements made to the coder-ddev template.
- Before: 270+ line embedded script in
template.tf - After: Clean external file at
template/scripts/startup.sh - Benefit: Much easier to maintain, test, and version control
- Added verification after Docker daemon starts
- Runs
docker infoto ensure daemon is functional - Shows detailed error logs if startup fails
- Location:
template/scripts/startup.sh:143-152
- Before: Variable defined but never used
- After: Variable removed (not supported by Sysbox)
- Rationale: Sysbox doesn't support volume size limits; disk space managed at host level
- Verifies DDEV installation with
ddev version - Tests DDEV-Docker connectivity with
ddev debug test - Provides helpful warnings if issues detected
- Location:
template/scripts/startup.sh:172-183
- Added comprehensive inline comment explaining purpose
- Documents required version (35) for Coder v2.13+
- Location:
template/template.tf:196-199
- Before: Hardcoded GID 988
- After: Configurable via
docker_gidvariable (default: 988) - Benefit: Works with different Docker group configurations
- Location:
template/template.tf:65-69, 276
- Before:
set +eignored all errors - After:
set -eby default withtry()function for non-critical operations - Benefit: Catches critical failures early while allowing non-essential operations to fail gracefully
- Location:
template/scripts/startup.sh:1-13
- Removed duplicate CODER_WORKSPACE_ID and CODER_WORKSPACE_NAME from container env
- These are already set in agent env (lines 195-206)
- Location:
template/template.tf:310-316
- Before: Comment said "GitLab Container Registry"
- After: "Registry authentication (supports Docker Hub, GitLab, GitHub Container Registry, etc.)"
- Location:
template/template.tf:21
- Added comprehensive comment explaining cleanup options
- Documents 4 alternative approaches for handling workspace cleanup
- References the implemented solution (coder_script resource)
- Location:
template/template.tf:334-342
- Template now reads version from
VERSIONfile automatically - Falls back to variable default if file doesn't exist
- Created
VERSIONfile with current version:1.0.0-beta1 - Location:
template/template.tf:106-108,VERSIONfile
- Added PHP version selector (8.1, 8.2, 8.3)
- Users can choose PHP version when creating workspace
- Value passed to workspace via DDEV_PHP_VERSION environment variable
- Location:
template/template.tf:80-99, 205
- Implemented
coder_scriptresource to run on workspace stop - Executes
ddev poweroffto cleanly shut down all projects - Prevents orphaned containers and corrupted databases
- Location:
template/template.tf:242-255
- Removed all commented-out code sections
- Replaced with clear documentation where needed
- Examples: Lines 290 (locale gen), 542-546 (Docker socket mount)
- Added CPU usage monitoring (10s interval)
- Added Memory usage monitoring (10s interval)
- Added Docker container count (30s interval)
- Added DDEV project count (60s interval)
- Location:
template/template.tf:208-238
- Before:
coder-ddev-base - After:
coder-ddev - Updated in README.md, CLAUDE.md, and all documentation
VERSION # Image version (1.0.0-beta1)
coder-ddev/scripts/startup.sh # Extracted startup script
CHANGES_SUMMARY.md # This file
coder-ddev/template.tf # Complete refactor with all improvements
README.md # Updated template name and directory
CLAUDE.md # Updated with new structure and locations
- Lines of Code Reduced: ~320 lines (from embedded script extraction)
- Configurability Added: 2 new variables, 1 workspace parameter
- Monitoring Added: 4 new metadata items
- Error Handling: Improved from fail-continue to fail-fast with selective tolerance
- Documentation: Significantly enhanced with inline comments
Before deploying to production:
-
Test Template Deployment:
coder templates push --directory coder-ddev --name coder-ddev --yes
-
Test Workspace Creation:
coder create --template coder-ddev test-workspace
-
Verify Startup Script:
- Check agent logs for successful Docker daemon start
- Verify DDEV version is displayed
- Confirm all health checks pass
-
Test DDEV Functionality:
cd ~/projects git clone <drupal-repo> cd <drupal-project> ddev start
-
Test Graceful Shutdown:
- Start a DDEV project
- Stop the workspace from Coder UI
- Verify
ddev poweroffwas executed in logs
-
Test Workspace Parameters:
- Create workspace with different PHP versions
- Verify DDEV_PHP_VERSION environment variable is set
None. All changes are backward compatible. Existing workspaces will continue to function.
For existing workspaces:
- No action required
- Next workspace restart will use the improved startup script
- Existing workspace parameters will use defaults if not specified
Potential enhancements not yet implemented:
- Add more workspace parameters (Node.js version, memory limits)
- Implement automatic DDEV project detection and startup
- Add workspace templates for common project types (Drupal, WordPress, Laravel)
- Create custom Coder widgets for DDEV status
- Add integration with external monitoring tools