#!/bin/sh set -eu trap 'for service_pid in $service_pids; do kill "$service_pid" 2>/dev/null || true; done' EXIT service_pids="" for try_number in $(seq 1 30); do if pg_isready -h postgres -U postgres; then break; fi sleep 1 done psql -h postgres -U postgres -d postgres -v ON_ERROR_STOP=1 <<'SQL' CREATE ROLE atlas_inventory LOGIN; CREATE ROLE atlas_intake LOGIN; CREATE DATABASE itematlas_inventory OWNER atlas_inventory; CREATE DATABASE itematlas_intake OWNER atlas_intake; SQL export SPRING_PROFILES_ACTIVE=local ATLAS_DB_PASSWORD="" JAVA_TOOL_OPTIONS="-Xmx192m" ATLAS_DB_USER=atlas_inventory ATLAS_DB_URL=jdbc:postgresql://postgres:5432/itematlas_inventory \ java -jar backend/inventory-service/target/app.jar > /tmp/atlas-inventory.log 2>&1 & service_pids="$!" ATLAS_DB_USER=atlas_intake ATLAS_DB_URL=jdbc:postgresql://postgres:5432/itematlas_intake \ java -jar backend/intake-service/target/app.jar > /tmp/atlas-intake.log 2>&1 & service_pids="$service_pids $!" java -jar backend/gateway/target/app.jar > /tmp/atlas-gateway.log 2>&1 & service_pids="$service_pids $!" if ! python3 backend/tests/smoke.py; then tail -80 /tmp/atlas-inventory.log /tmp/atlas-intake.log /tmp/atlas-gateway.log exit 1 fi