Open benjaminpreiss opened 1 month ago
I can confirm that on a docker build. I ran printenv, and the variables are not there at build time, even if I mark them as a build-time variable. But if I call printenv on the command-tab on the running container, it works. But I need the keys at compile time.
can you link a repo or make an example, ive checked this so many times and never found an issue
True, not working with docker-compose deployment also
just deploy this (docker-compose) ad env variables
Enviromental variables inside docker like this are not passed from whenadded in Enviromental variables:
environment:
- _APP_ENV
- _APP_WORKER_PER_CORE
- _APP_LOCALE
- _APP_CONSOLE_WHITELIST_ROOT
- _APP_CONSOLE_WHITELIST_EMAILS
- _APP_CONSOLE_SESSION_ALERTS
- _APP_CONSOLE_WHITELIST_IPS
- _APP_CONSOLE_HOSTNAMES
- _APP_SYSTEM_EMAIL_NAME
- _APP_SYSTEM_EMAIL_ADDRESS
- _APP_EMAIL_SECURITY
- _APP_SYSTEM_RESPONSE_FORMAT
- _APP_OPTIONS_ABUSE
- _APP_OPTIONS_ROUTER_PROTECTION
@nhCoder you need to assign them like this
environment:
- '_APP_ENV=${_APP_ENV}'
the links you pasted dont work so i cant check
The only thing I did differently than the standard was manually set a specific docker file. Given I am using NESTJS SSR, I need variables at compile time, so I expect the env vars to be there if I check "Build Variables?" at the Environment Variables tab. But as you can see down below, I call printenv in the docker build and they are not there. But if I go to the terminal and call printenv again, they are there, so for now, I changed the CMD on the docker to call build before start, and it works, but it slowers the startup of the new version.
@djsisson I have updated the links please check.. and Why we need to do like this '_APP_ENV=${_APP_ENV}'
standard deployment with docker doesn't require that. Also Dokploy supports like i without assiging env var inside compose.
@tolstenko did you add ARG API_HOST in your dockerfile etc
@nhCoder coolify parses the compose files first
@djsisson ehhrr... it is embarrassing... you are right. I'm sorry. It works with that.
For some reason, I thought Coolify would magically be in charge of that. Well, to help you not receive this type of issue anymore and help people like me who assume this same idea, it would be nice to have an information icon, explaining what we should do to make it work. Coolify is so nice that I just wrongly assumed that.
I guess you could transform this issue into either an improvement to have this (i) to remember people to setup dockerfile properly, or even better, create an automation to modify the dockerfile and inject ARGs on the build container (this might be harder on multi-stage builds). I can do the (i) in a PR. What do you think?
Then, what is the use of providing environmental variables separately
Then, what is the use of providing environmental variables separately @nhCoder there is already a coolify appwrite template https://github.com/coollabsio/coolify/blob/main/templates/compose/appwrite.yaml
the env vars in the env vars tab, will get passed into whichever service requires them. if you need more info look at any of the docker compose templates
@tolstenko i think it also depends on what image you are using to build, for instance a normal nextjs dockerfile using node 20 alpine you do not have to specify ARG at all it auto picks up all teh build args that are passed in
Error Message and Logs
Steps to Reproduce
1 Setup nixpacks.toml in your repo root:
2 Set NPM_TOKEN environment variable in coolify 3 Make sure the above steps are available 4 Push to git & deploy 5 Verify that the $NPM_TOKEN variable is not defined in the logs
Example Repository URL
No response
Coolify Version
v4.0.0-beta.323
Are you using Coolify Cloud?
Yes (Coolify Cloud)
Operating System and Version (self-hosted)
macOS 14.4.1 (23E224)
Additional Information
No response