Skip to content

Deploying Coder

Coder is a powerful open-source platform that enables teams to provision and manage secure cloud development environments (workspaces) using Infrastructure as Code (IaC). Built on top of Terraform, Coder allows organizations to create standardized, reproducible development environments that can be accessed from anywhere via web IDEs (VS Code in the browser), SSH, or local IDEs. Whether you’re looking to centralize development infrastructure, provide consistent environments across teams, enable secure remote development, reduce local setup time, or improve developer productivity with powerful cloud resources, Coder provides enterprise-grade features including workspace templates, automated provisioning, role-based access control, audit logging, and resource quotas—all while keeping your infrastructure flexible and portable.

This comprehensive guide walks through deploying Coder to Klutch.sh using a Dockerfile for reliable, containerized deployment. You’ll learn how to set up Coder with persistent storage for workspaces and configuration data, create a production-ready Dockerfile, configure PostgreSQL database connectivity, manage workspace templates, implement security best practices, configure custom domains, set up monitoring and logging, and troubleshoot common issues. By the end of this guide, you’ll have a production-ready Coder instance running on Klutch.sh’s global infrastructure with automatic HTTPS, optimized performance, and reliable hosting for your remote development platform.

Prerequisites

  • Docker installed locally for testing (optional but recommended)
  • Git installed locally and a GitHub account (Klutch.sh uses GitHub as the only git source)
  • Klutch.sh account with access to the dashboard at klutch.sh/app
  • Text editor or IDE for code editing (VS Code recommended)
  • PostgreSQL database (required for production deployments)
  • Basic understanding of Terraform (helpful for creating workspace templates)
  • Docker knowledge for understanding workspace provisioning
  • Basic networking knowledge: Understanding of HTTP/HTTPS and SSH

Understanding Coder Architecture

Technology Stack

Backend:

  • Go application (compiled binary)
  • PostgreSQL database (required for multi-user deployments)
  • Terraform for infrastructure provisioning
  • Built-in web server
  • WebSocket support for terminal access
  • OAuth2/OIDC authentication support

Frontend:

  • React-based web interface
  • Monaco Editor (VS Code in browser)
  • WebSocket-based terminal
  • Responsive design
  • Progressive Web App (PWA) capabilities

Key Features

Workspace Management:

  • Template-based workspace provisioning
  • Support for Docker, Kubernetes, AWS, Azure, GCP
  • Automatic workspace lifecycle management
  • Workspace scheduling (auto-start/stop)
  • Development environment versioning
  • Workspace snapshots and backups

Developer Experience:

  • VS Code in the browser (code-server)
  • SSH access to workspaces
  • Local IDE integration (VS Code, JetBrains)
  • Port forwarding for running applications
  • File upload/download
  • Terminal access

Administration:

  • User management and authentication
  • Role-based access control (RBAC)
  • Template management and versioning
  • Resource quotas and limits
  • Audit logging
  • Usage analytics

Security:

  • End-to-end encrypted connections
  • OAuth2/OIDC integration
  • SCIM for user provisioning
  • Network policies
  • Workspace isolation
  • API token management

Project Setup

1. Create Project Directory

Create a project directory for Coder deployment:

Terminal window
mkdir coder-deployment
cd coder-deployment
git init

2. Create Directory Structure

Create necessary directories:

Terminal window
mkdir -p {config,data,scripts,templates}

Resulting project structure:

coder-deployment/
├── Dockerfile
├── entrypoint.sh
├── config/
│ └── coder.env
├── data/
│ └── (persistent data)
├── templates/
│ └── (workspace templates)
├── scripts/
│ └── init-db.sh
├── .dockerignore
├── .gitignore
└── README.md

3. Create .gitignore File

Create .gitignore to exclude unnecessary files:

.env
.env.local
*.log
.DS_Store
.vscode
.idea
data/
*.db
*.sqlite
.cache/
tmp/

4. Create .dockerignore File

Create .dockerignore to exclude files from Docker build:

.git
.gitignore
*.log
.env
data/
.DS_Store
.vscode
.idea
tests/
README.md
scripts/

Creating a Production Dockerfile

Create a Dockerfile for production deployment:

