You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blog/2025-03-26-deploying-defang-with-defang-part-2.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,14 +45,14 @@ Some things we had to change:
45
45
```yaml
46
46
domainname: defang.io
47
47
networks:
48
-
public:
48
+
default:
49
49
aliases:
50
50
- www.defang.io
51
51
```
52
52
53
53
One other hiccup was that we used to do www to non-www redirects using S3. There are a few ways to switch that up, but for the time being we decided to use Next.js middleware.
54
54
55
-
Pretty soon after that, the site was up and running in an AWS account—with TLS, DNS, and both the `www` and root domains automatically configured. Pretty straightfoward!
55
+
Pretty soon after that, the site was up and running in an AWS account—with TLS, DNS, and both the `www` and root domains automatically configured. Pretty straightfoward!
Copy file name to clipboardExpand all lines: docs/concepts/compose.md
+62-63Lines changed: 62 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,8 @@ sidebar_position: 150
6
6
7
7
# Compose
8
8
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.
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
11
This file format may look familiar to you if you've used [Docker](https://docker.com).
12
12
13
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.
@@ -19,20 +19,19 @@ You can create a `compose.yaml` file in the root of your project, or use the [`d
19
19
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.
20
20
21
21
## Example of a Compose File
22
-
Here is a basic `compose.yaml` file that contains all the required properties for deployment in Defang.
22
+
Here is a basic `compose.yaml` file that contains all the required properties for deployment in Defang.
23
23
24
24
```yaml
25
25
services:
26
26
service-example:
27
27
image: nginx:latest # use one of: image (shown on this line) or build (shown below)
28
-
# build:
28
+
# build:
29
29
# context: .
30
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
-
31
+
ports:
32
+
- mode: ingress # specify ports to expose
33
+
target: 8080
34
+
published: 8080# this is useful for running locally
36
35
```
37
36
38
37
## Compose Top-level Properties
@@ -41,26 +40,26 @@ Here are a list of top-level properties of the [Compose specification](https://d
41
40
### `services`
42
41
(Required)
43
42
44
-
The services defined in your application.
43
+
The services defined in your application.
45
44
46
45
```yaml
47
46
services:
48
47
service:
49
48
# add service-level properties here
50
49
```
51
50
52
-
:::info
51
+
:::info
53
52
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
53
:::
55
54
56
55
### `networks`
57
56
(Optional)
58
57
59
-
The networks defined in your application. This is commonly added together with a [service-level `networks`](#networks-1) property.
58
+
The networks defined in your application. This is commonly added together with a [service-level `networks`](#networks-1) property.
60
59
61
60
```yaml
62
61
networks:
63
-
public:
62
+
default: # the "default" network is always created even if not specified
64
63
```
65
64
66
65
See our [Networking](/docs/concepts/networking) page for more.
@@ -76,7 +75,7 @@ The volume mounts for a container, reusable across services. This feature is not
76
75
```
77
76
78
77
:::warning
79
-
Defang does not support the `secrets` top-level property. Please read our [Configuration](/docs/concepts/configuration) page for more.
78
+
Defang does not support the `secrets` top-level property. Please read our [Configuration](/docs/concepts/configuration) page for more.
80
79
:::
81
80
82
81
## Compose Service-level Properties
@@ -86,14 +85,14 @@ Here are a list of service-level properties of the [Compose specification](https
86
85
Service-level means inside your `service`. A service-level property called `build` would look like:
87
86
```yaml
88
87
service:
89
-
build: ...
88
+
build: ...
90
89
```
91
90
92
91
Note that in your Compose file, you will need a top-level property called `services` to contain all of your services. For example:
93
92
```yaml
94
93
services:
95
-
service:
96
-
build: ...
94
+
service:
95
+
build: ...
97
96
```
98
97
:::
99
98
@@ -103,9 +102,9 @@ services:
103
102
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
103
105
104
```yaml
106
-
build:
107
-
context: .
108
-
dockerfile: ./Dockerfile
105
+
build:
106
+
context: .
107
+
dockerfile: ./Dockerfile
109
108
```
110
109
111
110
### `image`
@@ -114,7 +113,7 @@ build:
114
113
[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
114
116
115
```yaml
117
-
image: nginx:latest
116
+
image: nginx:latest
118
117
```
119
118
120
119
### `ports`
@@ -123,23 +122,23 @@ image: nginx:latest
123
122
The ports to expose. The default port mode is `ingress`.
124
123
125
124
```yaml
126
-
ports:
127
-
- mode: ingress
128
-
target: 80
129
-
published: 80
125
+
ports:
126
+
- mode: ingress
127
+
target: 80
128
+
published: 80
130
129
```
131
130
132
131
:::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.
132
+
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
133
:::
135
134
136
135
### `command`
137
136
(Optional)
138
137
139
-
The command which will be run to start your service. If left out, the command from the Docker image will be used.
138
+
The command which will be run to start your service. If left out, the command from the Docker image will be used.
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
148
150
149
```yaml
151
-
deploy:
152
-
replicas: 1
153
-
reservations:
154
-
cpus: '0.5'
155
-
memory: 256M
150
+
deploy:
151
+
replicas: 1
152
+
reservations:
153
+
cpus: '0.5'
154
+
memory: 256M
156
155
```
157
156
158
157
### `depends_on`
159
158
(Not yet supported)
160
159
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.
160
+
This property describes startup dependencies between services. This feature currently has limited supported by Defang, but can be useful in local development with Docker.
162
161
163
162
```yaml
164
-
# depends_on:
165
-
# - db
163
+
# depends_on:
164
+
# - db
166
165
```
167
166
168
167
### `environment`
169
168
(Optional)
170
169
171
170
The environment variables to set.
172
171
```yaml
173
-
environment:
174
-
DATABASE_USER: someuser
172
+
environment:
173
+
DATABASE_USER: someuser
175
174
```
176
175
:::info
177
176
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
-
177
+
179
178
For example:
180
179
```yaml
181
180
- DATABASE_USER=someuser # env var loaded with this literal value
@@ -191,54 +190,54 @@ For sensitive environment variables (or secret values), you should list the vari
191
190
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
191
193
192
:::note
194
-
`curl`is commonly used for containers with an Ubuntu-based image, and `wget` is used for containers with an `alpine`-based image.
193
+
`curl`is commonly used for containers with an Ubuntu-based image, and `wget` is used for containers with an `alpine`-based image.
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.
217
+
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
218
220
219
```yaml
221
-
networks:
222
-
public:
220
+
networks:
221
+
default: # when not specified, services are assigned to the default network
223
222
```
224
223
225
224
You can also assign an alias for a network by using `aliases`, as seen below:
226
225
```yaml
227
-
networks:
228
-
public:
229
-
aliases:
230
-
- app
226
+
networks:
227
+
default:
228
+
aliases:
229
+
- app
231
230
```
232
-
231
+
233
232
See our [Networking](/docs/concepts/networking) page for more.
234
-
233
+
235
234
### `restart`
236
235
(Optional, but highly recommended)
237
236
238
-
The restart mode for a container. Defaults to `unless-stopped` unless otherwise specified.
237
+
The restart mode for a container. Defaults to `unless-stopped` unless otherwise specified.
239
238
240
239
```yaml
241
-
restart: unless-stopped
240
+
restart: unless-stopped
242
241
```
243
242
244
243
### `volumes`
@@ -247,6 +246,6 @@ restart: unless-stopped
247
246
The volume mounts for a container, specific to a service. This feature is not currently supported by Defang.
0 commit comments