medienhaus / medienhaus-docker

The medienhaus/ Docker composition
https://medienhaus.dev/
GNU Affero General Public License v3.0
0 stars 0 forks source link

Add Docker healthchecks & fix startup-order #3

Closed fnwbr closed 9 months ago

fnwbr commented 9 months ago

When I booted this repository for the first time, I ran in the issue of the spacedeck container crying like this:

2023-09-13T13:37:41.376092492Z [2023-09-13T13:37:41.375Z] Booting Spacedeck Open… (environment: development)
2023-09-13T13:37:41.379381791Z Wed, 13 Sep 2023 13:37:41 GMT express-session deprecated undefined resave option; provide resave option at spacedeck.js:69:9
2023-09-13T13:37:41.379402208Z Wed, 13 Sep 2023 13:37:41 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at spacedeck.js:69:9
2023-09-13T13:37:41.680518061Z [2023-09-13T13:37:41.679Z] [redis-mock] websockets subscribed to 3 topics.
2023-09-13T13:37:41.681911565Z [2023-09-13T13:37:41.681Z] Spacedeck Open listening at http://:::9666
2023-09-13T13:37:41.686424783Z [2023-09-13T13:37:41.686Z] createBucket null undefined
2023-09-13T13:37:41.688130579Z [2023-09-13T13:37:41.687Z] (node:1) UnhandledPromiseRejectionWarning: SequelizeConnectionRefusedError: connect ECONNREFUSED 192.168.207.7:5432
2023-09-13T13:37:41.688139204Z     at Client.connection.connect.err [as _connectionCallback] (/app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:142:24)
2023-09-13T13:37:41.688141204Z     at Client._handleErrorWhileConnecting (/app/node_modules/pg/lib/client.js:327:19)
2023-09-13T13:37:41.688142662Z     at Client._handleErrorEvent (/app/node_modules/pg/lib/client.js:337:19)
2023-09-13T13:37:41.688143871Z     at Connection.emit (events.js:198:13)
2023-09-13T13:37:41.688145037Z     at Socket.reportStreamError (/app/node_modules/pg/lib/connection.js:58:12)
2023-09-13T13:37:41.688146246Z     at Socket.emit (events.js:198:13)
2023-09-13T13:37:41.688147371Z     at emitErrorNT (internal/streams/destroy.js:91:8)
2023-09-13T13:37:41.688148496Z     at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
2023-09-13T13:37:41.688149579Z     at process._tickCallback (internal/process/next_tick.js:63:19)
2023-09-13T13:37:41.688151037Z [2023-09-13T13:37:41.688Z] (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2023-09-13T13:37:41.688197662Z [2023-09-13T13:37:41.688Z] (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2023-09-13T13:37:53.186539070Z [2023-09-13T13:37:53.186Z] Executing (default): SELECT "token", "user_id", "expires", "created_at", "device", "ip", "createdAt", "updatedAt" FROM "sessions" AS "session" WHERE "session"."token" = 'undefined';
2023-09-13T13:37:53.189187118Z [2023-09-13T13:37:53.189Z] Unhandled rejection SequelizeDatabaseError: relation "sessions" does not exist
2023-09-13T13:37:53.189198326Z     at Query.formatError (/app/node_modules/sequelize/lib/dialects/postgres/query.js:363:16)
2023-09-13T13:37:53.189200451Z     at query.catch.err (/app/node_modules/sequelize/lib/dialects/postgres/query.js:86:18)
2023-09-13T13:37:53.189202035Z     at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
2023-09-13T13:37:53.189203535Z     at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:547:31)
2023-09-13T13:37:53.189221701Z     at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
2023-09-13T13:37:53.189223368Z     at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:649:10)
2023-09-13T13:37:53.189224660Z     at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:725:18)
2023-09-13T13:37:53.189225993Z     at _drainQueueStep (/app/node_modules/bluebird/js/release/async.js:93:12)
2023-09-13T13:37:53.189227243Z     at _drainQueue (/app/node_modules/bluebird/js/release/async.js:86:9)
2023-09-13T13:37:53.189228410Z     at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:102:5)
2023-09-13T13:37:53.189229618Z     at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:15:14)
2023-09-13T13:37:53.189230868Z     at runCallback (timers.js:705:18)
2023-09-13T13:37:53.189231993Z     at tryOnImmediate (timers.js:676:5)
2023-09-13T13:37:53.189233118Z     at processImmediate (timers.js:658:5)

Turned out that it was trying to run the database migrations before the corresponding PostgreSQL database was ready and available. This PR fixes that.

Solution came from https://devops.datenkollektiv.de/using-a-postgresql-with-docker-like-a-pro.html.