# Use official Coder base image
FROM ghcr.io/coder/coder:latest
# Switch to root for setup
USER root
# Install additional utilities
RUN apk add --no-cache \
bash \
curl \
ca-certificates \
postgresql-client \
openssh-client \
git \
&& rm -rf /var/cache/apk/*
# Create coder user and directories
RUN addgroup -g 1000 coder && \
adduser -D -u 1000 -G coder coder && \
mkdir -p /home/coder/.config/coderv2 && \
chown -R coder:coder /home/coder
# Create data directory
RUN mkdir -p /var/lib/coder && \
chown -R coder:coder /var/lib/coder
# Copy entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:3000/api/v2/buildinfo || exit 1
# Expose Coder port
EXPOSE 3000
# Switch to coder user
USER coder
# Set working directory
WORKDIR /home/coder
# Use entrypoint script
ENTRYPOINT ["/entrypoint.sh"]

Dockerfile Explanation

  • Base Image: Uses official Coder image from GitHub Container Registry
  • Additional Tools: Installs PostgreSQL client, SSH client, and Git for workspace management
  • Non-root User: Runs as coder user for security
  • Data Persistence: Creates /var/lib/coder for configuration and cache
  • Health Checks: Automatic container health monitoring via API endpoint
  • Port: Exposes port 3000 (default Coder port)

Create Entrypoint Script

Create entrypoint.sh for initialization:

#!/bin/bash
set -e
echo "Starting Coder initialization..."
# Wait for PostgreSQL if configured
if [ ! -z "$CODER_PG_CONNECTION_URL" ]; then
echo "Waiting for PostgreSQL..."
# Extract host and port from connection URL
DB_HOST=$(echo $CODER_PG_CONNECTION_URL | sed -n 's/.*@\([^:]*\):.*/\1/p')
DB_PORT=$(echo $CODER_PG_CONNECTION_URL | sed -n 's/.*:\([0-9]*\)\/.*/\1/p')
if [ ! -z "$DB_HOST" ] && [ ! -z "$DB_PORT" ]; then
until pg_isready -h "$DB_HOST" -p "$DB_PORT" -U postgres > /dev/null 2>&1; do
echo "PostgreSQL is unavailable - sleeping"
sleep 2
done
echo "PostgreSQL is available"
fi
fi
# Create config directory if it doesn't exist
mkdir -p /home/coder/.config/coderv2
mkdir -p /var/lib/coder
# Set permissions
chown -R coder:coder /home/coder/.config/coderv2
chown -R coder:coder /var/lib/coder
# Start Coder server
echo "Starting Coder server..."
exec coder server

Building the Dockerfile Locally (Optional)

Test the Dockerfile locally:

Terminal window
# Build the Docker image
docker build -t coder:latest .
# Run the container locally (for testing only)
docker run -d \
--name coder-test \
-p 3000:3000 \
-e CODER_ACCESS_URL=http://localhost:3000 \
-e CODER_PG_CONNECTION_URL=postgresql://user:pass@localhost:5432/coder \
coder:latest
# Wait for container to start
sleep 30
# Access the application
# http://localhost:3000

Deploying with Docker on Klutch.sh

Klutch.sh automatically detects a Dockerfile in your repository root and uses it for deployment.

Prerequisites for Docker Deployment

  • Your Coder project pushed to GitHub with Dockerfile
  • PostgreSQL database (either external or deployed on Klutch.sh)
  • Persistent storage configured for data and configuration
  • Domain name (recommended for production)

