Files
Mdeical_Sur_Report/scripts/docker-api-entrypoint.sh
admin 5d936832da Complete Docker compose deployment setup
- Add an API container entrypoint that waits for PostgreSQL, runs Prisma migrations, seeds demo data, and then starts NestJS.

- Keep Prisma CLI and seed dependencies available in the API runtime image and copy seed source dependencies into the container.

- Add Docker Compose healthchecks and health-based startup ordering for PostgreSQL, API, and Nginx web services.

- Add Docker initialization environment switches for migrations, seed, and startup retries.

- Add a dedicated Docker deployment guide covering services, ports, initialization, HTTPS, production variables, backup, restore, and troubleshooting.

- Update README, AGENTS, installation, deployment, progress, and environment example docs for the Dockerized workflow.
2026-05-02 05:38:03 +08:00

31 lines
774 B
Bash

#!/bin/sh
set -e
run_with_retry() {
name="$1"
shift
attempts="${DOCKER_STARTUP_RETRIES:-30}"
delay="${DOCKER_STARTUP_RETRY_DELAY:-2}"
current=1
until "$@"; do
if [ "$current" -ge "$attempts" ]; then
echo "Docker startup step failed after ${attempts} attempts: ${name}" >&2
return 1
fi
echo "Docker startup step not ready (${current}/${attempts}): ${name}. Retrying in ${delay}s..." >&2
current=$((current + 1))
sleep "$delay"
done
}
if [ "${RUN_DB_MIGRATIONS:-true}" = "true" ]; then
run_with_retry "prisma migrate deploy" npx prisma migrate deploy --schema server/prisma/schema.prisma
fi
if [ "${RUN_DB_SEED:-true}" = "true" ]; then
run_with_retry "prisma db seed" npm run prisma:seed
fi
exec node server/dist/main.js