Skip to content

Commit d397e2e

Browse files
authored
Merge pull request #160 from DefangLabs/linda-one-click-deploy
Added 1-Click Deploy tutorial
2 parents 307815d + f053446 commit d397e2e

File tree

10 files changed

+147
-1
lines changed

10 files changed

+147
-1
lines changed

docs/concepts/configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ Use the `defang config` command of the Defang CLI to manage the values.
4545
You can find a sample of how to set sensitive config values [here](https://github.com/DefangLabs/samples/tree/main/samples/nodejs-openai).
4646
:::
4747

48+
:::info
49+
If you are using the [1-Click Deploy](/docs/tutorials/using-one-click-deploy) option, you can set sensitive config values as secrets in your GitHub repository and the action will automatically deploy them for you. [Learn how to manage config values with the Defang Github Action](https://github.com/DefangLabs/defang-github-action?tab=readme-ov-file#managing-config-values).
50+
:::
51+
4852
## Interpolation
4953

5054
Environment variables are set within the `environment` section of a service in a `compose.yaml` file. Any variables declared here will become available within the service container.

docs/providers/playground.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: The Defang Playground is a free tier that allows you to experiment
44
sidebar_position: 0000
55
---
66

7-
The Defang Playground is a free tier that allows you to experiment with Defang. The Playground is a shared environment that should not be used to run production workloads. The Playground is a great way to get started with Defang using "1-click deploy" or to experiment with the Defang CLI.
7+
The Defang Playground is a free deployment provider that allows you to experiment with Defang. The Playground is a shared environment that should not be used to run production workloads. The Playground is a great way to get started with Defang. You can even use [1-Click Deploy](/docs/tutorials/using-one-click-deploy) to try it out quickly or you can get started with the [Defang CLI](/docs/getting-started).
88

99
This page highlights architectural considerations when deploying to the Playground and any differences you might encounter when deploying to the Playground versus deploying to your own cloud account.
1010

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: Adding Custom 1-Click Deploy to Your App
3+
sidebar_position: 800
4+
description: Add a custom 1-Click Deploy link to deploy your own app.
5+
---
6+
7+
# Adding Custom 1-Click Deploy to Your App
8+
9+
This tutorial will show you how to add a 1-Click Deploy link to deploy your app to the Defang Playground. A 1-Click Deploy link points to a special Defang URL. Clicking this link will trigger a deployment of a project to Defang. The link is often placed as a button in the `README.md` file of your project repository, and is the easiest way to allow anyone to deploy your app.
10+
11+
:::info
12+
If you are trying to use 1-Click Deploy with one of our [samples](https://defang.io/samples/), we have a separate tutorial on [how to use 1-Click Deploy](/docs/tutorials/using-one-click-deploy).
13+
:::
14+
15+
## Pre-requisites
16+
17+
- A [GitHub](https://github.com/) repository for your project
18+
19+
## Step 1 - Prepare Your App
20+
21+
You will need a `compose.yaml` file in the root folder of your project to describe the services which will be deployed. Learn more about writing [Compose files](/docs/concepts/compose#example-of-a-compose-file).
22+
23+
## Step 2 - Copy the GitHub Workflow
24+
25+
In your project, add a new folder named `.github`, then add a folder `workflows` inside it, and copy the entire GitHub Workflow `deploy.yaml` file from [here](https://github.com/DefangLabs/samples/blob/main/starter-sample/.github/workflows/deploy.yaml) into the `workflows` folder.
26+
27+
If your app requires [configuration](/docs/concepts/configuration) (e.g. API keys, passwords, etc.), learn more about [managing config variables with the Defang GitHub Action](https://github.com/DefangLabs/defang-github-action).
28+
29+
You should have a `.yaml` file similar to the one below:
30+
```yaml
31+
name: Deploy
32+
33+
on:
34+
push:
35+
branches:
36+
- main
37+
38+
jobs:
39+
deploy:
40+
environment: playground
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: read
44+
id-token: write
45+
46+
steps:
47+
- name: Checkout Repo
48+
uses: actions/checkout@v4
49+
50+
- name: Deploy
51+
uses: DefangLabs/[email protected]
52+
```
53+
54+
## Step 3 - Get the Encoded URL
55+
56+
You will need the encoded version of your project repository's URL. This will be used as a redirect for the 1-Click Deploy link.
57+
58+
1. Copy the URL of your repository's homepage. It should look something like the following:
59+
```
60+
https://github.com/<your-github-username>/<your-repo-name>
61+
```
62+
2. You can go online and paste the URL from the step above into a URL encoder tool of your choice. You should end up with an encoded URL, similar to the one shown below:
63+
64+
```
65+
https%3A%2F%2Fgithub.com%2F<your-github-username>%2F<your-repo-name>
66+
```
67+
68+
## Step 4 - Create the 1-Click Deploy Link
69+
70+
You will need to create a 1-Click Deploy link with the following format: `https://portal.defang.dev/redirect?url=` + your encoded URL. This ensures that the user can get [logged in](/docs/concepts/authentication/) to Defang before they get redirected to clone your app for deployment.
71+
72+
:::tip
73+
Optionally, you can add `&name=<your-project-here>` to the end of the link if you'd like to suggest a name for the user to use for their deployment.
74+
:::
75+
76+
The finished link should look similar to the one below:
77+
```
78+
https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2F<your-github-username>%2F<your-project-here>&name=<your-project-here>
79+
```
80+
81+
Now you have a link for anyone to deploy your app to Defang, with just 1 click.
82+
83+
## Step 5 - Use the Link
84+
For example, you can add it as a link in a Markdown file:
85+
```
86+
[1-Click Deploy Link](https://portal.defang.dev/redirect?url=<your-encoded-url>&name=<your-project-here>)
87+
```
88+
Or perhaps you can add it to a button with your own styling:
89+
```
90+
[![1-click-deploy-button](https://defang.io/deploy-with-defang.png)](https://portal.defang.dev/redirect?url=<your-encoded-url>&name=<your-project-here>)
91+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Using 1-Click Deploy
3+
sidebar_position: 300
4+
description: Use 1-Click Deploy to easily deploy a sample to the Defang Playground.
5+
---
6+
7+
# Using 1-Click Deploy
8+
9+
This tutorial will show you how to use Defang 1-Click Deploy to deploy a sample to the Defang Playground.
10+
11+
The 1-Click Deploy button is the easiest way for new users to deploy a sample project to the [Defang Playground](/docs/concepts/defang-playground). No CLI installation is required.
12+
13+
:::info
14+
To access the full range of features provided by Defang, we recommend using the [Defang CLI](/docs/getting-started).
15+
:::
16+
17+
## Step 1 - Choose a Sample
18+
Head to our [list of samples](https://defang.io/#samples) and click a sample you want to deploy. Then, click on the button that says "1-Click Deploy".
19+
20+
![one-click-deploy-button](/img/use-one-click-tutorial/one-click-deploy-button.png)
21+
22+
:::info
23+
Alternatively, you can find the "1-Click Deploy" button located in the `README.md` file of each sample's GitHub repository.
24+
25+
![deploy-with-defang-button](/img/use-one-click-tutorial/deploy-with-defang-button.png)
26+
:::
27+
28+
## Step 2 - Allow Permissions
29+
30+
After you've clicked, you will be prompted to use GitHub to log in. Once you see a "Create a new repository" page appear, allow the sample repository to get cloned into your GitHub account. You can do this by clicking the green "Create repository" button at the bottom.
31+
32+
![create-repository](/img/use-one-click-tutorial/create-repository.png)
33+
34+
## Step 3 - Wait for Deployment to Complete
35+
36+
A Github Action workflow will automatically start running to install Defang and deploy the sample to the Defang Playground. You can see this by going into the "Actions" tab in your GitHub repository.
37+
38+
You can view the status of your deployment in the [Defang Portal](https://portal.defang.dev/), or by downloading the [Defang CLI](/docs/getting-started).
39+
40+
:::tip
41+
If you decide to make a commit later to a repository created from 1-Click Deploy, then the project will automatically get deployed again to Defang Playground.
42+
:::
43+
44+
When it is completed, you can view your deployed app using the deployment link generated by Defang, which should appear similar to the format below:
45+
```
46+
https://<username>-<service-name>--<port>.defang.dev
47+
```
48+
49+
### Configuration in 1-Click Deploy
50+
51+
If the sample you chose requires setting configuration, such as API keys, you can set sensitive config values as secrets in your GitHub repository and the GitHub Action can automatically handle those values for you. [Learn how to manage config values with the Defang Github Action](https://github.com/DefangLabs/defang-github-action?tab=readme-ov-file#managing-config-values).
109 KB
Loading
61.8 KB
Loading
61.2 KB
Loading
60.2 KB
Loading
51 KB
Loading
26.7 KB
Loading

0 commit comments

Comments
 (0)