fix sso healtcheck
This commit is contained in:
@@ -41,6 +41,9 @@ RUN npm --workspace @lendry/sso-core run prisma:generate \
|
||||
&& npm --workspace @lendry/sso-core run proto:generate \
|
||||
&& npm --workspace @lendry/sso-core run build
|
||||
|
||||
COPY apps/sso-core/docker-entrypoint.sh /app/apps/sso-core/docker-entrypoint.sh
|
||||
RUN chmod +x /app/apps/sso-core/docker-entrypoint.sh
|
||||
|
||||
EXPOSE 3001 50051
|
||||
|
||||
CMD ["sh", "-c", "npm --workspace @lendry/sso-core run prisma:push && node apps/sso-core/dist/main.js"]
|
||||
CMD ["/app/apps/sso-core/docker-entrypoint.sh"]
|
||||
|
||||
23
apps/sso-core/docker-entrypoint.sh
Normal file
23
apps/sso-core/docker-entrypoint.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "[sso-core] Применение схемы БД (Prisma)..."
|
||||
attempt=0
|
||||
max_attempts=30
|
||||
|
||||
while [ "$attempt" -lt "$max_attempts" ]; do
|
||||
attempt=$((attempt + 1))
|
||||
if npm --workspace @lendry/sso-core run prisma:push; then
|
||||
echo "[sso-core] Схема БД синхронизирована"
|
||||
break
|
||||
fi
|
||||
if [ "$attempt" -ge "$max_attempts" ]; then
|
||||
echo "[sso-core] ОШИБКА: не удалось подключиться к PostgreSQL после ${max_attempts} попыток." >&2
|
||||
echo "[sso-core] Проверьте POSTGRES_* в .env и пароль существующего volume postgres_data." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "[sso-core] PostgreSQL недоступен или неверный пароль, повтор ${attempt}/${max_attempts}..."
|
||||
sleep 3
|
||||
done
|
||||
|
||||
exec node apps/sso-core/dist/main.js
|
||||
@@ -110,10 +110,11 @@ services:
|
||||
ldap-auth:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "node -e \"fetch('http://localhost:3001/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\""]
|
||||
test: ["CMD-SHELL", "node -e \"fetch('http://127.0.0.1:3001/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\""]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
timeout: 10s
|
||||
retries: 12
|
||||
start_period: 120s
|
||||
|
||||
api-gateway:
|
||||
pull_policy: build
|
||||
@@ -143,10 +144,11 @@ services:
|
||||
minio:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "node -e \"fetch('http://localhost:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\""]
|
||||
test: ["CMD-SHELL", "node -e \"fetch('http://127.0.0.1:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\""]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
timeout: 10s
|
||||
retries: 12
|
||||
start_period: 60s
|
||||
|
||||
media-ws:
|
||||
pull_policy: build
|
||||
|
||||
@@ -1328,6 +1328,7 @@ deploy_stack() {
|
||||
log "Сборка и запуск контейнеров (10–20 минут при первом запуске)..."
|
||||
docker_cmd "${compose_cmd[@]}" up -d --build
|
||||
|
||||
wait_for_service "sso-core" 120
|
||||
wait_for_service "api-gateway" 90
|
||||
wait_for_service "frontend" 60
|
||||
wait_for_service "docs" 60
|
||||
|
||||
Reference in New Issue
Block a user