Stabilize discovery workflow

This commit is contained in:
2026-05-29 17:16:46 +08:00
parent 15772bc17e
commit 3981ffdf5e
40 changed files with 2039 additions and 211 deletions
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -f .env ]]; then
cp .env.example .env
echo "Created .env from .env.example. Edit secrets before production use."
fi
echo "=== build and start database/app ==="
docker compose up -d --build db app
echo "=== wait for database ==="
attempt=1
max_attempts=60
until docker compose exec -T app php -r '
$host = getenv("DB_HOST") ?: "db";
$port = (int)(getenv("DB_PORT") ?: 3306);
$database = getenv("DB_DATABASE") ?: "domovoy";
$username = getenv("DB_USERNAME") ?: "domovoy";
$password = getenv("DB_PASSWORD") ?: "domovoy";
try {
new PDO(
sprintf("mysql:host=%s;port=%d;dbname=%s;charset=utf8mb4", $host, $port, $database),
$username,
$password,
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);
exit(0);
} catch (Throwable $e) {
fwrite(STDERR, $e->getMessage() . PHP_EOL);
exit(1);
}
' >/dev/null 2>&1; do
if (( attempt >= max_attempts )); then
echo "Database did not become ready after ${max_attempts} attempts" >&2
exit 1
fi
sleep 1
attempt=$((attempt + 1))
done
echo "=== run database migrations ==="
docker compose exec -T app php vendor/bin/phinx migrate
echo "=== start web and worker ==="
docker compose up -d --build web worker
port="$(grep -E '^DOMOVOY_HTTP_PORT=' .env | tail -n 1 | cut -d= -f2- || true)"
port="${port:-8080}"
echo "=== ready ==="
echo "Open http://localhost:${port}"
+10 -7
View File
@@ -13,16 +13,19 @@ find app public bin -name "*.php" -print0 | xargs -0 -n1 php -l
echo "=== docker compose config ==="
docker compose config > /dev/null
echo "=== docker compose up ==="
docker compose up -d --build
echo "=== docker compose port config ==="
bash scripts/test-compose-config.sh
echo "=== wait for db ==="
sleep 5
echo "=== docker compose worker config ==="
bash scripts/test-worker-config.sh
echo "=== phinx migrate ==="
docker compose exec app php vendor/bin/phinx migrate
echo "=== bootstrap docker stack ==="
bash scripts/bootstrap.sh
http_port="$(grep -E '^DOMOVOY_HTTP_PORT=' .env 2>/dev/null | tail -n 1 | cut -d= -f2- || true)"
http_port="${http_port:-8080}"
echo "=== HTTP health check ==="
curl -sI http://localhost:8080/login | head -1
curl -sI "http://localhost:${http_port}/login" | head -1
echo "=== ALL CHECKS PASSED ==="
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -x scripts/bootstrap.sh ]]; then
echo "Expected executable scripts/bootstrap.sh" >&2
exit 1
fi
if ! grep -q "./scripts/bootstrap.sh" README.md; then
echo "Expected README.md to document ./scripts/bootstrap.sh" >&2
exit 1
fi
if grep -q "bin/setup first-admin" README.md; then
echo "README.md still references removed bin/setup first-admin command" >&2
exit 1
fi
echo "bootstrap docs ok"
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
output="$(DOMOVOY_HTTP_PORT=18080 docker compose config)"
if ! grep -q "published: \"18080\"" <<< "$output"; then
echo "Expected web service to publish DOMOVOY_HTTP_PORT=18080" >&2
exit 1
fi
echo "compose port config ok"
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
output="$(docker compose config)"
if ! grep -q "container_name: domovoy-worker" <<< "$output"; then
echo "Expected compose config to define domovoy-worker" >&2
exit 1
fi
if ! grep -q -- "- bin/run-scan-worker.php" <<< "$output" || ! grep -q -- "- --loop" <<< "$output"; then
echo "Expected worker to run bin/run-scan-worker.php --loop" >&2
exit 1
fi
echo "worker config ok"