initial commit

This commit is contained in:
TakuyaYagam1 committed 2026-10-05 14:23:31 +03:00
commit 88c14b627e
224 files changed
+17204

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
compose_file="$root/deploy/docker/docker-compose.yml"
env_file="$root/.env.example"
project=lincodex-smoke
app_network="${project}_default"
port=18080
volume="${project}_postgres_data"
network="${project}_default"
started=0
compose() {
APP_PROJECT="$project" APP_NETWORK="$app_network" APP_HTTP_PORT="$port" docker compose \
--env-file "$env_file" \
-p "$project" \
-f "$compose_file" \
"$@"
}
if docker volume inspect "$volume" >/dev/null 2>&1; then
printf 'Refusing to use existing smoke volume %s.\n' "$volume" >&2
exit 2
fi
if docker network inspect "$network" >/dev/null 2>&1; then
printf 'Refusing to use existing smoke network %s.\n' "$network" >&2
exit 2
fi
for dockerfile in "$root/backend/Dockerfile" "$root/frontend/Dockerfile"; do
if [[ ! -f "$dockerfile" ]]; then
printf 'Missing required build file %s.\n' "$dockerfile" >&2
exit 2
fi
done
if [[ -n "$(compose ps -q 2>/dev/null || true)" ]]; then
printf 'Refusing to use existing Compose project %s.\n' "$project" >&2
exit 2
fi
cleanup() {
local result=$?
trap - EXIT
if (( started )); then
if ! compose down --volumes --remove-orphans; then
printf '%s\n' 'Smoke cleanup failed; inspect only the lincodex-smoke Compose project.' >&2
result=1
fi
fi
exit "$result"
}
trap cleanup EXIT
compose config --quiet
started=1
compose up --build -d --wait --wait-timeout 120
wait_for() {
local url=$1
local attempt
for attempt in {1..60}; do
if curl --fail --silent --show-error "$url" >/dev/null 2>&1; then
return 0
fi
sleep 1
done
printf 'Timed out waiting for %s.\n' "$url" >&2
return 1
}
wait_for "http://127.0.0.1:$port/healthz"
wait_for "http://127.0.0.1:$port/api/v1/healthz"
readiness=$(compose exec -T frontend wget -q -O - http://backend:8080/readyz)
if [[ "$readiness" != '{"status":"ready"}' ]]; then
printf 'Backend did not confirm database readiness: %s\n' "$readiness" >&2
exit 1
fi
status=$(curl --silent --show-error --output /dev/null --write-out '%{http_code}' \
"http://127.0.0.1:$port/api/v1/missing")
if [[ "$status" != 404 ]]; then
printf 'Unknown API route returned %s instead of 404.\n' "$status" >&2
exit 1
fi
printf '%s\n' 'Technical smoke passed: frontend, API routing, and PostgreSQL readiness.'