akaunting / docker

Docker Image for Akaunting
https://github.com/akaunting/akaunting
GNU General Public License v3.0
182 stars 85 forks source link

PHP env variables not set based off environment variables #91

Open JavonneM opened 1 year ago

JavonneM commented 1 year ago

The docker image seems to be a stateful container. Currently there is no way to dynamically set the php .env file through the docker env variables. Typically these variables can be set via the env variables (things such as APP_KEY and database host/port etc), however it seems that only some of the variables such as the database related env vars get set when the container is started with AKAUNTING_SETUP=true, but this also recreates the first company, and admin users duplicating the company and users that have already been create and locking users out since the APP_KEY gets changed.

A simple situation, I need to move my database from its current host to a new host, in order to change this I needed to do the following

docker-compose up --detach
docker cp <akaunting_container>:/var/www/html/.env ./env
vim .env # and change the env file as needed
docker cp .env <akaunting_container>:/var/www/html/.env
docker restart <akaunting_container>

Another way this can easily be show is by simply deleting the volume that is attached to the Akaunting app (not the database), now when recreating the container using docker compose, the database related variables and the APP_KEY is never passed into the newly generated /var/www/html/.env