#!/usr/bin/env bash # Brings the isolated acceptance stand (docker compose project gis-acceptance) # up or down. # # test/acceptance/stand.sh up build the image from this checkout, start # all services, apply migrations, import the # 14 districts, wait for /readyz # test/acceptance/stand.sh down stop and remove the stand with its volumes # test/acceptance/stand.sh ps|logs pass-through to docker compose # # Environment: MINIO_IMAGE, POSTGIS_PLATFORM, APP_IMAGE, HTTP_MAX_UPLOAD_BYTES, # LP_MAX_WORKERS, LP_MAX_NODES (see compose.acceptance.yml). set -euo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" ROOT="$(cd "$HERE/../.." && pwd)" PROJECT=gis-acceptance compose() { docker compose -p "$PROJECT" -f "$ROOT/deployments/docker-compose.yml" -f "$HERE/compose.acceptance.yml" "$@" } cmd="${1:-up}" shift || true case "$cmd" in up) echo "== build application image from $(git -C "$ROOT" rev-parse --short HEAD 2>/dev/null || echo 'this checkout')" compose build app worker echo "== start infrastructure ($PROJECT)" compose up -d --wait postgres minio rabbitmq echo "== migrate up" compose run --rm --no-deps app migrate up echo "== import districts" compose run --rm --no-deps app import-districts /stubs/districts.geojson compose up -d app worker echo "== wait for http://localhost:18080/readyz" for _ in $(seq 1 60); do if curl -fsS http://localhost:18080/readyz >/dev/null 2>&1; then curl -sS http://localhost:18080/readyz; echo compose ps --format 'table {{.Service}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}' exit 0 fi sleep 2 done echo "stand did not become ready" >&2 compose logs --tail 50 app worker >&2 exit 1 ;; down) compose down -v --remove-orphans ;; *) compose "$cmd" "$@" ;; esac