Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feat: New magic #64

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/content/docs/contribute/service.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Aside, Steps } from '@astrojs/starlight/components';
Services in Coolify are templates made from normal [docker-compose](https://docs.docker.com/reference/compose-file/) files with some added Coolify magic.

<Aside type="note">
See [Coolify's docker-compose specs](/docs/knowledge-base/docker/compose#coolifys-magic-environment-variables) to learn more about Coolify's magic and how to benefit from generated variables and storage handling. Please use this magic when submitting your PR to make the merging process smoother.
See [Coolify's magic environment variables](/docs/knowledge-base/environment-variables#coolifys-magic-environment-variables) to learn more about Coolify's magic and how to benefit from generated variables and storage handling. Please use this magic when submitting your PR to make the merging process smoother.
</Aside>

<Steps>
Expand Down
61 changes: 2 additions & 59 deletions src/content/docs/knowledge-base/docker/compose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,9 @@ If you are using `Docker Compose` based deployments, you need to understand how

In all cases the Docker Compose (`docker-compose.y[a]ml`) file is the single source of truth.

## Defining environment variables
## Environment variables

Coolify will notice the environment variables you mention in your compose file and will display it in its UI.

```yaml
services:
myservice:
environment:
- SOME_HARDCODED_VALUE=hello # Gets passed to the container but will not be visible in Coolify's UI
- SOME_VARIABLE=${SOME_VARIABLE_IN_COOLIFY_UI} # Creates an uninitialized environment variable editable in Coolify's UI
- SOME_DEFAULT_VARIABLE=${OTHER_NAME_IN_COOLIFY:-hello} # Creates an environment variable of value "hello" editable in Coolify's UI
```


![Coolify's UI for environment variables](../../../../assets/images/screenshots/Docker-compose-environment-variables-UI.png)

## Coolify's magic environment variables

Additionally, Coolify can generate some dynamic environment variables for you.
The syntax is `SERVICE_<TYPE>_<IDENTIFIER>`.
Type may be one of:

- **FQDN**: This will [generate](/docs/knowledge-base/server/introduction#wildcard-domain) an FQDN for the service. The example below shows how you can add paths and ports.
- **URL**: Generates an URL based on the FQDN you have defined.
- **USER**: Generates a random string using `Str::random(16)`. You might want to use it as a username in your service.
- **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)`.
- **BASE64**: Generates a random string using `Str::random(32)`. For longer strings, use `BASE64_64` or `BASE64_128`.
- **REALBASE64**: Encodes a randomly generated string using `base64_encode(Str::random(32))`. For longer strings, use `REALBASE64_64` or `REALBASE64_128`.

Every generated variable can be reused and will always have the same value for every service.
All generated variables are displayed in Coolify's UI for environment variables and can be edited there (except FQDN and URl).

As an example, imagine an application with UUID `vgsco4o` (generated by Coolify on creation).
It uses a compose file deploying Appwrite on the [wildcard](/docs/knowledge-base/server/introduction#wildcard-domain) domain `http://example.com` .

```yaml
services:
appwrite:
environment:
# http://appwrite-vgsco4o.example.com/v1/realtime
- SERVICE_FQDN_APPWRITE=/v1/realtime
# _APP_URL will have the FQDN because SERVICE_FQDN_APPWRITE is just a simple environment variable
- _APP_URL=$SERVICE_FQDN_APPWRITE
# http://appwrite-vgsco4o.example.com/ will be proxied to port 3000
- SERVICE_FQDN_APPWRITE_3000
# http://api-vgsco4o.example.com/api will be proxied to port 2000
- SERVICE_FQDN_API_2000=/api
# Coolify generates password and injects it as SERVICE_SPECIFIC_PASSWORD into the container
- SERVICE_SPECIFIC_PASSWORD=${SERVICE_PASSWORD_APPWRITE}
not-appwrite:
environment:
# Same value as in Appwrite service
- APPWRITE_PASSWORD=${SERVICE_PASSWORD_APPWRITE}
# As SERVICE_FQDN_API is not the same as SERVICE_FQDN_APPWRITE
# Coolify will generate a new FQDN
# http://not-appwrite-vgsco4o.example.com/api
- SERVICE_FQDN_API=/api
```

---
To read more about environment variables, please refer to the [Environment Variables](/docs/knowledge-base/environment-variables) page.

## Storage

Expand Down
Loading