Steps to Deploy with Docker

  1. Prepare Your Repository

    Commit and push all necessary files:

    Terminal window
    git add Dockerfile entrypoint.sh .dockerignore
    git commit -m "Add Docker deployment configuration for Coder"
    git push origin main
  2. Log In to Klutch.sh Dashboard

    Go to klutch.sh/app and sign in with your GitHub account.

  3. Create a Project

    Navigate to the Projects section and create a new project for your Coder instance.

  4. Create an App

    Click “Create App” and select your GitHub repository containing the Coder Docker configuration.

  5. Select the Branch

    Choose the branch you want to deploy (typically main).

  6. Configure Traffic Type

    Select HTTP as the traffic type for Coder (a web application).

  7. Set the Internal Port

    Set the internal port to 3000 – this is the port where Coder server listens.

  8. Add Environment Variables

    Configure environment variables for your Coder instance:

    Terminal window
    # Required: Access URL (your Klutch.sh URL)
    CODER_ACCESS_URL=https://example-app.klutch.sh
    # Required: PostgreSQL Database Connection
    CODER_PG_CONNECTION_URL=postgresql://coder_user:secure_password@db.example.com:5432/coder?sslmode=require
    # Optional: Admin user for first login
    CODER_FIRST_USER_EMAIL=admin@example.com
    CODER_FIRST_USER_USERNAME=admin
    CODER_FIRST_USER_PASSWORD=change_this_secure_password
    # Security Settings
    CODER_SECURE_AUTH_COOKIE=true
    CODER_REDIRECT_TO_ACCESS_URL=true
    # Session Settings
    CODER_SESSION_DURATION=24h
    CODER_MAX_TOKEN_LIFETIME=720h
    # OAuth2/OIDC Settings (optional)
    # CODER_OIDC_ISSUER_URL=https://accounts.google.com
    # CODER_OIDC_CLIENT_ID=your-client-id
    # CODER_OIDC_CLIENT_SECRET=your-client-secret
    # CODER_OIDC_SCOPES=openid,email,profile
    # GitHub OAuth (optional)
    # CODER_OAUTH2_GITHUB_CLIENT_ID=your-github-client-id
    # CODER_OAUTH2_GITHUB_CLIENT_SECRET=your-github-client-secret
    # CODER_OAUTH2_GITHUB_ALLOWED_ORGS=your-org
    # Workspace Settings
    CODER_PROVISIONER_DAEMONS=1
    CODER_MAX_PARALLEL_PROVISIONING_OPERATIONS=10
    # Telemetry (disable for privacy)
    CODER_TELEMETRY=false
    # Logging
    CODER_LOG_HUMAN=true
    CODER_VERBOSE=false
    # Timezone
    TZ=UTC

    Replace with your actual values. Important: You must have a PostgreSQL database ready before deploying Coder.

  9. Configure Persistent Storage

    Coder needs persistent volumes for configuration and cache:

    1. After creating the app, go to Volumes
    2. Add volume for data:
      • Mount path: /var/lib/coder
      • Size: 5-10 GiB (adjust based on number of workspaces and templates)
    3. Add volume for config:
      • Mount path: /home/coder/.config/coderv2
      • Size: 1-2 GiB
  10. Configure Compute Resources

    Select appropriate resources:

    • Minimum: 1 CPU, 1 GB RAM (testing/small teams, <10 users)
    • Recommended: 2-4 CPU, 2-4 GB RAM (small teams, 10-50 users)
    • Large: 4-8 CPU, 4-8 GB RAM (medium teams, 50-200 users)
    • Enterprise: 8+ CPU, 8+ GB RAM (large deployments, 200+ users)

    Note: Coder itself is lightweight, but needs resources for provisioning workspaces. Consider the number of concurrent workspace builds.

  11. Deploy

    Click “Create” to start deployment. Klutch.sh will:

    1. Build the Docker image
    2. Start the Coder container
    3. Assign a public URL (e.g., example-app.klutch.sh)
    4. Configure HTTPS automatically
  12. Complete Initial Setup

    After deployment, access your Coder instance:

    1. Navigate to https://example-app.klutch.sh
    2. If you configured CODER_FIRST_USER_* variables, log in with those credentials
    3. Otherwise, create the first admin account through the UI
    4. Immediately change the default password if using first user credentials
    5. Configure authentication settings (OAuth2/OIDC recommended for production)
    6. Set up workspace templates (see next section)
    7. Invite team members or configure SSO
  13. Test Functionality

    Verify all features are working:

    1. Create a test workspace template
    2. Provision a test workspace
    3. Access the workspace via VS Code in browser
    4. Test SSH access (if configured)
    5. Verify workspace auto-start/stop
    6. Test user permissions and access control
    7. Check persistent storage for workspace data
    8. Review logs for any errors

Coder Features and Configuration

1. PostgreSQL Database Setup

Coder requires PostgreSQL for production deployments.

Database Requirements:

  • PostgreSQL 13+ recommended
  • Separate database for Coder (e.g., coder)
  • Dedicated user with full permissions on the database
  • SSL/TLS encryption recommended

