fix sso healtcheck

This commit is contained in:
lendry
2026-06-24 15:28:03 +03:00
parent 3aba59ef84
commit ecd95c5698
4 changed files with 36 additions and 7 deletions

View File

@@ -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"]

View 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