Go package Discord GitHub Release

Defang

Develop Once, Deploy Anywhere.

Take your app from Compose to a secure and scalable deployment on your favorite cloud in minutes.

How It Works

flowchart LR

subgraph local["Your Machine or CI/CD"]
    compose["compose.yaml"] --> cli["Defang CLI"]
end

subgraph defang["Defang Backend"]
    fabric["Fabric API (gRPC)"]
end

subgraph cloud["Your Cloud Account"]
    secrets["Config & Secrets"]
    cd["Defang CD Task"]
    logs["Logs"]
    runtime["Load Balancer, Containers, DB, Cache, LLM, DNS, Roles"]
end

%% control plane
cli <-.-> fabric

%% deploy
cli --> secrets
cli --> cd
cd --> runtime

%% observability
cli -.-> logs
  1. You write a standard Docker Compose file
  2. Defang CLI validates your Compose project and uploads the project to storage in your AWS/GCP account
  3. CD runs in your cloud — a deployment task spins up in your AWS/GCP account
  4. Infrastructure is created — containers, DNS, load balancing, and roles are provisioned
  5. Monitor the deployment and tail or query runtime logs with the Defang CLI

Your code and secrets never leave your cloud account. Defang orchestrates the deployment, but everything runs in your infrastructure.

Defang CLI

The Defang Command-Line Interface (CLI) is designed for developers who prefer to manage their workflows directly from the terminal. It offers full access to Defang’s capabilities, allowing you to build, test, and deploy applications efficiently to the cloud.

Deploying with Defang

If you already have a Docker Compose file, create a new stack and then deploy it. For example:

$ defang stack new
? Which cloud provider do you want to deploy to? AWS
? Which AWS region do you want to deploy to? us-west-2
? Which deployment mode do you want to use? AFFORDABLE
? What do you want to call this stack? awsuswest2
 * Created new stack configuration file: `.defang/awsuswest2`. Check this file into version control. You can now deploy this stack using `defang up --stack=awsuswest2`

$ defang up --stack=awsuswest2

Defang MCP Server

Install in VS Code Install in VS Code Insiders Install MCP Server Add to Kiro

The Defang Model Context Protocol (MCP) Server is tailored for developers who work primarily within integrated development environments (IDEs). It enables seamless cloud deployment from supported editors such as Cursor, Windsurf, VS Code, VS Code Insiders and Claude delivering a fully integrated experience without leaving your development environment.

Claude Code Plugin

Install the Defang plugin for Claude Code to deploy directly from any Claude Code session — no CLI required upfront:

/plugin marketplace add DefangLabs/defang
/plugin install defang@defang-skills

After installing, use /defang:deploy to guide you through deploying your project. The Defang MCP server activates automatically once the Defang CLI is installed.

This repo includes:

Getting started

Installing

Install the Defang CLI from one of the following sources:

Support

Command completion

The Defang CLI supports command completion for Bash, Zsh, Fish, and Powershell. To get the shell script for command completion, run the following command:

defang completion [bash|zsh|fish|powershell]

If you're using Bash, you can add the following to your ~/.bashrc file:

source <(defang completion bash)

If you're using Zsh, you can add the following to your ~/.zshrc file:

source <(defang completion zsh)

or pipe the output to a file called _defang in the directory with the completions.

If you're using Fish, you can add the following to your ~/.config/fish/config.fish file:

defang completion fish | source

If you're using Powershell, you can add the following to your $HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 file:

Invoke-Expression -Command (defang completion powershell | Out-String)

Environment Variables

The Defang CLI recognizes the following environment variables:

Environment variables will be loaded from a .defang file in the current directory, if it exists. This file follows the same format as a .env file: KEY=VALUE pairs on each line, lines starting with # are treated as comments and ignored.

Development

At Defang we use the Nix package manager for our dev environment, in conjunction with DirEnv.

To get started quickly, install Nix and DirEnv, then create a .envrc file to automatically load the Defang developer environment:

echo use flake >> .envrc
direnv allow

Adding cloud support

At a high-level, support for a specific cloud lives in three repositories: