30 lines
950 B
Bash
30 lines
950 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
bundle_path=${1:-}
|
|
deployment_directory=${2:-/opt/shd-build-production}
|
|
if [ -z "$bundle_path" ] || [ ! -f "$bundle_path" ]; then
|
|
echo "Usage: bootstrap-production.sh <bootstrap-bundle.json> [deployment-directory]" >&2
|
|
exit 2
|
|
fi
|
|
|
|
compose_file="$deployment_directory/compose.production.yml"
|
|
deploy_environment="$deployment_directory/.env.deploy"
|
|
compose() {
|
|
docker compose --env-file "$deploy_environment" -f "$compose_file" "$@"
|
|
}
|
|
restart_services() {
|
|
compose up -d --no-build app scheduler
|
|
}
|
|
trap restart_services EXIT
|
|
|
|
echo "Stopping production before the one-time database bootstrap."
|
|
compose stop scheduler app || true
|
|
compose run --rm --no-deps \
|
|
-e ALLOW_PRODUCTION_BOOTSTRAP=true \
|
|
-v "$bundle_path:/import/production-bootstrap.json:ro" \
|
|
app node scripts/environment-bootstrap-import.mjs \
|
|
/import/production-bootstrap.json --target production --confirm-empty-target-replace
|
|
|
|
echo "Production bootstrap completed."
|