Create Database (on your PostgreSQL server):

CREATE DATABASE coder;
CREATE USER coder_user WITH ENCRYPTED PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE coder TO coder_user;

Connection String Format:

postgresql://username:password@host:port/database?sslmode=require

2. Workspace Templates

Templates define how workspaces are provisioned. Coder uses Terraform for this.

Creating a Simple Docker Template:

Create a file docker-template.tf:

terraform {
required_providers {
coder = {
source = "coder/coder"
version = "~> 0.12"
}
docker = {
source = "kreuzwerker/docker"
version = "~> 3.0"
}
}
}
provider "coder" {}
provider "docker" {}
data "coder_workspace" "me" {}
resource "coder_agent" "main" {
os = "linux"
arch = "amd64"
startup_script = <<-EOT
#!/bin/bash
# Install code-server
curl -fsSL https://code-server.dev/install.sh | sh
code-server --auth none --port 13337 >/dev/null 2>&1 &
EOT
}
resource "docker_image" "workspace" {
name = "codercom/enterprise-base:ubuntu"
}
resource "docker_container" "workspace" {
count = data.coder_workspace.me.start_count
image = docker_image.workspace.name
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
env = [
"CODER_AGENT_TOKEN=${coder_agent.main.token}",
]
command = [
"sh", "-c",
<<-EOT
${coder_agent.main.init_script}
sleep infinity
EOT
]
}
resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
slug = "code-server"
display_name = "VS Code"
url = "http://localhost:13337"
icon = "/icon/code.svg"
subdomain = false
share = "owner"
}

Uploading Template:

  1. Go to Templates in Coder UI
  2. Click Create Template
  3. Upload your Terraform files or point to a Git repository
  4. Configure template variables (if any)
  5. Provision a test workspace to validate

3. User Management

Built-in Authentication:

  • Create users manually in the UI
  • Users can change their passwords
  • Admin can disable/enable users

OAuth2/OIDC Integration: Configure via environment variables:

Terminal window
CODER_OIDC_ISSUER_URL=https://your-idp.com
CODER_OIDC_CLIENT_ID=your-client-id
CODER_OIDC_CLIENT_SECRET=your-secret

SCIM Provisioning: For automated user management with identity providers like Okta or Azure AD.

4. Workspace Management

Lifecycle Management:

  • Auto-start: Workspaces start automatically when accessed
  • Auto-stop: Workspaces stop after inactivity (configurable per template)
  • Manual control: Users can start/stop/delete workspaces
  • Scheduled shutdowns: Reduce costs by stopping workspaces during off-hours

Resource Quotas: Admins can set:

  • Maximum number of workspaces per user
  • CPU and memory limits per workspace
  • Storage quotas

5. Access Methods

VS Code in Browser:

  • Built-in code-server integration
  • Full VS Code experience
  • Extensions support
  • Terminal access

SSH Access: Configure SSH on your local machine:

Terminal window
# Add to ~/.ssh/config
Host coder
HostName example-app.klutch.sh
ProxyCommand coder ssh --stdio <workspace-name>
StrictHostKeyChecking no
UserKnownHostsFile /dev/null

Local IDE: Use coder CLI to tunnel connections to local VS Code or JetBrains IDEs.

6. Audit Logging

Coder logs all user actions:

  • Workspace creation/deletion
  • User logins
  • Template modifications
  • Admin actions

Viewing Audit Logs:

  1. Go to Admin > Audit Logs
  2. Filter by user, action, or date
  3. Export logs for compliance

7. Monitoring and Metrics

Coder exposes Prometheus metrics:

  • Workspace counts and states
  • Provisioning durations
  • User sessions
  • API request metrics

Enable Metrics:

Terminal window
CODER_PROMETHEUS_ENABLE=true
CODER_PROMETHEUS_ADDRESS=0.0.0.0:2112

Access metrics at http://example-app.klutch.sh:2112/metrics.

8. CLI Installation

Users can install the Coder CLI to interact with workspaces:

Terminal window
# macOS/Linux
curl -L https://coder.com/install.sh | sh
# Windows (PowerShell)
winget install Coder.Coder
# Login
coder login https://example-app.klutch.sh

