defang-tool
A comprehensive utility for engineering secure software artifacts and managing deployment lifecycles. It streamlines dependency refreshment, standardized formatting, and version control implementation, facilitating highly reliable continuous integration pipelines.
Author

DefangLabs
Quick Info
Actions
Tags
Develop Locally, Operate Globally.
Transition your application from a local Compose setup to a robust, protected, and scalable environment on your chosen hyperscaler within moments.
Defang Command Line Interface
The Defang Terminal Utility (CLI) is engineered for practitioners who favor direct interaction via the command shell. It grants complete programmatic access to Defang's feature set, enabling rapid construction, validation, and provisioning of applications to the cloud infrastructure.
Defang Model Context Protocol (MCP) Listener
The Defang Model Context Protocol (MCP) Broker service is optimized for developers whose primary workspace is within integrated coding environments (IDEs). This component enables fluid provisioning to the cloud directly from supported editors like Cursor, Windsurf, VS Code, VS Code Insiders, and Claude, offering a deeply integrated operational experience.
Repository Contents:
- Public distributions of the Defang CLI; locate the most recent iteration here.
- Integrated support for the MCP Listener — the Defang MCP Listener simplifies cloud deployment to a single directive. Further details
- Reference Samples in Go, Python, and Node.js demonstrating task execution and deployment to the DOP utilizing a Docker Compose manifest via the Defang CLI.
- Examples illustrating deployment using the Defang Pulumi Integration Module.
Initial Setup Guidance
- Consult our comprehensive Getting Started guide.
- Adhere to the instructions detailed on the Installation reference page.
- Examine the Samples directory for template projects across various programming languages.
- Engage the Artificial Intelligence augmentation by executing:
defang generate - Initialize your novel service with:
defang compose up
Installation Procedures
Install the Defang CLI utilizing one of the following methods:
- Employing the Homebrew package management system via the DefangLabs/defang repository:
brew install DefangLabs/defang/defang
- Via a direct shell invocation script:
eval "$(curl -fsSL s.defang.io/install)"
- Utilizing the Go toolchain:
go install github.com/DefangLabs/defang/src/cmd/cli@latest
-
Leveraging the Nix package manager:
-
When using Nix-Env:
nix-env -if https://github.com/DefangLabs/defang/archive/main.tar.gz
-
Or, with Flakes:
nix profile install github:DefangLabs/defang#defang-bin --refresh
-
Via the winget utility:
winget install defang
- Executing a PowerShell script:
iwr https://s.defang.io/defang_win_amd64.zip -OutFile defang.zip Expand-Archive defang.zip . -Force
- Retrieving the official container image from Docker Hub:
docker run -it defangio/defang-cli help
- Or, manually download the most current binary release.
Assistance
- Submit any discovered defects or inquiries here.
Shell Argument Completion
The Defang CLI incorporates argument completion features for Bash, Zsh, Fish, and Powershell. Obtain the requisite shell script by running:
defang completion [bash|zsh|fish|powershell]
For Bash integration, append the following line to your ~/.bashrc file:
source <(defang completion bash)
For Zsh users, integrate this into your ~/.zshrc file:
source <(defang completion zsh)
Alternatively, redirect the output to a file named _defang within your completions directory.
For Fish shell configuration within ~/.config/fish/config.fish:
defang completion fish | source
For Powershell profiles ($HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1):
Invoke-Expression -Command (defang completion powershell | Out-String)
Runtime Configuration Variables
The Defang CLI recognizes the following environment variables for operational tuning:
COMPOSE_PROJECT_NAME- Designates the project identifier; supersedes the value within thecompose.yamlconfiguration.DEFANG_ACCESS_TOKEN- The credential key for API access; defaults to the token obtained viadefang login.DEFANG_BUILD_CONTEXT_LIMIT- Sets the maximum allowable size for container image build contexts; defaults to100MiB.DEFANG_CD_BUCKET- Specifies the target S3 repository for the Bring-Your-Own-Cloud (BYOC) Continuous Deployment process; default isdefang-cd-bucket-….DEFANG_CD_IMAGE- The container image utilized by the Continuous Deployment (CD) workflow; defaults topublic.ecr.aws/defang-io/cd:public-beta.DEFANG_DEBUG- Setting this to1ortrueactivates verbose logging output.DEFANG_DISABLE_ANALYTICS- If set totrue, prevents telemetry data transmission to Defang; default isfalse.DEFANG_EDITOR- The preferred application launched post-project scaffolding; defaults tocode(VS Code).DEFANG_FABRIC- The network endpoint address for the Defang Fabric service; defaults tofabric-prod1.defang.dev.DEFANG_JSON- When set totrue, mandates JSON formatting for all terminal outputs; default isfalse.DEFANG_HIDE_HINTS- If set totrue, suppresses advisory messages displayed in the CLI; default isfalse.DEFANG_HIDE_UPDATE- If set totrue, suppresses notifications regarding new tool versions; default isfalse.DEFANG_ISSUER- The OAuth2 identity provider URL utilized for authentication; defaults tohttps://auth.defang.io.DEFANG_MODEL_ID- The specific identifier for the Large Language Model employed for AI-assisted generation/debugging (Pro subscription feature).DEFANG_NO_CACHE- Iftrue, bypasses the pull-through mechanism for cached container images; default isfalse.DEFANG_ORG- The tenancy identifier utilized; defaults to the user's GitHub account name.DEFANG_PREFIX- A standardized string prepended to all BYOC provisioned cloud resources; defaults toDefang.DEFANG_PROVIDER- Defines the target cloud vendor for provisioning:auto(inferred, default),aws,digitalocean,gcp, ordefang.DEFANG_PULUMI_BACKEND- The URL for the Pulumi state backend or the string"pulumi-cloud"; defaults to an internally hosted backend.DEFANG_PULUMI_DIR- Specifies the directory from which Pulumi operations should execute, bypassing remote task spawning (BYOC context only, requires--debug).DEFANG_PULUMI_VERSION- Allows overriding the specific image version used for the Pulumi provider (AWS provider interactions only).NO_COLOR- Setting this variable to any value disables chromatic output in the terminal; color is enabled by default based on TTY detection.PULUMI_ACCESS_TOKEN- The requisite token for authenticating against the Pulumi Cloud service; consultDEFANG_PULUMI_BACKENDdocumentation.PULUMI_CONFIG_PASSPHRASE- The secret phrase employed to generate unique cryptographic keys for stack configuration and encrypted state.TZ- Specifies the system timezone for log timestamps using an IANA name (e.g.,UTCorEurope/Amsterdam); defaults to the host system's local time.XDG_STATE_HOME- The designated location for persistent application state files; defaults to~/.local/state.
Configuration settings specified in a .defangrc file within the current working directory will be loaded, adhering to the .env format (KEY=VALUE pairs, lines starting with # are ignored as comments).
Development Setup
Defang developers leverage the Nix package manager in conjunction with DirEnv for standardized local environments.
To swiftly initialize the environment, install Nix and DirEnv, then create a .envrc file to autoload the required development context:
sh echo use flake >> .envrc direnv allow
WIKIPEDIA: Cloud computing is defined by ISO as "a paradigm for enabling network access to a scalable and elastic pool of shareable physical or virtual resources with self-service provisioning and administration on-demand." This concept is commonly referred to as "the cloud".
== Defining Attributes == In 2011, the U.S. National Institute of Standards and Technology (NIST) established five 'essential characteristics' for cloud architectures. These precise definitions are:
On-demand self-service: "A consumer can unilaterally provision computing capabilities, such as server time and network storage, as needed automatically without requiring human interaction with each service provider." Broad network access: "Capabilities are available over the network and accessed through standard mechanisms that promote use by heterogeneous thin or thick client platforms (e.g., mobile phones, tablets, laptops, and workstations)." Resource pooling: " The provider's computing resources are pooled to serve multiple consumers using a multi-tenant model, with different physical and virtual resources dynamically assigned and reassigned according to consumer demand." Rapid elasticity: "Capabilities can be elastically provisioned and released, in some cases automatically, to scale rapidly outward and inward commensurate with demand. To the consumer, the capabilities available for provisioning often appear unlimited and can be appropriated in any quantity at any time." Measured service: "Cloud systems automatically control and optimize resource use by leveraging a metering capability at some level of abstraction appropriate to the type of service (e.g., storage, processing, bandwidth, and active user accounts). Resource usage can be monitored, controlled, and reported, providing transparency for both the provider and consumer of the utilized service. By 2023, the International Organization for Standardization (ISO) had subsequently revised and expanded this delineation.
== Historical Antecedents ==
The foundational concepts underpinning cloud infrastructure trace back to the 1960s, specifically through the adoption of time-sharing systems facilitated by remote job entry (RJE). During this period, the prevailing operational model involved users submitting computational tasks to system operators for execution on large mainframe computers (the 'data center' paradigm). This era was characterized by intensive research into methods for democratizing access to substantial computational capacity via time-sharing, maximizing infrastructure utilization, refining platforms and applications, and boosting end-user productivity. The adoption of the 'cloud' visual metaphor for abstracted, virtualized services originated in 1994. General Magic employed it to describe the conceptual domain accessible by mobile software agents within their Telescript environment. This graphical representation is generally attributed to David Hoffman, a communications specialist at General Magic, drawing on its established usage in network topology diagrams. The term 'cloud computing' gained broader recognition in 1996 when Compaq Computer Corporation drafted a strategic business blueprint for future internet-centric computing, articulating ambitions to supercharge...

