Deployment Flow
Lightfold uses a composable, idempotent deployment architecture where each step is independent and can be run standalone or orchestrated together.Orchestrated Deployment
Thelightfold deploy command chains all steps automatically:
1
Framework Detection
Analyzes project structure to identify framework and package manager.Supports 15+ frameworks including Next.js, Django, Rails, Laravel, and more.
2
Infrastructure Creation
Creates server infrastructure if not already created.
- Auto-provision mode: Creates VM on cloud provider (DigitalOcean, Vultr, Hetzner)
- BYOS mode: Validates SSH access to existing server
3
Server Configuration
Configures server if not already configured.
- Installs runtime dependencies
- Sets up systemd services
- Configures nginx reverse proxy
- Creates deployment directory structure
/etc/lightfold/configured marker on server.4
Code Deployment
Deploys code changes using blue/green deployment.
- Checks git commit vs. last deployed commit
- Creates timestamped release:
/srv/<app>/releases/<timestamp>/ - Uploads tarball and builds project
- Swaps symlink
/srv/<app>/currentwith health checks - Auto-rollback on failure
Manual Steps
You can run each step independently for granular control:Idempotency
Lightfold is designed to be safe to rerun. Each step checks state before executing.State Tracking
Local State (~/.lightfold/state/<target>.json):
/etc/lightfold/created- Written by create command/etc/lightfold/configured- Written by configure command
Smart Skipping
Commands automatically skip completed steps:create- Skips if already createdconfigure- Skips if/etc/lightfold/configuredexistspush- Skips if git commit unchangeddeploy- Skips all completed steps
--force to override and rerun steps.
Builder System
Lightfold supports multiple build strategies:Native Builder
Traditional approach using framework detection + nginx.- Uses framework-specific build commands
- Serves static files with nginx
- Runs app with systemd service
Nixpacks Builder
Railway’s Nixpacks for auto-detected builds.- Auto-detects runtime and dependencies
- Generates optimized Docker container
- No Dockerfile required
Dockerfile Builder
Uses your existing Dockerfile (coming soon).Auto-Selection
Lightfold automatically selects the best builder:- If Dockerfile exists →
dockerfile - If Node/Python + nixpacks available →
nixpacks - Otherwise →
native
--builder flag:
Blue/Green Deployment
Lightfold uses blue/green deployment for zero-downtime releases:1
Create new release
Creates timestamped directory:
/srv/<app>/releases/20251003103000/2
Build application
Uploads code, installs dependencies, runs build commands.
3
Health check
Starts new release and runs health checks.
4
Swap symlink
Atomically updates
/srv/<app>/current symlink to new release.5
Cleanup
Keeps last 5 releases, removes older ones.
Rollback
Instant rollback to previous release:Custom Domains & SSL
Add custom domain with automatic Let’s Encrypt SSL:- Prompts for SSL enable (default: yes)
- Installs certbot if needed
- Issues Let’s Encrypt certificate
- Configures nginx with domain + HTTPS
- Sets up auto-renewal
- Updates target config
State Recovery
If local state gets corrupted or server IP changes, use sync:- Recovers server IP from provider API
- Verifies SSH connectivity
- Syncs remote markers (
created,configured) - Updates deployment info (current release, git commit)
- Checks service status
Environment Variables
Set environment variables in config:.env file in project root (automatically loaded).
Multi-Target Deployments
Deploy the same project to multiple environments:Deployment Tips
First deployment is slow
First deployment is slow
First deployment installs all dependencies and configures the server. Subsequent deployments are much faster due to idempotency.
Force reconfiguration
Force reconfiguration
Use
--force to rerun steps:View deployment logs
View deployment logs
Check application logs:
Check server status
Check server status
View detailed status:
SSH into server
SSH into server
Access server directly: