linuxserver / Heimdall

An Application dashboard and launcher
MIT License
7.73k stars 537 forks source link

Allow APP_NAME environment variable to override .env file. #848

Closed traverseda closed 1 year ago

traverseda commented 2 years ago

Discussed in https://github.com/linuxserver/Heimdall/discussions/734

Originally posted by **ChaoticWyrme** March 7, 2021 I'm hosting my heimdall install in docker, and wanted to change the tab title. I followed the APP_NAME environment variable from #132, by adding -e APP_NAME="Media Server" onto my docker run command. However, this didn't change the tab title, and looking at the filesystem in the container, it is specified in the .env file, so it may be that it is being overridden by that. I would like to be able to specify the APP_NAME setting through my `docker run` command rather than modifying the file in the container in such a fragile way.
pablomalo commented 2 years ago

@traverseda I'm having the same issue. My docker-compose.yml file references an .env file where the APP_NAME environment variable is defined.

Inside the container, the variable is correctly set.

root@80d48c11e309:/# echo $APP_NAME 
My Dashboard

Furthermore, Laravel seems to have picked it up.

root@80d48c11e309:/# cd /var/www/localhost/heimdall/
root@80d48c11e309:/var/www/localhost/heimdall# php artisan tinker
Psy Shell v0.11.2 (PHP 7.4.26 — cli) by Justin Hileman
>>> config('app.name');
=> "My Dashboard"

Still, the page keeps displaying "Heimdall" as the title, despite the fact that the main template references the exact same variable that we just checked.

root@80d48c11e309:/var/www/localhost/heimdall# cat resources/views/layouts/app.blade.php | grep title
        <title>{{ config('app.name') }}</title>
                    if($app->title == 'app.dashboard') continue;
                    <li>{{ $app->title }}<a class="{{ $active }}" data-tag="{{ $tag ?? 0 }}" data-id="{{ $app->id }}" href="{{ route('items.pintoggle', [$app->id]) }}"><i class="fas fa-thumbtack"></i></a></li>

Clearing the config cache with php artisan config:clear has no effect.

I'm really kind of baffled by this behavior.

pablomalo commented 2 years ago

OK so the command that needed to be run for the environment change to take effect was not artisan config:clear but artisan config:cache.

So if I up my docker compose stack and then run the following command (where heimdall is the name of my service), the app correctly picks up the title defined in APP_NAME.

docker compose exec -it heimdall php /var/www/localhost/heimdall/artisan config:cache
pablomalo commented 2 years ago

Well sorry for the humming and hawing. It seems both commands are actually required --if I run only the first, I get a 419 error when attempting to log in / add bookmarks.

So for now I'm going with this:

l$ docker compose up -d
[+] Running 1/1
 ⠿ Container heimdall-heimdall-1  Started                                                 0.6s
$ docker compose exec -it heimdall php /var/www/localhost/heimdall/artisan config:cache
Configuration cache cleared!
Configuration cached successfully!
$ docker compose exec -it heimdall php /var/www/localhost/heimdall/artisan config:clear
Configuration cache cleared!
yurividal commented 2 years ago

Still cant get this to work. Any permanent solutions to allow changing app name?

Amatsuntsun commented 2 years ago

The APP_NAME variable briefly worked in Portainer but after logging in it just results in a 403 Error or gets stuck in a login loop. Using pablomalo's suggestion just resets it back to default. Tried adding custom CSS and Javascript to change the title and even tried editing config/app.php to simply 'Home' with no luck.

I can only guess the name is hardcoded somewhere. I've not the time or patience to look for it and simply replaced it with a Grafana Dashboard.

Dev should understand that not everyone shares his obsession with Marvel Comics. Can't be from mythology since Heidall is a god who keeps watch for invaders. An okay marketing name for a firewall but not a dashboard IMO.

karan commented 2 years ago

I tried @pablomalo's suggestion in https://github.com/linuxserver/Heimdall/issues/848#issuecomment-1147404897 but it still doesn't work:

docker  exec -it heimdall php /var/www/localhost/heimdall/artisan config:cache
docker  exec -it heimdall php /var/www/localhost/heimdall/artisan config:clear
docker restart heimdall
oystermon commented 2 years ago

Hi, the way I did it was how it was suggested by Kodestar: (assuming you are running it in a docker container)

In the folder you mapped /config to, open a terminal and navigate to <mapped location>/www/ and do a cat .env You should be able to see the .env file Use a text editor of your choice to edit the APP_NAME= line of the .env file to what you want it to be Restart the container and it should work.