Prerequisites
Before you begin, make sure you have:- HopX API key - Get one from console.hopx.dev or see [API key Management](/API key)
- Understanding of templates - Familiarity with Listing Templates is helpful
- Base image or template - Decide on a base image (Python, Node.js, Ubuntu, etc.)
- Dependencies list - Know what packages or tools you want pre-installed
Overview
Building templates enables you to:- Pre-install packages and dependencies
- Configure environment variables
- Set up working directories and users
- Create reusable sandbox configurations
- Optimize sandbox creation time
Template building is an async operation that can take several minutes. The build process includes uploading files, executing build steps, and waiting for template activation.
Basic Template Building
Create a simple template from a base image:- Python
- JavaScript
Using Base Image Helpers
Use convenient base image helpers:- Python
- JavaScript
Complete Template Example
Build a complete template with multiple steps:- Python
- JavaScript
Build Options
Configure build options:- Python
- JavaScript
Build Result and Logs
Access build results and logs:- Python
- JavaScript
Best Practices
1
1. Start with Base Images
Use base image helpers (from_python_image, from_node_image) for common environments.
2
2. Chain Operations
Use fluent API to chain operations for readable template definitions.
3
3. Set Resources Appropriately
Configure CPU, memory, and disk based on your application needs.
4
4. Use Ready Checks
Set ready checks for services that need to be ready before sandbox is usable.
5
5. Monitor Build Progress
Use progress and log callbacks to monitor long-running builds.
Related
- Listing Templates - List available templates
- Getting Template Details - View template information
- Template Configuration - Configure template resources and steps
- API: POST /v1/templates/build - Control Plane API endpoint
- CLI Template Commands - Template management from CLI
Next Steps
- Learn about Template Configuration for advanced setup
- Explore Template Caching for build optimization
- Review Listing Templates to see your built templates

