Deployment
Deploy your application to production on the LegionEdge Platform
The LegionEdge Platform supports multiple deployment strategies with built-in CI/CD integration, environment promotion, and rollback capabilities.
Deployment Targets
The platform supports deploying to these targets:
- LegionEdge Managed -- Fully managed infrastructure powered by Foltrac.
- Self-Hosted -- Deploy to your own infrastructure with the LegionEdge agent.
- Hybrid -- Mix of managed and self-hosted resources.
Creating a Deployment
Via SDK
import { LegionEdge } from "@legionedge/sdk";
const client = new LegionEdge({ apiKey: process.env.LEGIONEDGE_API_KEY! });
const deployment = await client.deployments.create({
projectId: "proj_abc123",
environment: "staging",
source: {
type: "git",
repository: "https://github.com/acme/my-app",
branch: "main",
commit: "a1b2c3d4",
},
config: {
instances: 2,
memory: "512Mi",
cpu: "0.5",
envVars: {
NODE_ENV: "production",
DATABASE_URL: "{{secrets.DATABASE_URL}}",
},
},
});
console.log(`Deployment ${deployment.id} - Status: ${deployment.status}`);Via CLI
npx legionedge deploy --project proj_abc123 --env stagingEnvironment Promotion
Promote a deployment from one environment to another without rebuilding:
const promotion = await client.deployments.promote({
deploymentId: "deploy_abc123",
targetEnvironment: "production",
overrides: {
instances: 4,
envVars: {
NODE_ENV: "production",
},
},
});
console.log(`Promoted to production: ${promotion.id}`);Deployment Status
Track deployment progress:
const status = await client.deployments.get("deploy_abc123");
console.log(`Status: ${status.status}`); // building | deploying | running | failed
console.log(`Started: ${status.startedAt}`);
console.log(`Duration: ${status.duration}s`);
// Stream deployment logs
const logs = client.deployments.streamLogs("deploy_abc123");
for await (const line of logs) {
console.log(line);
}Rollback
Roll back to a previous deployment:
// List recent deployments
const deployments = await client.deployments.list({
projectId: "proj_abc123",
environment: "production",
perPage: 5,
});
// Rollback to the previous deployment
const rollback = await client.deployments.rollback({
projectId: "proj_abc123",
environment: "production",
targetDeploymentId: deployments.data[1].id,
});
console.log(`Rolled back to ${rollback.targetDeploymentId}`);CI/CD Integration
Add deployment to your CI/CD pipeline with a GitHub Actions example:
# .github/workflows/deploy.yml
name: Deploy to LegionEdge
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: legionedge/deploy-action@v2
with:
api-key: ${{ secrets.LEGIONEDGE_API_KEY }}
project-id: proj_abc123
environment: productionHealth Checks
Configure health checks for automatic rollback on failure:
const deployment = await client.deployments.create({
projectId: "proj_abc123",
environment: "production",
healthCheck: {
path: "/health",
interval: 30,
timeout: 5,
healthyThreshold: 3,
unhealthyThreshold: 2,
},
rollbackOnFailure: true,
});Next Steps
- Set up CI/CD pipelines for automated deployments.
- Follow best practices for production deployments.
- Optimize performance of your deployed applications.