feat: migrate secrets to Infisical
This commit is contained in:
@@ -7,23 +7,45 @@ if [ -z "$bundle_path" ] || [ ! -f "$bundle_path" ]; then
|
||||
echo "Usage: bootstrap-staging.sh <bootstrap-bundle.json> [deployment-directory]" >&2
|
||||
exit 2
|
||||
fi
|
||||
bundle_path=$(readlink -f "$bundle_path")
|
||||
|
||||
compose_file="$deployment_directory/compose.staging.yml"
|
||||
deploy_environment="$deployment_directory/.env.deploy"
|
||||
volume_bundle_path=/app/data/.staging-bootstrap-import.json
|
||||
remove_volume_bundle=false
|
||||
compose() {
|
||||
docker compose --env-file "$deploy_environment" -f "$compose_file" "$@"
|
||||
}
|
||||
restart_services() {
|
||||
compose up -d --no-build app scheduler
|
||||
cleanup() {
|
||||
status=$?
|
||||
trap - EXIT HUP INT TERM
|
||||
set +e
|
||||
if [ "$remove_volume_bundle" = true ]; then
|
||||
compose run --rm --no-deps --entrypoint rm --user root app -f "$volume_bundle_path"
|
||||
fi
|
||||
if ! compose up -d --no-build app scheduler; then status=1; fi
|
||||
exit "$status"
|
||||
}
|
||||
trap restart_services EXIT
|
||||
trap cleanup EXIT
|
||||
trap 'exit 129' HUP
|
||||
trap 'exit 130' INT
|
||||
trap 'exit 143' TERM
|
||||
|
||||
echo "Stopping staging before the one-time database bootstrap."
|
||||
compose stop scheduler app || true
|
||||
compose stop scheduler app
|
||||
compose create app >/dev/null
|
||||
app_container=$(compose ps --all --quiet app)
|
||||
if [ -z "$app_container" ]; then
|
||||
echo "The stopped staging app container could not be found." >&2
|
||||
exit 1
|
||||
fi
|
||||
docker cp "$bundle_path" "$app_container:$volume_bundle_path"
|
||||
remove_volume_bundle=true
|
||||
compose run --rm --no-deps --entrypoint sh --user root app -c \
|
||||
'chown shd-runtime:node "$1" && chmod 600 "$1"' sh "$volume_bundle_path"
|
||||
compose run --rm --no-deps \
|
||||
-e ALLOW_STAGING_BOOTSTRAP=true \
|
||||
-v "$bundle_path:/import/staging-bootstrap.json:ro" \
|
||||
app node scripts/stage-bootstrap-import.mjs \
|
||||
/import/staging-bootstrap.json --confirm-empty-staging-replace
|
||||
"$volume_bundle_path" --confirm-empty-staging-replace
|
||||
|
||||
echo "Staging bootstrap completed."
|
||||
|
||||
Reference in New Issue
Block a user