pretendo-docker/scripts/internal/firstrun-mongodb-container.sh
Matthew Lopez 35e64a1044
Create verbose mode for all scripts and reduce default output
Man, dealing with passing arguments through multiple programs correctly is annoying. Tip: don't use eval, use "$@" instead.
2024-05-19 17:26:37 -04:00

19 lines
701 B
Bash
Executable File

#!/usr/bin/env bash
# shellcheck source=./framework.sh
source "$(dirname "$(realpath "$0")")/framework.sh"
parse_arguments "$@"
mongodb_init_script=$(cat "$git_base_dir/scripts/run-in-container/mongodb-init.js")
docker compose up -d mongodb
# This won't work in /docker-entrypoint-initdb.d/ because MongoDB is in a special init state where it will refuse to
# resolve anything but localhost. This needs to be run after it initializes.
# https://github.com/docker-library/mongo/issues/339
run_command_until_success "Waiting for MongoDB to be ready..." 10 \
docker compose exec mongodb mongosh --eval "db.adminCommand('ping')"
docker compose exec mongodb mongosh --eval "$mongodb_init_script"