Skip to content

Commit

Permalink
Add depends on for healthy DB, wait for DB to import/generate tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Mar 31, 2024
1 parent b80d614 commit 02c9675
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,7 +28,8 @@ services:
cache_from:
- ghcr.io/hiddewie/openrailwaymap-import:latest
depends_on:
- db
db:
condition: service_healthy
volumes:
- ./data:/data
environment:
Expand All @@ -39,7 +44,8 @@ services:
martin-cp:
image: ghcr.io/maplibre/martin
depends_on:
- db
db:
condition: service_healthy
entrypoint: ['sh', '-c']
command: |
'
Expand Down Expand Up @@ -75,7 +81,8 @@ services:
build:
dockerfile: martin.Dockerfile
depends_on:
- db
db:
condition: service_healthy
volumes:
- ./martin:/config
environment:
Expand Down
12 changes: 0 additions & 12 deletions import/docker-startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 02c9675

Please sign in to comment.