Skip to main content

Defang with Codespaces and GitPod

This tutorial will guide you to set up Defang in both Codespaces and Gitpod.

Getting Started with Github Codespaces and Defang

Step 1: Clone the Defang Codespace Project

Start by cloning the Defang Github-Codespace repo and pushing it to your own account. This repository is configured with a Codespace that has Defang pre-installed.

Step 2: Create a Codespace

Once you've pushed to your own GitHub repo, you'll be able to create a Codespace by clicking the Code button, selecting the Codespaces tab, and clicking the + icon. This will set up a development environment with Defang already installed, which might take a few minutes.

Create Codespace button screenshot

Step 3: Open in VS Code Desktop

For the defang login command to work correctly, you must open the Codespace in VS Code desktop. This is required because the login process is designed to run on localhost.

Open in vs code desktop button screenshot

Step 4: Run Defang Login

Within a VS Code desktop terminal, execute the following command.

defang login

Although it may initially refuse to connect on your localhost, going back will show a "successfully logged in" message, confirming that you're logged into Defang.

Step 5: Verify Running Services

Now that you're logged in, you can use Defang commands. You can test that everything is working properly by running defang ls to list your running services.

Getting Started with GitPod Workspace with Defang

Step 1: Clone the Defang GitPod Workspace Project

Start by cloning the Defang Gitpod-Workspace repo and pushing it to your own GitHub, GitLab, or BitBucket account. This repository includes a Workspace configuration that pre-installs Defang.

Step 2: Initialize GitPod Workspace

Navigate https://gitpod.io/#<your-repo-url> to create your new workspace. In the repository, we have a yaml file indicating that we are using a pre-built dockerfile which installs Defang CLI for you.

Step 3: Lauch VS Code from GitPod

Open VS Code from GitPod, you will likely need to have the GitPod VS Code extension installed.

Open in vs code desktop button screenshot

Screenshot of GitPod extension

Step 4: Run Defang Login

Within a VS Code desktop terminal, execute the following command.

defang login

Step 5: Verify Running Services

Now that you're logged in, you can use Defang commands. You can test that everything is working properly by running defang ls to list your running services.