Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1f2c25f
clear config explanation
Dec 23, 2024
dad7e65
started outlining possible compose page outline
Dec 23, 2024
e67d4d6
alternative layout as a list, not a table
commit111 Jan 3, 2025
668a4e0
fixes for what is required
commit111 Jan 4, 2025
27226b6
update ports property
commit111 Jan 4, 2025
88cc6b5
add top level property heading
commit111 Jan 4, 2025
f33e5f9
add healthcheck
commit111 Jan 4, 2025
74685d8
adjust examples
commit111 Jan 6, 2025
41dd1f9
fix typo
commit111 Jan 6, 2025
39917f9
add more properties
commit111 Jan 6, 2025
10f37b9
update compose support
commit111 Jan 7, 2025
234db8c
update environment
commit111 Jan 7, 2025
77e1296
update healthcheck
commit111 Jan 7, 2025
836ac63
remove tip
commit111 Jan 7, 2025
22ff2bb
move compose support to compose page
commit111 Jan 7, 2025
4220181
edit description
commit111 Jan 8, 2025
57f642a
move service name resolution
commit111 Jan 8, 2025
2faa8d9
add service name resolution from compose to services page
commit111 Jan 8, 2025
c2796f3
Merge branch 'main' into linda-compose-support
commit111 Jan 8, 2025
793e617
Apply suggestions from code review
commit111 Jan 8, 2025
f37f4d0
Update docs/concepts/compose.md
commit111 Jan 8, 2025
dbda400
fix grammar
commit111 Jan 8, 2025
e9f884b
Merge branch 'linda-compose-support' of https://github.com/DefangLabs…
commit111 Jan 8, 2025
6dd6d01
improve config section
commit111 Jan 14, 2025
0b01183
Apply suggestions from code review
commit111 Jan 14, 2025
d7e6289
Apply suggestions from code review
commit111 Jan 15, 2025
856397b
Update docs/concepts/compose.md
commit111 Jan 15, 2025
dd9f070
move required properties above, and improve services tip
commit111 Jan 16, 2025
b66216a
improve services page according to compose tip
commit111 Jan 16, 2025
7e602ce
fix domain example for services
commit111 Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions docs/concepts/compose-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
title: Compose Support
description: Defang supports many of the properties of the Compose specification.
sidebar_position: 160
---

# Compose Support

## Required Compose File
Here is a basic `compose.yaml` file that contains all the required properties for deployment in Defang.

```yaml
services:
service-example:
restart: unless-stopped # specify a restart mode
image: nginx:latest # specify an image (or a build, as shown below)
# build:
# context: .
# dockerfile: Dockerfile
ports:
- "8080:80" # specify ports to expose

```

## Compose Service Properties
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.

:::tip
Service-level means inside your `service`. A service-level property called `build` would look like:
```yaml
service:
build: ...
```

Note that in your Compose file, you will need a top-level property called `services` to contain all of your services. For example:
```yaml
services:
service:
build: ...
another-service:
build: ...
```
:::

### `build`
(Required, unless `image` is defined)

The build configuration.

```yaml
build:
context: .
dockerfile: ./Dockerfile
```

### `command`
(Optional)

The command which will be run to start your service. If left out, the command from the docker image will be used.

```yaml
command: nginx -g 'daemon off;'
```

### `environment`
(Optional)

The environment variables to set.

```yaml
environment:
MYSQL_ROOT_PASSWORD: example
```

### `image`
(Required, unless `build` is defined)

The image to run.

```yaml
image: nginx:latest
```

### `ports`
(Optional, but required if you want to access the service from outside the container)

The ports to expose. Can be formatted as `"published:target"`.

```yaml
ports:
- "8080:80"
```

Alternatively, you can use this notation:
```yaml
ports:
- target: 80
published: 8080
mode: ingress
```

:::info
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.
:::

### `restart`
(Required)

The restart mode for a container.

```yaml
restart: unless-stopped
```

### `version`
(Deprecated)

The version of the Compose file format being used. This feature is no longer supported and will be ignored by Defang.

### `volumes`
(Unsupported)

The volume for a container. This feature is not currently supported by Defang.


### Configuration
You can define sensitive environment variables/configuration for Defang by writing out the variable name and leaving it in as a blank or `null` value in the Compose file. See our [Configuration](/docs/concepts/configuration) page for more.
7 changes: 4 additions & 3 deletions docs/concepts/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ defang config set API_KEY

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.

Either one of list notation or map notation is acceptable for defining your environment variable(s). See below for an example of each.

#### With List Notation
```yaml
services:
service1:
Expand All @@ -27,9 +30,7 @@ services:
- API_KEY
```

You can also use this syntax:


#### With Map Notation
```yaml
services:
service1:
Expand Down
Loading