Persistent Storage

Coder requires persistent storage for configuration and workspace metadata.

Critical Data Directories

/var/lib/coder/
├── cache/ (Terraform provider cache)
└── provisioner/ (Provisioner logs)
/home/coder/.config/coderv2/
└── (Coder configuration files)

Adding Persistent Volumes

  1. In Klutch.sh dashboard, go to your Coder app
  2. Navigate to Volumes section
  3. Add volume for data:
    • Mount path: /var/lib/coder
    • Size: 5-10 GiB
  4. Add volume for config:
    • Mount path: /home/coder/.config/coderv2
    • Size: 1-2 GiB

Backup Strategy

Database Backup (Most Critical):

Terminal window
# Backup PostgreSQL database
pg_dump -h db.example.com -U coder_user coder | gzip > coder_backup_$(date +%Y%m%d).sql.gz

Configuration Backup:

Terminal window
# Backup Coder configuration
tar -czf coder_config_$(date +%Y%m%d).tar.gz /home/coder/.config/coderv2/

Template Backup: Store templates in Git repositories for version control.


Security Best Practices

1. HTTPS/SSL Enforcement

Klutch.sh automatically provides HTTPS for your web interface. All traffic is encrypted by default.

2. Authentication and Authorization

Production Authentication:

  • Use OAuth2/OIDC with your identity provider (Google, GitHub, Okta, Azure AD)
  • Avoid built-in authentication for large teams
  • Enable MFA on your identity provider

Role-Based Access Control:

  • Owner: Full system access
  • Template Admin: Can manage templates
  • User Manager: Can manage users
  • Member: Can create workspaces from templates

3. Database Security

  • Use strong database passwords
  • Enable SSL/TLS for database connections
  • Restrict database access by IP if possible
  • Regular database backups
  • Monitor database access logs

4. Network Security

Workspace Isolation:

  • Workspaces should not have direct access to each other
  • Use network policies if deploying on Kubernetes
  • Implement egress filtering if needed

API Security:

  • API tokens have expiration times
  • Rotate tokens regularly
  • Audit API access logs

5. Workspace Security

Template Security:

  • Review all Terraform templates before deployment
  • Restrict who can create/modify templates
  • Use trusted base images
  • Implement vulnerability scanning on base images

Resource Limits:

  • Set CPU and memory limits in templates
  • Implement storage quotas
  • Monitor resource usage

6. Audit and Compliance

  • Enable audit logging
  • Regularly review audit logs
  • Export logs to SIEM for compliance
  • Document access patterns

7. Secret Management

For Workspaces:

  • Use Coder’s built-in secrets (Environment variables in templates)
  • Integrate with external secret managers (HashiCorp Vault, AWS Secrets Manager)
  • Never hardcode secrets in templates

Performance Optimization

1. Database Performance

  • Use PostgreSQL connection pooling (pgBouncer)
  • Monitor database query performance
  • Index optimization for large deployments
  • Regular VACUUM and ANALYZE

2. Provisioning Performance

Optimize Template Builds:

  • Use cached Docker images
  • Minimize layers in Dockerfiles
  • Pre-install common tools in base images

Provisioner Settings:

Terminal window
CODER_PROVISIONER_DAEMONS=2 # Number of provisioners
CODER_MAX_PARALLEL_PROVISIONING_OPERATIONS=20

3. Resource Allocation

  • Allocate sufficient resources to Coder server based on team size
  • Monitor CPU and memory usage
  • Scale horizontally for large deployments (multiple Coder instances)

4. Caching

  • Enable Terraform provider caching (automatic in /var/lib/coder/cache)
  • Use Docker layer caching for workspace images
  • Cache frequently used packages in base images

Monitoring and Logging

1. Access Application Logs

View Coder logs through Klutch.sh:

  1. Go to your app in Klutch.sh
  2. Click Logs
  3. Filter by time range and log level
  4. Search for specific errors or events

2. Configure Logging

Configure logging levels:

Terminal window
CODER_VERBOSE=true # Enable verbose logging
CODER_LOG_HUMAN=true # Human-readable logs
CODER_LOG_JSON=false # JSON logs for structured logging

3. Monitor Real-Time Metrics

