coolify
coolify copied to clipboard
[Bug]: env vars don't work for docker-compose based Preview Deployments
Description
At least the "Build variable" ones, even though it works fine in normal deployments and I declare/consume them in docker-compose.yaml
Example:
services:
something:
build:
context: .
args:
NPM_TOKEN: ${NPM_TOKEN:?NPM_TOKEN not set}
# ...
ports:
- "3333:3000"
environment:
- NPM_TOKEN=${NPM_TOKEN:?NPM_TOKEN not set}
# ...
Works as expected with regular deployments, however for Preview Deployments I'm getting the following error:
[2024-May-03 03:17:50.638004] error while interpolating services.something-pr-75.build.args.NPM_TOKEN: required variable NPM_TOKEN is missing a value: NPM_TOKEN not set
Switching the same resource to the Nixpacks build where nixpacks.toml relies on the same env variables solves the issue
Minimal Reproduction (if possible, example repository)
- Add a GitHub repo
- Configure the repo-based resource choosing Docker Compose build pack
- Add some environment variables and declare them in docker-compose
- Add e.g. a custom build command to see the env vars:
printenv && docker compose build
- Enable Preview Deployments, create PR and push there.
See your env vars missing in the logs e.g. below
Exception or Error
[COMMAND] docker exec XXXXXX bash -c 'cd /artifacts/XXXXXX && printenv && docker compose build' [OUTPUT] HOSTNAME=... PWD=/artifacts/XXXXXX HOME=/root SHLVL=1 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin OLDPWD=/artifacts _=/bin/printenv
Version
v4.0.0-beta.271