Skip to content

Commit 9637068

Browse files
committed
one click components
2 parents eab691b + c1d44ab commit 9637068

23 files changed

+446
-402
lines changed

blog/2024-02-12-announcing-defang-public-beta.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Ever since we shipped our Private Beta in the summer of 2023, we have been worki
1212

1313
And so, today with our Public Beta, we are addressing this request. With today’s release of [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) (Bring-your-own-Cloud), you can now enjoy all the benefits of Defang **and** deploy applications to your own AWS account! Our Private Beta experience is still available as [Defang Playground](https://docs.defang.io/docs/concepts/defang-playground) for you to quickly and easily prototype applications and deploy them to our hosted environment.
1414

15-
You can learn more about Defang [here](https://docs.defang.io/docs/intro). Also check out our [tutorials](https://docs.defang.io/docs/category/tutorials), [samples](https://docs.defang.io/docs/samples), and [FAQ](https://docs.defang.io/docs/category/faq) to know more.
15+
You can learn more about Defang [here](https://docs.defang.io/docs/intro). Also check out our [tutorials](https://docs.defang.io/docs/category/tutorials), [samples](https://defang.io/samples), and [FAQ](https://docs.defang.io/docs/category/faq) to know more.
1616

1717
**Try the Public Beta!**
1818

blog/2024-07-31-july-product-updates-2.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@ Hey folks! We can’t believe a month has gone by already, time flies when you
1111

1212
1. As our user-base grows, we wanted to make sure we’re able to scale our [Playground](https://docs.defang.io/docs/concepts/defang-playground) environment to be able to handle the load. This involved being able to shard the workload across multiple ALBs and being able to dynamically move some workloads across shards where possible. With these changes, we are now able handle a large number of concurrent users comfortably. The only noticeable change in behavior you would see is that Defang will now ask you to “`compose down`” your previous project before you are able to deploy a new project on Playground.
1313

14-
2. The major news this month was the introduction of our “`debug`” functionality. The motivation for this feature was that while the Defang experience is amazing when everything goes smoothly, we saw users (including our own interns who are helping write all those [samples](https://docs.defang.io/docs/samples)) struggle when they hit an error. The underlying reason for the error could come from a variety of sources: an error in the developer’s application (including in their Dockerfile or Compose file), an issue in the way Defang is processing the application, or an issue in the underlying cloud platform (currently, AWS). To the developer, it is often not obvious what the issue is or how to fix it. That got us thinking how we could make this debugging experience “radically simpler” and thus the idea for `defang debug` was born.
15-
14+
2. The major news this month was the introduction of our “`debug`” functionality. The motivation for this feature was that while the Defang experience is amazing when everything goes smoothly, we saw users (including our own interns who are helping write all those [samples](https://defang.io/samples)) struggle when they hit an error. The underlying reason for the error could come from a variety of sources: an error in the developer’s application (including in their Dockerfile or Compose file), an issue in the way Defang is processing the application, or an issue in the underlying cloud platform (currently, AWS). To the developer, it is often not obvious what the issue is or how to fix it. That got us thinking how we could make this debugging experience “radically simpler” and thus the idea for `defang debug` was born.
15+
1616
Now (with CLI v0.5.37 if your application encounters an error that leads to a failed deployment, a failed health-check, or a run-time error, Defang will automatically detect the issue. It will then offer to help you debug it by running the `defang debug` command. If you choose to proceed, Defang will apply an LLM model to try to determine the precise cause of the error, with the context of your application source, logs, error code etc. And it will try to come up with one or more actionable insights on how to fix the error. For an example, see the case below:
17-
18-
19-
17+
18+
19+
2020
Behind the scenes, Defang is having a conversation on your behalf with the LLM to narrow down to the cause of the error. We would love for you to try the `debug` feature and give us your feedback so we can improve it further. One future improvement already on our list is the ability to, with user consent, automatically apply a chosen fix and re-try. We are also looking for way to improve the range of failures we are able to diagnose successfully.
2121

2222
## Townhall
2323

2424
If you're excited about what's coming next and want to hear more about our vision for the future, join us for our Townhall on August 21st. We'll be sharing more about our roadmap and what we're working on next. We'll also be making sure to take time to answer any questions you have, hear your feedback, and learn more about what you want from Defang!
2525

2626
**[Register here](https://lu.ma/rlj13eq5)**
27-
27+
2828
---
2929

3030
We’re excited to keep improving Defang to make it the easiest way for you to Develop, Deploy, and Debug cloud application. Stay tuned for more updates next month.
31-

blog/2024-11-12-hard-lessons-from-hardware.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ Before I let you go, here are the hard lessons from hardware, from yours truly:
6060
4. Choose the simpler way if it is offered.
6161
5. That’s where Defang comes in.
6262

63-
Want to try deploying to the cloud yourself? You can try it out [here](https://defang.io/#samples). Keep on composing up! 💪
63+
Want to try deploying to the cloud yourself? You can try it out [here](https://defang.io/samples). Keep on composing up! 💪

docs/concepts/compose.md

Lines changed: 225 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,247 @@ sidebar_position: 150
66

77
# Compose
88

9-
You might be familiar with `docker-compose.yml` files, now known as the [Compose specification](https://docs.docker.com/compose/compose-file/) and `compose.yaml` files. It's a simple way to define and run multi-container Docker applications. Defang allows you to use `compose.yaml` files to deploy your application to the cloud.
9+
Defang allows you to use `compose.yaml` files to deploy your application to the cloud.
10+
The `compose.yaml` file is a simple way to define and run multi-container applications.
11+
This file format may look familiar to you if you've used [Docker](https://docker.com).
1012

11-
## How it works
13+
The [Compose Specification](https://github.com/compose-spec/compose-spec/blob/main/spec.md#compose-file) lets you define a platform-agnostic application designed as a set of containers which are configured to run together with shared resources. These applications may be destined for any [OCI](https://opencontainers.org/) Container Runtime. Defang does the heavy lifting to deploy to your favourite cloud platform using this file.
1214

13-
You can define your [services](./services.md) using a `compose.yaml` file in the root of your project, or use the [`defang generate` command](../tutorials/generate-new-code-using-ai.mdx) to generate one (along with other resources). This file is used to define your application's services and how they run. You can edit this file to add more services or change the configuration of existing services.
15+
## How It Works
16+
17+
You can create a `compose.yaml` file in the root of your project, or use the [`defang generate`](../tutorials/generate-new-code-using-ai.mdx) command to create one for you (along with other resources). This file is used to define your application's [services](./services.md) and how they run. You can edit this file to add more services or change the configuration of services.
1418

1519
When you run `defang compose up`, Defang will read your `compose.yaml` file and [deploy](./deployments.md) the services named in that file to the cloud.
1620

17-
## Service Name Resolution
21+
## Example of a Compose File
22+
Here is a basic `compose.yaml` file that contains all the required properties for deployment in Defang.
23+
24+
```yaml
25+
services:
26+
service-example:
27+
image: nginx:latest # use one of: image (shown on this line) or build (shown below)
28+
# build:
29+
# context: .
30+
# dockerfile: Dockerfile
31+
ports:
32+
- mode: ingress # specify ports to expose
33+
target: 8080
34+
published: 8080 # this is useful for running locally
35+
36+
```
1837
19-
One thing to keep in mind is that, at the time of this writing, Defang identifies services by the [user/account name](./accounts.md) and the service name (as defined in the `compose.yaml` file). This means that if you have multiple Defang projects with the same service name, they will conflict with each other. We plan to provide a more robust system for managing service names and protecting against conflicts in the future.
38+
## Compose Top-level Properties
39+
Here are a list of top-level properties of the [Compose specification](https://docs.docker.com/compose/compose-file/) that Defang supports when writing a `compose.yaml` file.
2040

21-
## Configuration
41+
### `services`
42+
(Required)
2243

23-
If you have a service that depends on a [config value](./configuration.md) (such as an API key), you can set it using the CLI:
44+
The services defined in your application.
2445

46+
```yaml
47+
services:
48+
service:
49+
# add service-level properties here
2550
```
26-
defang config set MY_API_KEY
51+
52+
:::info
53+
Defang identifies a service based on your username, project name, and the service name you've defined under the `services` property. See our [Services](/docs/concepts/services) page for more about how Defang resolves service names.
54+
:::
55+
56+
### `networks`
57+
(Optional)
58+
59+
The networks defined in your application. This is commonly added together with a [service-level `networks`](#networks-1) property.
60+
61+
```yaml
62+
networks:
63+
public:
2764
```
2865

29-
and then connect it to the service by specifying it in the `compose.yaml`:
66+
See our [Networking](/docs/concepts/networking) page for more.
67+
68+
### `volumes`
69+
(Not yet supported)
70+
71+
The volume mounts for a container, reusable across services. This feature is not currently supported by Defang.
72+
73+
```yaml
74+
# volumes:
75+
# db-data:
76+
```
77+
78+
:::warning
79+
Defang does not support the `secrets` top-level property. Please read our [Configuration](/docs/concepts/configuration) page for more.
80+
:::
81+
82+
## Compose Service-level Properties
83+
Here are a list of service-level properties of the [Compose specification](https://docs.docker.com/compose/compose-file/) that Defang supports when writing a `compose.yaml` file.
84+
85+
:::tip
86+
Service-level means inside your `service`. A service-level property called `build` would look like:
87+
```yaml
88+
service:
89+
build: ...
90+
```
3091

92+
Note that in your Compose file, you will need a top-level property called `services` to contain all of your services. For example:
3193
```yaml
3294
services:
33-
my-service:
34-
environment:
35-
- MY_API_KEY
95+
service:
96+
build: ...
97+
```
98+
:::
99+
100+
### `build`
101+
(Required, unless `image` is defined)
102+
103+
The [build configuration](https://github.com/compose-spec/compose-spec/blob/main/build.md). This property describes how to create an OCI container for this service.
104+
105+
```yaml
106+
build:
107+
context: .
108+
dockerfile: ./Dockerfile
109+
```
110+
111+
### `image`
112+
(Required, unless `build` is defined)
113+
114+
[This property](https://github.com/compose-spec/compose-spec/blob/main/05-services.md#image) describes the image from which your container should start.
115+
116+
```yaml
117+
image: nginx:latest
118+
```
119+
120+
### `ports`
121+
(Optional, but required if you want to access the service from outside the container)
122+
123+
The ports to expose. The default port mode is `ingress`.
124+
125+
```yaml
126+
ports:
127+
- mode: ingress
128+
target: 80
129+
published: 80
130+
```
131+
132+
:::info
133+
Defang ignores `published` ports in production. As such, it is common to make `target` and `published` ports the same when using Defang. However, it can be useful to include a `published` port for local development, such as Docker.
134+
:::
135+
136+
### `command`
137+
(Optional)
138+
139+
The command which will be run to start your service. If left out, the command from the Docker image will be used.
140+
141+
```yaml
142+
command: nginx -g 'daemon off;'
143+
```
144+
145+
### `deploy`
146+
(Optional)
147+
148+
The [Deploy Specification](https://github.com/compose-spec/compose-spec/blob/main/deploy.md) describes the runtime constraints and requirements for how your services will be deployed and managed across different environments (e.g. memory reservations, replicas, number of CPUs, etc.).
149+
150+
```yaml
151+
deploy:
152+
replicas: 1
153+
reservations:
154+
cpus: '0.5'
155+
memory: 256M
156+
```
157+
158+
### `depends_on`
159+
(Not yet supported)
160+
161+
This property describes startup dependencies between services. This feature is currently unsupported by Defang, but can be useful in local developments such as Docker.
162+
163+
```yaml
164+
# depends_on:
165+
# - db
36166
```
37167

168+
### `environment`
169+
(Optional)
170+
171+
The environment variables to set.
172+
```yaml
173+
environment:
174+
DATABASE_USER: someuser
175+
```
38176
:::info
39-
Read more about configuration in the [Configuration page](./configuration.md).
177+
For sensitive environment variables (or secret values), you should list the variable's name with a blank or `null` value, and then securely set their actual value with `defang config` in the CLI. See our [Configuration page](/docs/concepts/configuration) for more.
178+
179+
For example:
180+
```yaml
181+
- DATABASE_USER=someuser # env var loaded with this literal value
182+
- DATABASE_PASSWORD # env var loaded using defang config
183+
```
40184
:::
185+
186+
### `healthcheck`
187+
(Optional, but required for healthchecks on services with a published port)
188+
189+
[This property](https://github.com/compose-spec/compose-spec/blob/main/05-services.md#healthcheck) describes a check that will be run to determine whether or not a service's containers are "healthy". It works in the same way, and has the same default values, as the [HEALTHCHECK Dockerfile instruction](https://docs.docker.com/engine/reference/builder/#healthcheck) set by the service's Docker image. Your Compose file can override the values set in the Dockerfile.
190+
191+
When using Defang, your Compose file must have a healthcheck if you want to expose an `ingress` port—even if your Dockerfile already contains one.
192+
193+
:::note
194+
`curl` is commonly used for containers with an Ubuntu-based image, and `wget` is used for containers with an `alpine`-based image.
195+
:::
196+
197+
```yaml
198+
healthcheck:
199+
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
200+
interval: 30s
201+
timeout: 90s
202+
retries: 3
203+
```
204+
205+
or
206+
207+
```yaml
208+
healthcheck:
209+
test: ["CMD", "wget", "--spider", "http://localhost:8080/"]
210+
interval: 30s
211+
timeout: 90s
212+
retries: 3
213+
```
214+
215+
### `networks`
216+
(Optional)
217+
218+
The network configuration. Can be `public`, where Defang will assign a public IP address, or `private`, in which Defang will not. To avoid warnings, add this to the [top-level `networks`](#networks) property as well.
219+
220+
```yaml
221+
networks:
222+
public:
223+
```
224+
225+
You can also assign an alias for a network by using `aliases`, as seen below:
226+
```yaml
227+
networks:
228+
public:
229+
aliases:
230+
- app
231+
```
232+
233+
See our [Networking](/docs/concepts/networking) page for more.
234+
235+
### `restart`
236+
(Optional, but highly recommended)
237+
238+
The restart mode for a container. Defaults to `unless-stopped` unless otherwise specified.
239+
240+
```yaml
241+
restart: unless-stopped
242+
```
243+
244+
### `volumes`
245+
(Not yet supported)
246+
247+
The volume mounts for a container, specific to a service. This feature is not currently supported by Defang.
248+
249+
```yaml
250+
# volumes:
251+
# - "./backend:/app"
252+
```

docs/concepts/configuration.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ defang config set API_KEY
1919

2020
You can use sensitive config by specifying them in the `environment` section of a service in a `compose.yaml` file without any value, or by specifying an environment key with a `null` value in your Pulumi code.
2121

22+
Either one of list notation or map notation is acceptable for defining your environment variable(s). See below for an example of each.
23+
24+
#### With List Notation
2225
```yaml
2326
services:
2427
service1:
@@ -27,9 +30,7 @@ services:
2730
- API_KEY
2831
```
2932
30-
You can also use this syntax:
31-
32-
33+
#### With Map Notation
3334
```yaml
3435
services:
3536
service1:
@@ -45,7 +46,7 @@ You can find a sample of how to set sensitive config values [here](https://githu
4546
:::
4647

4748
:::info
48-
Note that 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.
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).
4950
:::
5051

5152
## Interpolation

docs/concepts/domains.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ https://<username>-<service-name>--<port>.defang.dev
3030
If you're using [Defang BYOC](./defang-byoc.md), your domain will be:
3131

3232
```
33-
https://<service-name>--<port>.<username>.defang.app
33+
https://<service-name>--<port>.<project-name>.<username>.defang.app
3434
```
3535
</TabItem>
3636
</Tabs>

0 commit comments

Comments
 (0)