Track real-time performance:

Metrics to monitor:
- Active workspaces count
- Workspace provisioning duration
- Failed provisioning attempts
- Active user sessions
- API request rates
- Database connection pool usage
- Memory and CPU utilization

4. Health Checks

Coder includes health endpoints:

Terminal window
# Health check
curl -f http://localhost:3000/api/v2/buildinfo
# Detailed health
curl http://localhost:3000/healthz

5. Monitoring Integration

Integrate with monitoring services:

  • Prometheus: Native metrics support
  • Grafana: Visualization dashboards for Coder metrics
  • DataDog: APM and infrastructure monitoring
  • New Relic: Application performance monitoring

Custom Domains

To use a custom domain with your Coder instance:

1. Add Domain in Klutch.sh

In the Klutch.sh dashboard, go to your app settings and add your custom domain (e.g., coder.example.com).

2. Update DNS Configuration

Update your DNS provider:

CNAME: coder.example.com → example-app.klutch.sh

3. Update Environment Variables

Update Coder configuration:

Terminal window
CODER_ACCESS_URL=https://coder.example.com

Redeploy the application to apply changes.

4. Verify DNS Propagation

Check DNS resolution:

Terminal window
nslookup coder.example.com
# or
dig coder.example.com CNAME

Once propagated, your Coder instance will be accessible at your custom domain with automatic HTTPS.


Troubleshooting

Issue 1: Container Won’t Start

Error: Container exits immediately or doesn’t respond

Solutions:

  • Check Docker logs in Klutch.sh dashboard
  • Verify PostgreSQL connection: Test database connectivity
  • Ensure CODER_ACCESS_URL is set correctly
  • Check environment variables are properly configured
  • Verify persistent volumes are mounted
  • Check database exists and user has permissions

Issue 2: Cannot Access Web Interface

Error: 503 Service Unavailable or connection timeout

Solutions:

  • Verify Coder is running: Check container status
  • Verify port 3000 is exposed and traffic is HTTP
  • Check health endpoint: curl http://localhost:3000/healthz
  • Verify DNS resolution
  • Check Coder logs for startup errors
  • Ensure CODER_ACCESS_URL matches your actual URL

Issue 3: Database Connection Failures

Error: “failed to connect to postgres”

Solutions:

  • Verify database credentials are correct
  • Check database host and port are accessible
  • Verify SSL mode matches database configuration
  • Test connection with psql command
  • Check database firewall allows connections
  • Verify database user has necessary permissions
  • Check if database exists

Issue 4: Workspace Provisioning Fails

Error: Workspaces fail to provision

Solutions:

  • Check template Terraform syntax
  • Verify Docker daemon is accessible (if using Docker templates)
  • Check provisioner logs in Coder UI
  • Verify base images are accessible
  • Check resource limits aren’t exceeded
  • Ensure provisioner daemons are running
  • Review audit logs for errors

Issue 5: Slow Workspace Startup

Error: Workspaces take too long to start

Solutions:

  • Use smaller, optimized base images
  • Pre-install common tools in base images
  • Enable Docker layer caching
  • Increase provisioner daemon count
  • Check network connectivity to image registries
  • Monitor Coder server resource usage
  • Optimize startup scripts in templates

Issue 6: Users Can’t Login

Error: Authentication failures

Solutions:

  • Verify OAuth2/OIDC configuration
  • Check redirect URIs match CODER_ACCESS_URL
  • Verify identity provider is accessible
  • Check user exists in Coder database
  • Review audit logs for authentication attempts
  • Verify SSL certificates are valid
  • Check session cookie settings

Issue 7: High Memory Usage

Error: Coder using excessive memory

Solutions:

  • Check number of active workspaces
  • Monitor database connection pool
  • Increase container memory allocation
  • Review provisioner daemon count
  • Check for memory leaks in logs
  • Optimize template provisioning
  • Reduce concurrent provisioning operations

Issue 8: Data Loss After Restart

Error: Configuration or workspaces lost after restart

Solutions:

  • Verify persistent volumes are mounted correctly
  • Check volume mount paths in Klutch.sh
  • Ensure PostgreSQL data is persistent (external database)
  • Verify file permissions on mounted volumes
  • Check disk space in volumes
  • Review backup strategy

