Skip to content

Commit 18d96b5

Browse files
committed
docs: expand environment variables section to include environment-level variables with practical examples
1 parent f78bbd5 commit 18d96b5

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

apps/docs/content/docs/core/variables.mdx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Environment Variables
3-
description: "Dokploy allows you to create and manage shared and service-level environment variables for your projects."
3+
description: "Dokploy allows you to create and manage shared and service-level environment variables for your projects and environments."
44
---
55

66
import { Callout } from "fumadocs-ui/components/callout";
@@ -19,6 +19,7 @@ Environment variables in Dokploy allow you to:
1919

2020
You can declare environment variables either:
2121
- **Project-level (shared)** — available across all services in the project
22+
- **Environment-level** — specific to a single environment
2223
- **Service-level** — specific to a single service
2324

2425
## Project-Level Variables
@@ -51,6 +52,40 @@ DATABASE_URL=${{project.DATABASE_URL}}
5152

5253
You can use shared environment variables in all the services available in dokploy.
5354

55+
56+
## Environment-Level Variables
57+
58+
### Practical Example
59+
60+
Let's consider a scenario where you have:
61+
- A staging environment with different database credentials
62+
- Multiple services that need environment-specific configurations
63+
64+
### 1. Define Environment Variable
65+
66+
In the environment's variables section, define:
67+
68+
```bash
69+
DATABASE_PASSWORD=staging_secret_password
70+
API_KEY=staging_api_key_12345
71+
```
72+
73+
### 2. Use the Variable in Services
74+
75+
In each service's environment variables tab, reference the environment variable:
76+
77+
78+
```bash
79+
DATABASE_URL=postgresql://postgres:${{environment.DATABASE_PASSWORD}}@staging-db:5432/postgres
80+
EXTERNAL_API_KEY=${{environment.API_KEY}}
81+
```
82+
83+
<Callout type="info">
84+
Dokploy will automatically replace `${{environment.VARIABLE_NAME}}` with the value defined in the environment's variables.
85+
</Callout>
86+
87+
You can use environment variables in all the services available in that specific environment.
88+
5489
## Service-Level Variables
5590

5691
Service-level variables are specific to a single service and can be used to override shared variables or define service-specific configurations.
@@ -61,7 +96,8 @@ Let's say you have a service that requires a different database user. You can de
6196

6297
```bash
6398
DATABASE_USER=service_user
64-
DATABASE_URL=postgresql://${{DATABASE_USER}}:${{project.DATABASE_PASSWORD}}@service-database:5432/postgres
99+
DATABASE_PASSWORD=service_password
100+
DATABASE_URL=postgresql://${{DATABASE_USER}}:${{DATABASE_PASSWORD}}@service-database:5432/postgres
65101
```
66102

67103
<Callout type="info">

0 commit comments

Comments
 (0)