diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 91b8bbc8..9f3fb850 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -151,7 +151,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Pull import database + - name: Pull database run: | docker compose pull db docker compose up --no-build --pull never --detach db diff --git a/docker-compose.yml b/docker-compose.yml index b4d6bf35..03ef3a29 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,10 @@ services: - PG_WORK_MEM - PG_MAINTENANCE_WORK_MEM - PGDATA=/var/lib/postgresql/postgres-data + healthcheck: + test: pg_isready -U postgres -d gis + interval: 1s + timeout: 1s import: image: ghcr.io/hiddewie/openrailwaymap-import:latest @@ -24,7 +28,8 @@ services: cache_from: - ghcr.io/hiddewie/openrailwaymap-import:latest depends_on: - - db + db: + condition: service_healthy volumes: - ./data:/data environment: @@ -39,7 +44,8 @@ services: martin-cp: image: ghcr.io/maplibre/martin depends_on: - - db + db: + condition: service_healthy entrypoint: ['sh', '-c'] command: | ' @@ -75,7 +81,8 @@ services: build: dockerfile: martin.Dockerfile depends_on: - - db + db: + condition: service_healthy volumes: - ./martin:/config environment: diff --git a/import/docker-startup.sh b/import/docker-startup.sh index e11bd76e..9eabc8a6 100755 --- a/import/docker-startup.sh +++ b/import/docker-startup.sh @@ -3,18 +3,6 @@ set -e set -o pipefail -# Testing if database is ready -i=1 -MAXCOUNT=60 -echo "Waiting for PostgreSQL to be running" -while [ $i -le $MAXCOUNT ] -do - pg_isready -q && echo "PostgreSQL running" && break - sleep 2 - i=$((i+1)) -done -test $i -gt $MAXCOUNT && echo "Timeout while waiting for PostgreSQL to be running" - case "$1" in import)