Kit applications compile to a single, self-contained binary that includes everything needed to run your application: web server, migrations, and scheduler.
Single Binary Architecture
Your Kit application builds to one binary with multiple commands:
This architecture simplifies deployment:
- One Docker image for all services
- Same binary for web server and scheduler
- Migrations run automatically on startup
Building for Production
Generate Dockerfile
This creates a multi-stage Dockerfile optimized for production:
- Frontend build - Compiles React/TypeScript assets
- Backend build - Compiles Rust with release optimizations
- Runtime - Minimal Debian image with only runtime dependencies
Build the Image
Test Locally
Environment Variables
Configure your application with these environment variables:
Example .env.production
Never commit .env.production to version control. Add it to your .gitignore.
Migrations
By default, the web server runs migrations automatically on startup. This ensures your database schema is always up to date.
Behavior
- Default (
./app): Runs migrations silently, then starts server
- Explicit (
./app serve): Same as default
- Skip migrations (
./app serve --no-migrate): Start server without migrations
- Migrations only (
./app migrate): Run migrations and exit
In Production
For most deployments, the default auto-migrate behavior is ideal:
If you need to run migrations separately (e.g., in a CI/CD pipeline):
Running the Scheduler
If your application has scheduled tasks, run the scheduler as a separate process:
The scheduler will:
- Check for due tasks every minute
- Run tasks in the background
- Log task execution and errors
Deployment Pattern
Most platforms support running multiple services from the same Docker image:
- Web service:
./app (default command)
- Scheduler service:
./app schedule:work
Both services use the same image and environment variables.
Health Checks
Kit includes a built-in /_kit/health endpoint that returns JSON status information. The /_kit prefix ensures it never conflicts with your application routes.
Response:
Database Health Check
Add ?db=true to verify database connectivity:
Response:
Configure your platform’s health check to:
- Path:
/_kit/health
- Port: 8080 (or
SERVER_PORT)
- Protocol: HTTP
Scaling
Horizontal Scaling (Web)
Scale your web servers horizontally by running multiple instances behind a load balancer. Each instance:
- Runs auto-migrations on startup (safe with multiple instances)
- Serves HTTP requests independently
- Shares the same database
Scheduler
Run only one scheduler instance to avoid duplicate task execution. Most platforms support marking a service as a “worker” that only runs one instance.
Next Steps
Choose your deployment platform: