movim / movim_docker

Official Docker Compose stack for Movim, maintained by @kawaii and the @movim team
https://movim.eu/
GNU Affero General Public License v3.0
79 stars 29 forks source link

Container error if postgres not reachable at localhost #42

Closed tetricky closed 1 year ago

tetricky commented 1 year ago

I've installed movim using the docker container image (docker.io/movim/movim:0.21.1) under podman, with postgres running on a different pod.

I've set the database host using env variable DB_HOST=postgres.

On creating the container, it successfully connects to the database and populates the public schema.

If I try to log in as a user, it fails to progress past the request, and the debug logs show:

[2023-06-29T15:37:00.625612+00:00] movim.ERROR: Illuminate\Database\QueryException: SQLSTATE[08006] [7] could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432? (SQL: select * from "sessions" where "sessions"."id" = M4S18q6E5DoHsHHpOWUP64H2UhU7EbSW limit 1) in /var/www/html/vendor/illuminate/database/Connection.php (line 712)
Trace
#0 /var/www/html/vendor/illuminate/database/Connection.php(672): Illuminate\Database\Connection->runQueryCallback('select * from "...', Array, Object(Closure))
#1 /var/www/html/vendor/illuminate/database/Connection.php(376): Illuminate\Database\Connection->run('select * from "...', Array, Object(Closure))
#2 /var/www/html/vendor/illuminate/database/Query/Builder.php(2414): Illuminate\Database\Connection->select('select * from "...', Array, true)
#3 /var/www/html/vendor/illuminate/database/Query/Builder.php(2402): Illuminate\Database\Query\Builder->runSelect()
#4 /var/www/html/vendor/illuminate/database/Query/Builder.php(2936): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#5 /var/www/html/vendor/illuminate/database/Query/Builder.php(2403): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure))
#6 /var/www/html/vendor/illuminate/database/Eloquent/Builder.php(625): Illuminate\Database\Query\Builder->get(Array)
#7 /var/www/html/vendor/illuminate/database/Eloquent/Builder.php(609): Illuminate\Database\Eloquent\Builder->getModels(Array)
#8 /var/www/html/vendor/illuminate/database/Concerns/BuildsQueries.php(294): Illuminate\Database\Eloquent\Builder->get(Array)
#9 /var/www/html/vendor/illuminate/database/Eloquent/Builder.php(400): Illuminate\Database\Eloquent\Builder->first(Array)
#10 /var/www/html/vendor/illuminate/support/Traits/ForwardsCalls.php(23): Illuminate\Database\Eloquent\Builder->find('M4S18q6E5DoHsHH...')
#11 /var/www/html/vendor/illuminate/database/Eloquent/Model.php(2132): Illuminate\Database\Eloquent\Model->forwardCallTo(Object(Illuminate\Database\Eloquent\Builder), 'find', Array)
#12 /var/www/html/vendor/illuminate/database/Eloquent/Model.php(2144): Illuminate\Database\Eloquent\Model->__call('find', Array)
#13 /var/www/html/src/Movim/Bootstrap.php(253): Illuminate\Database\Eloquent\Model::__callStatic('find', Array)
#14 /var/www/html/src/Movim/Bootstrap.php(48): Movim\Bootstrap->startingSession()
#15 /var/www/html/linker.php(17): Movim\Bootstrap->boot()
#16 {main}  
tetricky commented 1 year ago

It seems that passing env variable at runtime is not sufficient, and does not catch all useage of them.

Creating a .env file, that mirrors that of the required env variables, and passing that into the container, with the correct permissions, solves the issue.

I'm marking this as closed, though in an ideal world one or the other approach would be all that is required, and the container would be capable of operation purely with runtime env variables.

At least the documentation should reflect this need.