Skip to content

fix(docker): Update docker-compose.yml to fix broken postgress and MinIO initialization.#330

Merged
chamikaJ merged 2 commits intoWorklenz:mainfrom
OmentaElvis:fix/docker-compose
Sep 10, 2025
Merged

fix(docker): Update docker-compose.yml to fix broken postgress and MinIO initialization.#330
chamikaJ merged 2 commits intoWorklenz:mainfrom
OmentaElvis:fix/docker-compose

Conversation

@OmentaElvis
Copy link
Copy Markdown
Contributor

@OmentaElvis OmentaElvis commented Aug 21, 2025

This PR fixes multiple issues with the provided docker-compose.yml setup that were preventing a clean deployment of Worklenz.

Problems identified

Problem 1

Inline init commands in Compose were triggering Docker variable substitution warnings ($i, $f), causing broken init scripts and migration failures.

WARN[0000] The "i" variable is not set. Defaulting to a blank string. 
WARN[0000] The "f" variable is not set. Defaulting to a blank string. 
WARN[0000] The "f" variable is not set. Defaulting to a blank string.

So what happens here is that docker compose tries to substitute all $VARIABLE strings. So inline scripts such as:

command: >
    bash -c '
      find /docker-entrypoint-initdb.d -type f -name "*.sh" -exec sh -c '"'"'
        for f; do
          dos2unix "$f" 2>/dev/null || true
          chmod +x "$f"
        done
      '"'"' sh {} +
      exec docker-entrypoint.sh postgres
    '

Will have their $f replaced with empty strings that leads to:

chmod: cannot access '': No such file or directory

Problem 2

Postgres healthcheck was running too early (before initdb, dos2unix install, and migrations finished), causing the container to be marked unhealthy and dependent services to fail.

worklenz_db | CREATE DATABASE 
worklenz_db | 
worklenz_db | 
worklenz_db | /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/00_init.sh 
worklenz_db | Starting database initialization... 
dependency failed to start: container worklenz_db is unhealthy

Fixes applied

  1. Moved inline init commands into standalone scripts:
  • docker/db-init-wrapper.sh – runs dos2unix + chmod safely without Compose substitution conflicts.
  • docker/createbuckets-entrypoint.sh – encapsulates MinIO bucket creation logic.
  1. Updated Postgres db service to use healthcheck start_period of 30s so the healthcheck waits for initialization before running.

Should fix #325

- Extracted Postgres (db) init wrapper into `docker/db-init-wrapper.sh`
  to avoid Compose variable substitution issues with `$f`
  and ensure dos2unix + chmod run consistently.
- Extracted MinIO (createbuckets) bucket creation logic into
  `docker/createbuckets-entrypoint.sh` for clarity and easier maintenance and
  prevent docker compose from trying to substitute `$i` variable.

This Fixes docker substitution warnings:
'WARN[0000] The "i" variable is not set. Defaulting to a blank string.'
'WARN[0000] The "f" variable is not set. Defaulting to a blank string.'
'WARN[0000] The "f" variable is not set. Defaulting to a blank string.'

Which just break migration scripts from running.
Postgres container was marked unhealthy during initialization,
causing dependent services to fail before the database was ready.

Increasing the `start_period` ensures healthchecks wait long enough
for Postgres to install dos2unix, finish initdb and run migrations.

Otherwise the healthckeck fail during init causes partial database setup that
permanently bricks other dependent services.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 21, 2025

CLA assistant check
All committers have signed the CLA.

@gdevenyi
Copy link
Copy Markdown
Contributor

Looks good

@chamikaJ chamikaJ merged commit cc8a0cf into Worklenz:main Sep 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker Quick Deployment Errors and only Debian-based

4 participants