coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
34.33k stars 1.86k forks source link

[Bug]: Env variables can't be updated without stopping and starting the service #4181

Open ultragrup opened 4 days ago

ultragrup commented 4 days ago

Error Message and Logs

Hi all! First of all, I absolutely love Coolify, it's made my life significantly easier and I've been pushing it to my company HARD.

The issue happens (at least) when deploying code from a repository via a Dockefile. I have a very large project that consists of ~15 apps. Most of them are Laravel/PHP apps deployed via a Dockerfile, and they all share this issue. If I update any env var, the generated .env file rarely (but sometimes) has the new one. More often than not if I just update the value of the env var it works fine after a restart/redeploy, but if I change the var name it almost never works. This is especially bad on load balanced apps in production, where in order for env vars to appear I have to stop the service in the main server + any load balanced servers, then redeploy it before it actually shows up correctly. In production we use Debian 12 and Amazon Linux (arm in both cases), and in staging env we use a single Hetzner server running Ubuntu-22.04 on x86, and this issue occurs in both cases. While env vars aren't something we change too often, it's still a huge issue if we have to stop and start a service in production just to change one.

Thanks in advance! Let me know if I can provide any additional information

Steps to Reproduce

  1. Create a new project and deploy a repository containing a Dockerfile (potentially a PHP/Laravel app?)
  2. Add some environment variables needed for the app to run
  3. After the app is deployed, try to change some environment variables, either value or name of it
  4. Observe the values not updating in the .env file inside the container

Example Repository URL

No response

Coolify Version

v4.0.0-beta.360 and earlier

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

Amazon Linux Arm64 as well as Ubuntu-22.04 x86

Additional Information

No response

quarkcore commented 4 days ago

Hey, guess this is intended behaviour originating from the way docker works. further more laravel caches your configs so at least someone needs to know how to run php artisan config:cache inside the container after your env changed.

whats wrong with restarting the container as coolify has rolling updates..? if you have proper docker cache the redeploy should be somewhat fast. takes about 1,5 minutes in my case (with nginx, supervisor/horizon,.. packed in the same image)

ultragrup commented 4 days ago

The redeploys delete the old container and create a new one, so there's no point in running "php artisan config:cache" or similar commands, as it will be restarted, and if restarting worked it wouldn't be an issue, that's why I specifically said stopping then starting, manually, via "stop" button, not restart/redeploy, not even cacheless deploys update the .env file