forked from toolshed/docs.coopcloud.tech
docs: improve STACK_NAME explanation
This commit is contained in:
@ -53,6 +53,12 @@ I.e. `compose.smtp.yml`. These are used to provide non-essential functionality s
|
||||
|
||||
If you look at a `compose.yml` file and see a `configs` section, that means this compose file is putting files in the container. This might be used for changing default (vendor) configuration, such as this [fpm-tune.ini file](https://git.coopcloud.tech/coop-cloud/nextcloud/src/commit/28425b6138603067021757de28c639ad464e9cf8/fpm-tune.ini) used to adjust `php-fpm.` See [this handbook entry](/maintainers/handbook/#manage-configs) for more.
|
||||
|
||||
### Special environment variables
|
||||
|
||||
#### STACK_NAME
|
||||
|
||||
Our deployment runtime expects a specific naming convention for Co-op Cloud apps when they are deployed on the server. This is a case of lowercasing/underscoring the domain name, e.g. "foo.coopcloud.tech" -> "foo_coopcloud_tech". This is for the most part an internal implementation detail. However, it is sometimes useful to expose this variable to template configurations when trying to connect apps together via runtime networking. See ["How do I reference serices in configs"](/maintainers/handbook/#how-do-i-reference-services-in-configs) for a practical example.
|
||||
|
||||
## Manage configs
|
||||
|
||||
To add additional files into the container, you can use [Docker configs](https://docs.docker.com/engine/swarm/configs/). This usually involves the following:
|
||||
@ -323,18 +329,15 @@ Sometimes the containers don't even have Bash installed on them. You had better
|
||||
|
||||
When referencing an `app` service in a config file, you should prefix with the `STACK_NAME` to avoid namespace conflicts (because all these containers sit on the traefik overlay network). You might want to do something like this `{{ env "STACK_NAME" }}_app` (using the often obscure dark magic of the Golang templating language). You can find examples of this approach used in the [Peertube recipe](https://git.coopcloud.tech/coop-cloud/peertube/src/commit/d1b297c5a6a23a06bf97bb954104ddfd7f736568/nginx.conf.tmpl#L9).
|
||||
|
||||
!!! warning "Here be timing dragons 🐉"
|
||||
!!! warning "Here be `STACK_NAME` dragons 🐉"
|
||||
|
||||
Due to how `STACK_NAME` as an environment variable is initialized within `abra`, it won't be available *early enough* for use within config templates (`*.tmpl`) unless you **use it as an environment variable for one of your compose services**.
|
||||
Ideally this is addressed in a newer version of `abra`, but for now, this workaround suffices ✅
|
||||
`STACK_NAME` is a [**special environment variable**](/maintainers/handbook/#special-environment-variables) which `abra` generates for you and in the format the runtime deployment expects to see. If you want to expose this environment variable in your template configurations, you need to expose it explicitly to the `env: ...` stanza in your recipe compose configuration. An example follows below.
|
||||
|
||||
E.g.
|
||||
```
|
||||
```yaml
|
||||
services:
|
||||
web:
|
||||
image: nginx:1.29.3
|
||||
environment:
|
||||
- ...
|
||||
- STACK_NAME
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user