- Translated comments from Spanish to English in vite.config.ts, docker-compose.yml, attendance-risk.ts, analytics.ts, attendance.ts, attendees.ts, enums.ts, groups.ts, and onboarding.ts. - Improved descriptions for better understanding of code functionality and purpose. - Ensured uniformity in terminology and phrasing throughout the codebase.
43 lines
1.3 KiB
Bash
Executable File
43 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# Production entrypoint for the backend: applies the migrations and starts the
|
|
# server in the same container.
|
|
#
|
|
# This is POSIX sh, not bash: the image is alpine and does not ship bash
|
|
# installed (adding it would be ~10MB for a shebang).
|
|
#
|
|
# Set RUN_MIGRATIONS=false to start without touching the database (for example,
|
|
# a database already migrated by hand, or one managed outside this deployment).
|
|
set -e
|
|
|
|
: "${DATABASE_URL:?falta DATABASE_URL}"
|
|
|
|
if [ "${RUN_MIGRATIONS:-true}" = "false" ]; then
|
|
echo "migrate: omitido (RUN_MIGRATIONS=false)"
|
|
else
|
|
attempts="${MIGRATE_ATTEMPTS:-30}"
|
|
delay="${MIGRATE_RETRY_DELAY:-5}"
|
|
i=1
|
|
|
|
# The database may still be starting up when this container is already
|
|
# running, and a deploy usually overlaps a Postgres restart.
|
|
while [ "$i" -le "$attempts" ]; do
|
|
if bun run db:deploy; then
|
|
echo "migrate: listo"
|
|
break
|
|
fi
|
|
|
|
if [ "$i" -eq "$attempts" ]; then
|
|
echo "migrate: fallo tras $attempts intentos; no se levanta el servidor" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "migrate: intento $i/$attempts fallo; reintento en ${delay}s" >&2
|
|
i=$((i + 1))
|
|
sleep "$delay"
|
|
done
|
|
fi
|
|
|
|
# exec so that Bun becomes PID 1 and receives the SIGTERM from `docker stop`
|
|
# (the server uses it to close Bun.serve and disconnect Prisma).
|
|
exec "$@"
|