mirror of
https://github.com/Dokploy/website.git
synced 2026-07-27 00:35:23 +02:00
feat: add self reference variables
This commit is contained in:
@@ -1,21 +1,29 @@
|
|||||||
---
|
---
|
||||||
title: Environment Variables
|
title: Environment Variables
|
||||||
description: "Dokploy allows you to create and manage shared environment variables for your projects."
|
description: "Dokploy allows you to create and manage shared and service-level environment variables for your projects."
|
||||||
---
|
---
|
||||||
|
|
||||||
import { Callout } from "fumadocs-ui/components/callout";
|
import { Callout } from "fumadocs-ui/components/callout";
|
||||||
|
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Shared environment variables allow you to:
|
Environment variables in Dokploy allow you to:
|
||||||
- Define values once and use them across multiple services
|
- Define configuration once and reuse it
|
||||||
- Maintain configuration consistency between services
|
- Share values across multiple services
|
||||||
|
- Reference values from within the same service
|
||||||
- Centrally manage sensitive information
|
- Centrally manage sensitive information
|
||||||
|
|
||||||
<ImageZoom src="/assets/images/shared-variables.png" width={800} height={630} alt='Shared variables panel' className="rounded-lg" />
|
<ImageZoom src="/assets/images/shared-variables.png" width={800} height={630} alt='Environment variables panel' className="rounded-lg" />
|
||||||
|
|
||||||
## Practical Example
|
## Defining Variables
|
||||||
|
|
||||||
|
You can declare environment variables either:
|
||||||
|
- **Project-level (shared)** — available across all services in the project
|
||||||
|
- **Service-level** — specific to a single service
|
||||||
|
|
||||||
|
## Project-Level Variables
|
||||||
|
|
||||||
|
### Practical Example
|
||||||
|
|
||||||
Let's consider a common scenario where you have:
|
Let's consider a common scenario where you have:
|
||||||
- A PostgreSQL database
|
- A PostgreSQL database
|
||||||
@@ -41,11 +49,28 @@ DATABASE_URL=${{project.DATABASE_URL}}
|
|||||||
Dokploy will automatically replace `${{project.DATABASE_URL}}` with the value defined in the project's shared variables.
|
Dokploy will automatically replace `${{project.DATABASE_URL}}` with the value defined in the project's shared variables.
|
||||||
</Callout>
|
</Callout>
|
||||||
|
|
||||||
## Best Practices
|
You can use shared environment variables in all the services available in dokploy.
|
||||||
|
|
||||||
|
## Service-Level Variables
|
||||||
|
|
||||||
|
Service-level variables are specific to a single service and can be used to override shared variables or define service-specific configurations.
|
||||||
|
|
||||||
|
### Practical Example
|
||||||
|
|
||||||
|
Let's say you have a service that requires a different database user. You can define a service-level variable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DATABASE_USER=service_user
|
||||||
|
DATABASE_URL=postgresql://${{DATABASE_USER}}:${{project.DATABASE_PASSWORD}}@service-database:5432/postgres
|
||||||
|
```
|
||||||
|
|
||||||
|
<Callout type="info">
|
||||||
|
Preview Deployments environments also include a service-level variable called `DOKPLOY_DEPLOY_URL`, which points to the deployment URL of the service.
|
||||||
|
It can be used as `${{DOKPLOY_DEPLOY_URL}}` for variables like `APP_URL=https://${{DOKPLOY_DEPLOY_URL}}`.
|
||||||
|
</Callout>
|
||||||
|
|
||||||
|
### Best Practices
|
||||||
|
|
||||||
- Use shared variables for credentials and configurations that repeat across services
|
- Use shared variables for credentials and configurations that repeat across services
|
||||||
- Keep descriptive variable names
|
- Keep descriptive variable names
|
||||||
- Document the purpose of each variable for easier maintenance
|
- Document the purpose of each variable for easier maintenance
|
||||||
|
|
||||||
|
|
||||||
You can use shared enviroment variables in all the services available in dokploy.
|
|
||||||
Reference in New Issue
Block a user