Skip to main content
Optimized environments start in 1-3 minutes. Without optimization, startup can take 10+ minutes. This page covers the strategies that close that gap.

Optimization strategies

Use prebuilds

Prebuilds run your environment setup ahead of time: container builds, dependency installation, and startup tasks. When an environment starts, it loads from a prebuild snapshot instead of running setup from scratch. This is the single biggest optimization. Configure prebuilds to run on pushes to main and your environments will be ready when agents need them.

Enable Dev Container image caching

For runners in your VPC, enable image caching to avoid rebuilding containers:
  • AWS runners: Caches built Dev Container images automatically
  • GCP runners: Supports image caching through Artifact Registry
Ona Cloud includes image caching by default.

Optimize your Dockerfile

Structure your Dockerfile for caching efficiency:
  • Put stable dependencies first: System packages, build tools, and runtimes that rarely change should be early in the Dockerfile.
  • Put volatile dependencies last: Application dependencies that change frequently go at the end.
  • Use prebuilt base images: Push your base image to a registry and reference it in devcontainer.json.

Use tasks for dynamic setup

For setup that must happen at runtime (database seeding, environment-specific config), use Tasks rather than baking everything into the image.

Use one environment per task

Create a fresh environment for each piece of work rather than reusing environments across tasks. This matches how agents operate:
  1. Agent receives a task
  2. Agent starts a clean environment
  3. Agent completes the work and creates a PR
  4. Environment is discarded
This isolation gives you:
  • No state conflicts: Each task gets a clean slate
  • Parallel execution: Multiple agents work simultaneously without interference
  • Mistakes are free: If something goes wrong, discard the environment and start fresh
With the optimizations above, startup stays under a few minutes.

Measure startup time

Track these metrics to identify bottlenecks:
  • Container build time: How long does the Dev Container image take to build?
  • Dependency installation: How long do startup tasks take to run?
  • Prebuild freshness: Are prebuilds running often enough to stay current?
If environments take more than 3 minutes to start, check your prebuild configuration first.