Deployment Management
This document explains how to deploy, update, stop, and restart services using Composia.
Deployment Flow
1. Service Discovery
The Controller periodically scans repo_dir for directories containing composia-meta.yaml:
repo/
├── service-a/
│ ├── composia-meta.yaml ← Discovered
│ └── docker-compose.yaml
├── service-b/
│ ├── composia-meta.yaml ← Discovered
│ └── docker-compose.yaml
└── README.md2. Instance Generation
Each Service generates corresponding ServiceInstances based on the nodes configuration:
# service-a/composia-meta.yaml
name: service-a
nodes:
- main
- edgeGenerates:
service-aonmainservice-aonedge
3. Trigger Deployment
When a user triggers deployment via Web UI or API:
- Controller validates the service definition
- Creates
deploytasks for each target node - Agent retrieves tasks and executes
- Downloads service bundle (including Compose files and configuration)
- Renders runtime directory
- Executes
docker compose up -d - Triggers Caddy sync if
network.caddyis configured - Reports execution result
Available Operations
Deploy
First-time deployment of a service to a node.
Use Cases:
- Initial deployment of a new service
- First deployment after loading service from Git repository
Behavior:
- Downloads service bundle
- Renders runtime directory
- Executes
docker compose up -d - Triggers Caddy sync (if
network.caddyis configured)
Update
Update an already deployed service.
Use Cases:
- Updated
docker-compose.yaml - Updated image version
- Updated environment variables
Behavior:
- Pulls latest bundle
- Re-renders runtime directory
- Executes
docker compose up -d(automatically handles changes) - Triggers Caddy reload
Notes:
- Compose automatically determines which containers need rebuilding
- Data volumes are preserved
- Environment variable changes trigger rebuild
Stop
Stop a service instance.
Use Cases:
- Temporarily taking a service offline
- Freeing node resources
- Preparing for service migration
Behavior:
- Executes
docker compose down - Removes generated Caddy fragment
- Triggers Caddy reload
Notes:
- Data volumes are preserved (unless using
down -v) - Containers are removed
- Service definition remains in Git repository
Restart
Restart a service instance.
Use Cases:
- Application configuration changes requiring restart
- Temporary issues like memory leaks
Behavior:
- Stops and starts sequentially
- Does not re-pull bundle (use Update if needed)
Using the Web UI
Deploy a Service
- Navigate to the Services page
- Click on the target service
- Find the target node in the Instances tab
- Click the Deploy button
Batch Operations
On the Services list page, you can perform batch operations on multiple services:
- Batch deploy
- Batch update
- Batch stop
View Deployment Status
During deployment, you can view progress in real-time on the Tasks page:
| Status | Description |
|---|---|
| Pending | Waiting for Agent to pull |
| Running | Currently executing |
| Success | Execution successful |
| Failed | Execution failed |
| Cancelled | Cancelled |
Using the API
Deploy Service
curl -X POST http://localhost:7001/api/v1/services/my-service/deploy \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"nodes": ["main", "edge"]
}'Update Service
curl -X POST http://localhost:7001/api/v1/services/my-service/update \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"nodes": ["main"]
}'Stop Service
curl -X POST http://localhost:7001/api/v1/services/my-service/stop \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"nodes": ["main"]
}'Restart Service
curl -X POST http://localhost:7001/api/v1/services/my-service/restart \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"nodes": ["main"]
}'Multi-Node Deployment Strategies
Same Service on Multiple Nodes
# composia-meta.yaml
name: my-app
nodes:
- main
- edge-1
- edge-2Creates instances on all three nodes after deployment.
Environment Separation
# my-app-prod/composia-meta.yaml
name: my-app-prod
nodes:
- main
---
# my-app-staging/composia-meta.yaml
name: my-app-staging
nodes:
- edge-1Rolling Updates
Currently Composia executes updates on all target nodes simultaneously. For rolling updates:
- First update
nodesconfiguration, removing some nodes - Wait for update to complete
- Re-add the nodes
- Update again
Deployment Best Practices
1. Use Health Checks
# docker-compose.yaml
services:
app:
image: myapp:latest
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s2. Configure Restart Policy
services:
app:
image: myapp:latest
restart: unless-stopped3. Resource Limits
services:
app:
image: myapp:latest
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M4. Environment Separation
Use different service names to distinguish environments:
# Production
name: my-app-prod
project_name: my-app-prod
# Staging
name: my-app-staging
project_name: my-app-staging5. Version Control
Specify explicit versions in image tags:
services:
app:
image: myapp:1.2.3 # Explicit version
# Avoid using latestTroubleshooting
Deployment Failed
Check task logs:
- Navigate to the Tasks page
- Find the failed deployment task
- View detailed logs
Common issues:
- Image pull failure: Check image name and network
- Port conflict: Check port usage
- Missing environment variables: Check
.envfile
Container Won't Start
On the Containers page:
- Find the target container
- View logs
- Check environment variables and volume mounts
Caddy Configuration Not Applied
Check:
- Is
network.caddy.enabledset totrue? - Is
Caddyfile.fragmentpath correct? - Is Caddy infrastructure service running?
Related Documentation
- Service Definition — How to define services
- Operations — Understanding task execution
- Networking — Configure reverse proxy