---
title: "Application Deployments"
description: "Deploy Docker applications, manage immutable revisions, promote changes between environments, perform Blue/Green releases, and roll back failed deployments without requiring Kubernetes."
---

> Documentation Index
> Fetch the complete documentation index at: https://flarelens.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Application Deployments

Deploy Docker applications, manage immutable revisions, promote changes between environments, perform zero-downtime Blue/Green releases, and roll back failed deployments without requiring Kubernetes.

## Immutable Revisions (Zero-Git or GitOps)

Every create, edit, delete, promotion, or CI sync writes an immutable revision (`rev-1`, `rev-2`, …) to D1 (`fleet_revisions`) and archives a SHA-256 verified full-fleet snapshot in R2 (`state/revisions/rev-N.json`).

- **Dashboard-First (Zero-Git)**: Define, clone, edit, and deploy services directly from the FlareLens UI using structured forms or the built-in JSON manifest editor.
- **Pre-Staged Services (`enabled: false`)**: Commit production manifests in a `Suspended` state so operators can audit ports, domains, secrets, and cgroup budgets before cutover day—tagged CI releases update the recorded image without starting containers prematurely.
- **Optional Keyless GitOps**: Synchronize repository manifests from GitHub Actions using short-lived OIDC tokens (`id-token: write`).

## 7-Step Zero-Downtime Blue/Green Pipeline

When rolling out a `blue_green` service, `flarelensd` runs a deterministic 7-step state machine on each assigned host:

1. **Pre-Deploy Database Guardrail**

   When `pre_deploy_snapshot: true` or `run_migrations: true` is configured, streams a compressed `pg_dump` archive directly to Cloudflare R2 before touching database schemas.
2. **Authenticated OCI Image Pull**

   Pulls the target image tag or `@sha256` digest using ephemeral registry credentials kept strictly in memory.
3. **Ephemeral Schema Migration Container**

   Executes `migration_command` inside a one-shot container attached to the internal network; aborts cutover and triggers snapshot recovery on non-zero exit.
4. **Candidate Slot Boot**

   Starts the inactive slot (`-green` while `-blue` serves live traffic) with decrypted Vault env vars, `/dev/shm` secret files, and kernel cgroup caps.
5. **HTTP Readiness Verification**

   Probes `health_path` on `internal_port` until consecutive `200 OK` responses confirm application health.
6. **Atomic \<1ms Traefik Swap**

   Atomically updates the dynamic Traefik upstream route (including multi-domain `Host(...)` rules and cross-node `remote_upstreams`) so new traffic shifts in under a millisecond.
7. **Graceful Connection Drain & Cleanup**

   Allows in-flight requests on the retiring slot to complete cleanly before stopping the old container and scheduling debounced image pruning.

## Environment Promotion & 1-Click Rollback

Promote verified UAT container digests and runtime settings to `prod` in one click while preserving production domains, replica counts, volumes, and environment-scoped Vault secrets:

```bash title="Promote UAT release to Prod via HTTP API"
curl -X POST https://ops.example.com/api/v1/control/fleet/promote \
  -H "Authorization: Bearer $FLARELENS_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"source_env":"uat","target_env":"prod","services":["checkout-api"]}'
```

If error rates climb after a release, selecting **Rollback** on any historical `rev-N` snapshot restores exact image digests, environment variables, and even deleted service definitions in a single atomic revision.

## Scheduled CronJobs & One-Off Container Jobs

Declare recurring `CronJob` schedules or on-demand maintenance commands directly inside a service manifest under `jobs:`. The Cloudflare Control Plane evaluates 5-field UTC cron expressions every minute (enforcing single-execution slot keys and `concurrency_policy: forbid`) while `flarelensd` executes the job inside an isolated ephemeral container (`--rm` semantics) on your host node with hard cgroup caps, decrypted Vault secrets, and private `*.mesh` DNS:

```yaml title="Declarative CronJobs & One-Off Jobs"
service: checkout-api
env: prod
image: ghcr.io/example/checkout-api:1.4.2
jobs:
  - name: nightly-reconcile
    schedule: "0 2 * * *"
    command: ["/app/checkout", "jobs", "reconcile"]
    concurrency_policy: forbid
    timeout_seconds: 900
    memory_mb: 512
    cpu_cores: 0.5
  - name: backfill-invoices
    command: ["/app/checkout", "jobs", "backfill"]
    timeout_seconds: 1800
```

Trigger any declared job—or an ad-hoc one-off command—from the **Fleet GitOps** dashboard or over HTTP:

```bash title="Trigger an ephemeral one-off container job"
curl -X POST https://ops.example.com/api/v1/control/jobs/run \
  -H "Authorization: Bearer $FLARELENS_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"env":"prod","service":"checkout-api","job_name":"backfill-invoices"}'
```

Source: https://flarelens.dev/docs/deployments/index.mdx
