Skip to content

Commit f855897

Browse files
authored
Merge pull request #367 from bozau/v4.x
2 parents e3d4538 + dff667a commit f855897

File tree

8 files changed

+72
-176
lines changed

8 files changed

+72
-176
lines changed

docs/builds/packs/docker-compose.md

Lines changed: 4 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -98,142 +98,11 @@ Then you can connect from `backend` to `auth` by referring to it as `http://auth
9898

9999
For further details, please refer to the [Docker Networking in Compose](https://docs.docker.com/compose/how-tos/networking/) docs.
100100

101-
102101
## Advanced Configuration
103102

104-
### Defining Environment Variables
105-
106-
Coolify automatically detects environment variables mentioned in your compose file and displays them in the UI. For example:
107-
108-
```yaml
109-
services:
110-
myservice:
111-
environment:
112-
- SOME_HARDCODED_VALUE=hello # Passed to the container, but not visible in Coolify's UI.
113-
- SOME_VARIABLE=${SOME_VARIABLE_IN_COOLIFY_UI} # Creates an editable, uninitialized variable in the UI.
114-
- SOME_DEFAULT_VARIABLE=${OTHER_NAME_IN_COOLIFY:-hello} # Sets a default value "hello" that can be edited.
115-
```
116-
117-
<ZoomableImage src="/docs/images/builds/packs/compose/6.webp" alt="Coolify dashboard screenshot" />
118-
119-
### Required Environment Variables
120-
121-
You can mark environment variables as required using the `:?` syntax. Required variables must be set before deployment and will be highlighted in Coolify's UI with a red border if empty.
122-
123-
```yaml
124-
services:
125-
myapp:
126-
environment:
127-
# Required variables - deployment will fail if not set
128-
- DATABASE_URL=${DATABASE_URL:?}
129-
- API_KEY=${API_KEY:?}
130-
131-
# Required variables with default values - prefilled in UI but can be changed
132-
- PORT=${PORT:?3000}
133-
- LOG_LEVEL=${LOG_LEVEL:?info}
134-
135-
# Optional variables - standard behavior
136-
- DEBUG=${DEBUG:-false}
137-
- CACHE_TTL=${CACHE_TTL:-3600}
138-
```
139-
140-
**Key behaviors:**
141-
142-
- **Required variables** (`${VAR:?}`) appear first in the environment variables list and show a red border when empty
143-
- **Required with defaults** (`${VAR:?default}`) are prefilled with the default value but remain editable
144-
- **Optional variables** (`${VAR:-default}`) use standard Docker Compose behavior
145-
146-
If a required variable is not set during deployment:
147-
148-
- Coolify will highlight the missing variable in the UI
149-
- The deployment will be prevented until all required variables are provided
150-
- Clear error messages guide users to fix the configuration
103+
### Using Environment and Shared Variables
151104

152-
This validation happens before container creation, preventing partial deployments and runtime failures.
153-
154-
### Coolify's Magic Environment Variables
155-
156-
Coolify can generate dynamic environment variables for you using the following syntax: `SERVICE_<TYPE>_<IDENTIFIER>`.
157-
158-
::: warning HEADS UP!
159-
Support for Magic Environment Variables in Compose files based on Git sources has been added in Coolify v4.0.0-beta.411
160-
:::
161-
162-
The types include:
163-
164-
| **Variables** | **Generated Value Type** |
165-
| -------------------------------------- | -------------------------------------------------- |
166-
| **PASSWORD** | Random Password (No Symbols) |
167-
| **PASSWORD\_64** | Random Password (No Symbols, 64 characters) |
168-
| **PASSWORDWITHSYMBOLS** | Random Password (With Symbols) |
169-
| **PASSWORDWITHSYMBOLS\_64** | Random Password (With Symbols, 64 characters) |
170-
| **BASE64\_64** | Random String (Not Base64-encoded, 64 characters) |
171-
| **BASE64\_128** | Random String (Not Base64-encoded, 128 characters) |
172-
| **BASE64** or **BASE64\_32** | Random String (Not Base64-encoded, 32 characters) |
173-
| **REALBASE64\_64** | Random String (Base64-encoded, 64 characters) |
174-
| **REALBASE64\_128** | Random String (Base64-encoded, 128 characters) |
175-
| **REALBASE64** or **REALBASE64\_32** | Random String (Base64-encoded, 32 characters) |
176-
| **HEX\_32** | Random String (Hexadecimal, 32 characters) |
177-
| **HEX\_64** | Random String (Hexadecimal, 64 characters) |
178-
| **HEX\_128** | Random String (Hexadecimal, 128 characters) |
179-
| **USER** | Random String (16 characters) |
180-
| **FQDN** | Fully Qualified Domain Name (FQDN) |
181-
| **URL** | URL based on the defined FQDN |
182-
183-
Example:
184-
```yaml
185-
services:
186-
appwrite:
187-
environment:
188-
- $SERVICE_PASSWORD: sjdkfhsd43f
189-
- $SERVICE_PASSWORD_64: kdlfghsdiof43r3rweos93fofi39fjeowfkdj84fh3dksfjsw43r5
190-
- $SERVICE_PASSWORDWITHSYMBOLS: sjdk@fhsd!43#f
191-
- $SERVICE_PASSWORDWITHSYMBOLS_64: kdlfghsdiof43!@#r3rweos93fofi39fjeowfkdj84fh3dksfjsw43r5!
192-
- $SERVICE_PASSWORD_BASE64_64: jkhf4r5g4dh7sd85sd85fh7sgd5fhdfgsd9g7sd
193-
- $SERVICE_PASSWORD_BASE64_128: sd98fhsd7g8d98sd7f9sdg7fd87sd98f7sdg78f7d98g7d89
194-
- $SERVICE_PASSWORD_BASE64: sd98fh3g2k3h2gs78d93dgh
195-
- $SERVICE_PASSWORD_BASE64_32: sd98fh3g2k3h2gs78d93dgh
196-
- $SERVICE_PASSWORD_REALBASE64_64: c2Q5OGZoc2Q3Z2g4Yzg1M2c5ZGM3MG5k8as==
197-
- $SERVICE_PASSWORD_REALBASE64_128: c2Q5OGZoc2Q3Z2g4Yzg1M2c5ZGM3MG5k8aY9sdg==
198-
- $SERVICE_PASSWORD_REALBASE64: c2Q5OGZoc2Q3Z2g4Yzg1M2c5ZGM3MG5k8a==
199-
- $SERVICE_PASSWORD_REALBASE64_32: c2Q5OGZoc2Q3Z2g4Yzg1M2c5ZGM3MG5k8a==
200-
- $SERVICE_PASSWORD_HEX_32: a6b9f34e43c112d79f9a3d5c7983344f
201-
- $SERVICE_PASSWORD_HEX_64: db8c8a1a3b9df5a9fb8fd3f87df62f4b6a34cf4310f5cdb8c098b4f0e9af3b2
202-
- $SERVICE_PASSWORD_HEX_128: 7f8c98a98db56b0c6c8768b1db6d24f5f39493433d8d8f1846598c9830202089
203-
- $SERVICE_USER: jsd98fhg2j3skl8j
204-
- $SERVICE_FQDN: api.example.com
205-
- $SERVICE_URL: https://api.example.com
206-
```
207-
208-
Every generated variable is consistent across all services in your stack and appears in Coolify's UI (except FQDN and URL, which are fixed).
209-
210-
For example, if your application UUID is `vgsco4o` and you deploy Appwrite on the wildcard domain `http://example.com`, you might include:
211-
212-
```yaml
213-
services:
214-
appwrite:
215-
environment:
216-
# Generates FQDN: http://appwrite-vgsco4o.example.com/v1/realtime
217-
- SERVICE_FQDN_APPWRITE=/v1/realtime
218-
219-
# Uses the FQDN for _APP_URL.
220-
- _APP_URL=$SERVICE_FQDN_APPWRITE
221-
222-
# Proxies to port 3000.
223-
- SERVICE_FQDN_APPWRITE_3000
224-
225-
# Proxies API requests to port 2000.
226-
- SERVICE_FQDN_API_2000=/api
227-
228-
# Generates and injects a password.
229-
- SERVICE_SPECIFIC_PASSWORD=${SERVICE_PASSWORD_APPWRITE}
230-
not-appwrite:
231-
environment:
232-
# Reuses the password from the Appwrite service.
233-
- APPWRITE_PASSWORD=${SERVICE_PASSWORD_APPWRITE}
234-
# Generates a new FQDN for this service.
235-
- SERVICE_FQDN_API=/api
236-
```
105+
Within Coolify you can configure these easily following the details found in the [Knowledge Base for Docker Compose](/knowledge-base/compose#defining-environment-and-shared-variables).
237106

238107
### Storage
239108

@@ -293,15 +162,15 @@ By default, each compose stack is deployed to a separate network named after you
293162

294163
If you want to connect services across different stacks (for example, linking an application to a separate database), enable the **Connect to Predefined Network** option on your Service Stack page.
295164

296-
<ZoomableImage src="/docs/images/builds/packs/compose/7.webp" alt="Coolify dashboard screenshot" />
165+
<ZoomableImage src="/docs/images/builds/packs/compose/6.webp" />
297166

298167
Note that you must use the full name (like `postgres-<uuid>`) when referencing a service in another stack.
299168

300169
### Raw Docker Compose Deployment
301170

302171
For advanced users, Coolify offers a "Raw Compose Deployment" mode. This option lets you deploy your Docker Compose file directly without many of Coolify's additional configurations.
303172

304-
<ZoomableImage src="/docs/images/builds/packs/compose/8.webp" alt="Coolify dashboard screenshot" />
173+
<ZoomableImage src="/docs/images/builds/packs/compose/7.webp" />
305174

306175
::: danger CAUTION
307176
This mode is intended for advanced users familiar with Docker Compose.

docs/knowledge-base/docker/compose.md

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ Then you can connect from `backend` to `auth` by referring to it as `http://auth
5959

6060
For further details, please refer to the [Docker Networking in Compose](https://docs.docker.com/compose/how-tos/networking/) docs.
6161

62-
## Defining environment variables
62+
## Defining Environment Variables
6363

64-
Coolify will notice the environment variables you mention in your compose file and will display it in its UI.
64+
Coolify automatically detects environment variables mentioned in your compose file and displays them in the UI. For example:
6565

6666
```yaml
6767
services:
@@ -72,28 +72,28 @@ services:
7272
- SOME_DEFAULT_VARIABLE=${OTHER_NAME_IN_COOLIFY:-hello} # Creates an environment variable of value "hello" editable in Coolify's UI
7373
```
7474

75-
<ZoomableImage src="/docs/images/screenshots/Docker-compose-environment-variables-UI.webp" alt="Docker Compose Environment Variables Ui configuration" />
75+
<ZoomableImage src="/docs/images/knowledge-base/compose/1.webp" />
7676

77-
## Required environment variables
77+
### Required Environment Variables
7878

7979
Coolify supports marking environment variables as required using Docker Compose's built-in syntax. This feature improves the deployment experience by validating critical configuration before starting services.
80-
81-
### Syntax
82-
83-
Use the `:?` syntax to mark variables as required:
80+
You can mark environment variables as required using the `:?` syntax. Required variables must be set before deployment and will be highlighted in Coolify's UI with a red border if empty.
8481

8582
```yaml
8683
services:
87-
webapp:
84+
myapp:
8885
environment:
89-
# Required variable - must be set, no default
86+
# Required variables - deployment will fail if not set
9087
- DATABASE_URL=${DATABASE_URL:?}
88+
- API_KEY=${API_KEY:?}
9189
92-
# Required variable with default value - prefilled but editable
90+
# Required variables with default values - prefilled in UI but can be changed
9391
- PORT=${PORT:?3000}
92+
- LOG_LEVEL=${LOG_LEVEL:?info}
9493
95-
# Optional variable with default - standard Docker Compose behavior
94+
# Optional variables - standard behavior
9695
- DEBUG=${DEBUG:-false}
96+
- CACHE_TTL=${CACHE_TTL:-3600}
9797
```
9898

9999
**Key behaviors:**
@@ -110,35 +110,71 @@ If a required variable is not set during deployment:
110110

111111
This validation happens before container creation, preventing partial deployments and runtime failures.
112112

113-
## Coolify's magic environment variables
113+
### Shared Environment Variables
114+
115+
Coolify doesn't directly detect **shared** environment variables in the compose file, but are able to be referenced using with an additional step.
116+
117+
1. Create your shared variable following the [shared variables documentation](/knowledge-base/environment-variables#shared-variables).
118+
119+
2. Define your variables in your Docker Compose file, for example;
120+
121+
```yaml
122+
services:
123+
myservice:
124+
environment:
125+
- HARD_CODED=dev # Passed to the container, but not visible in Coolify's UI.
126+
- SOME_OPTIONAL_VARIABLE=${SOME_VARIABLE_IN_COOLIFY_UI} # Creates an editable, uninitialized variable in the UI.
127+
volumes:
128+
- data-persist:/var/data
129+
volumes:
130+
data-persist:
131+
device: /mnt/serverstorage/${SOME_VARIABLE_IN_COOLIFY_UI} # Re-uses the variable
132+
```
133+
134+
3. Define the variable explicitly in the applications Environment Variables referencing your shared variable created in step 1;
135+
136+
::: v-pre
137+
138+
If in developer view, you can enter it like so;
139+
140+
```
141+
SOME_VARIABLE_IN_COOLIFY_UI={{environment.SOME_SHARED_VARIABLE}}
142+
```
143+
144+
Or in the normal view, the Name is what's referenced in the Docker Compose file `SOME_VARIABLE_IN_COOLIFY_UI` with the Value being the referenced environment variable `{{environment.SOME_SHARED_VARIABLE}}` as seen below. Once saved if correct, you'll see there's a third text box, if you reveal this, you should be able to see the true value, in this case `SOME_VALUE`.
145+
146+
:::
147+
148+
<ZoomableImage src="/docs/images/knowledge-base/compose/2.webp" />
114149
115-
Additionally, Coolify can generate some dynamic environment variables for you.
116-
The syntax is `SERVICE_<TYPE>_<IDENTIFIER>`.
117-
Type may be one of:
150+
### Coolify's Magic Environment Variables
118151
119-
- **FQDN**: This will [generate](/knowledge-base/server/introduction#wildcard-domain) an FQDN for the service. The example below shows how you can add paths and ports.
120-
- **URL**: Generates an URL based on the FQDN you have defined. Prefer this to generate URL for your services
152+
Coolify can generate dynamic environment variables for you using the following syntax: `SERVICE_<TYPE>_<IDENTIFIER>`. The type may be one of:
153+
154+
- **URL**: This will [generate](/knowledge-base/server/introduction#wildcard-domain) an URL for the service. The example below shows how you can add paths and ports.
155+
- **FQDN**: Generates FQDN for the service based on the URL you have defined. The example below shows how you can add paths and ports.
121156
- **USER**: Generates a random string using `Str::random(16)`. You might want to use it as a username in your service.
122157
- **PASSWORD**: Generates a password using `Str::password(symbols: false)`. Use `PASSWORD_64` to generate a 64 bit long password with `Str::password(length: 64, symbols: false)`.
123158
- **BASE64**: Generates a random string using `Str::random(32)`. For longer strings, use `BASE64_64` or `BASE64_128`.
124-
- **REALBASE64**: Encodes a randomly generated string using `base64_encode(Str::random(32))`. For longer strings, use `REALBASE64_64` or `REALBASE64_128`.
125-
126-
Every generated variable can be reused and will always have the same value for every service.
127-
All generated variables are displayed in Coolify's UI for environment variables and can be edited there (except FQDN and URl).
128159
129-
::: info Naming
130-
Names with underscores (`_`) cannot use ports in environment variables. Use hyphens (`-`) instead to avoid this limitation.
160+
::: info Identifier Naming
161+
Identifier with underscores (`_`) cannot use ports in environment variables. Use hyphens (`-`) instead to avoid this limitation.
131162
132163
```
133164
SERVICE_URL_APPWRITE_SERVICE_3000 ❌
134165
SERVICE_URL_APPWRITE-SERVICE_3000 ✅
135166
```
167+
136168
:::
137169
170+
Every generated variable can be reused and will always have the same value for every service.
171+
All generated variables are displayed in Coolify's UI for environment variables and can be edited there (except FQDN and URl).
172+
138173
As an example, imagine an application with UUID `vgsco4o` (generated by Coolify on creation).
139174
It uses a compose file deploying Appwrite on the [wildcard](/knowledge-base/server/introduction#wildcard-domain) domain `http://example.com` .
140175
141-
This will do the following:
176+
This will do the following:
177+
142178
- `SERVICE_URL_APPWRITE`: 'http://appwrite-vgsco4o.example.com'
143179
- `SERVICE_FQDN_APPWRITE`: appwrite-vgsco4o.example.com
144180
@@ -160,15 +196,17 @@ services:
160196
- SERVICE_SPECIFIC_PASSWORD=${SERVICE_PASSWORD_APPWRITE}
161197
not-appwrite:
162198
environment:
163-
# Same value as in Appwrite service
199+
# Reuses the password from the Appwrite service.
164200
- APPWRITE_PASSWORD=${SERVICE_PASSWORD_APPWRITE}
165201
# As SERVICE_URL_API is not the same as SERVICE_URL_APPWRITE
166202
# Coolify will generate a new URL
167203
# http://not-appwrite-vgsco4o.example.com/api
168204
- SERVICE_URL_API=/api
169205
```
170206

171-
---
207+
:::Warning
208+
Support for Magic Environment Variables in Compose files based on Git sources requires Coolify v4.0.0-beta.411 and above.
209+
:::
172210

173211
## Storage
174212

@@ -195,7 +233,7 @@ Here you can see how to add a file with content and a dynamic value that is comi
195233
```yaml
196234
services:
197235
filebrowser:
198-
image: filebrowser/filebrowser:latest
236+
image: filebrowser/firebrowser:latest
199237
environment:
200238
- POSTGRES_PASSWORD=password
201239
volumes:

docs/knowledge-base/environment-variables.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,9 @@ You can set them on the `Projects` page, under the gear icon and use it with <co
3737

3838
You can set them on the `Environments` page (select a `Project`), under the gear icon and use it with <code v-pre>{{environment.NODE_ENV}}</code> Do not replace "environment" with your actual environment name.
3939

40-
#### Using Shared Variables in Compose File
40+
### Using Environment and Shared Variables in Docker Compose
4141

42-
If you want to use the environment variables in your compose file, you can do so by using the following syntax:
43-
44-
```bash
45-
environment:
46-
- NODE_ENV=${NODE_ENV}
47-
```
48-
49-
And then in the UI set `NODE_ENV` to your desired shared variable. For example if you want to use a team based variable (make sure you have the `NODE_ENV` variable set in the Team Variables):
50-
51-
```bash
52-
NODE_ENV={{team.NODE_ENV}}
53-
```
42+
Within Coolify you can configure these easily following the details found in the [Knowledge Base for Docker Compose](/knowledge-base/compose#defining-environment-and-shared-variables).
5443

5544
## Predefined Variables
5645

-6.19 KB
Loading
532 Bytes
Loading
-54.3 KB
Binary file not shown.
60 KB
Loading
52.2 KB
Loading

0 commit comments

Comments
 (0)