wallabag / docker

Official docker-composer for wallabag.
572 stars 150 forks source link

Fix initial setup when using Postgres #392

Open 501st-alpha1 opened 6 months ago

501st-alpha1 commented 6 months ago

I ran into a few different issues when trying to run this locally in Docker (using Docker Compose as recommended).

The main problem is the migrations are not run on first docker-compose up, even if POPULATE_DATABASE is set to True. Searching through the issues I was able to find the command to run the migrations (bin/console doctrine:migrations:migrate --env=prod --no-interaction), and though it throws errors when run, the migrations do succeed. (Running the command a second time will show that no migrations need to be run, and no errors occur, so some part of the command must depend on having the correct database structure.)

I also noticed that the database-exists check was failing; when I did a fresh docker-compose up, the entrypoint.sh script detected that the wallabag database already existed, and I confirmed this by inspecting the Postgres instance myself. My guess is Docker Compose automatically created a database with the same name as the Compose project (which here was also wallabag), so by the time the script checks it already exists. To work around this, I instead added a check if any tables exist, and now it works properly.

One other issue I found is even though the entrypoint.sh provisioner runs the bin/console wallabag:install command, the default wallabag:wallabag user was not created. I ran the install command again by doing:

docker-compose exec wallabag php bin/console wallabag:install --env=prod -n

and after that the default user was created.

I haven't dug into either that or the migration command throwing errors, but will shortly either do so or at least create issues for them.

I found a few similar issues (listed below), but all of them have slight variations from my setup or behavior, e.g. using MySQL instead of Postgres, so I'm listing as Related rather than Fixes.

Related: #291, #236, #286, #154, #377.

j0k3r commented 6 months ago

Every thing sound goods but now the build is failing. Can you look into it?