Best Practices

1. Template Management

  • Store templates in Git repositories
  • Version control all template changes
  • Test templates in development before production
  • Document template variables and requirements
  • Use semantic versioning for templates
  • Implement template review process
  • Create templates for common development stacks
  • Maintain minimal, focused templates

2. User Management

  • Use SSO/OIDC for production deployments
  • Implement RBAC based on team structure
  • Regular user access audits
  • Disable inactive users
  • Document user provisioning process
  • Enable MFA on identity provider
  • Set appropriate session timeouts
  • Monitor user activity logs

3. Workspace Lifecycle

  • Configure auto-stop for cost optimization
  • Set appropriate inactivity timeouts
  • Implement workspace quotas per user
  • Regular cleanup of old workspaces
  • Monitor workspace resource usage
  • Document workspace policies
  • Educate users on workspace management

4. Security Maintenance

  • Regular security updates for Coder
  • Keep base images up to date
  • Scan images for vulnerabilities
  • Review audit logs regularly
  • Rotate API tokens and secrets
  • Implement network policies
  • Document security procedures
  • Incident response planning

5. Database Maintenance

  • Regular database backups (daily recommended)
  • Test restore procedures quarterly
  • Monitor database performance
  • Implement connection pooling
  • Regular VACUUM and ANALYZE
  • Monitor database growth
  • Document backup procedures
  • Plan for database scaling

6. Performance Tuning

  • Monitor provisioning times
  • Optimize template efficiency
  • Cache frequently used images
  • Tune provisioner daemon count
  • Monitor resource utilization
  • Implement horizontal scaling for large deployments
  • Document performance baselines
  • Regular performance reviews

7. Capacity Planning

  • Monitor user growth trends
  • Plan resource scaling
  • Estimate storage requirements
  • Budget for infrastructure growth
  • Document scaling procedures
  • Test scaling strategies
  • Plan for peak usage periods

8. Documentation

  • Maintain workspace template documentation
  • Document custom configurations
  • Create user guides for developers
  • Document troubleshooting procedures
  • Maintain runbooks for common tasks
  • Document API integrations
  • Keep architecture diagrams updated

9. Disaster Recovery

  • Regular backup testing
  • Document recovery procedures
  • Maintain off-site backups
  • Test failover procedures
  • Document RTO and RPO requirements
  • Maintain backup retention policies
  • Practice disaster recovery scenarios

10. Team Training

  • Onboard new users effectively
  • Provide template creation training
  • Document best practices
  • Regular training sessions
  • Share knowledge base articles
  • Create video tutorials
  • Gather user feedback
  • Continuous improvement

Verifying Your Deployment

After deployment completes:

  1. Check the App URL: Visit https://example-app.klutch.sh
  2. Log In: Use administrator credentials from environment variables or create account
  3. Verify Database Connection: Check that Coder connected to PostgreSQL successfully
  4. Create Test Template: Upload or create a simple workspace template
  5. Provision Test Workspace: Create a workspace from your template
  6. Access Workspace: Open workspace in VS Code browser or SSH
  7. Test Auto-Start/Stop: Verify workspace lifecycle management
  8. Create Test User: Add a user account and verify permissions
  9. Check Persistence: Verify configuration persists after restart
  10. Review Logs: Check Coder logs for errors or warnings

If your Coder instance doesn’t work as expected, review the troubleshooting section and check the Klutch.sh dashboard logs for detailed error messages.


External Resources


Deploying Coder to Klutch.sh using Docker provides a powerful, open-source platform for creating and managing cloud development environments with complete control over your remote development infrastructure. By following this guide, you’ve learned how to create a production-ready Dockerfile with proper initialization, configure persistent storage for configuration and cache data, set up PostgreSQL database connectivity, manage workspace templates with Terraform, configure user authentication with OAuth2/OIDC, implement security best practices for workspace isolation, optimize provisioning performance, configure custom domains, monitor system health and metrics, and troubleshoot common issues. Your Coder instance is now running on Klutch.sh’s global infrastructure with professional-grade hosting, automatic HTTPS, scalable resources, and reliable infrastructure for remote development platform. For additional help or questions, consult the official Coder documentation or contact Klutch.sh support.