Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(root): Update Jarvis to run docker infra instead of through brew #5659

Merged
merged 16 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,9 @@
"whatsappbusiness",
"xkeysib",
"zulip",
"zwnj"
"zwnj",
"prepush",
"xcodebuild"
],
"flagWords": [],
"patterns": [
Expand Down
83 changes: 51 additions & 32 deletions scripts/dev-environment-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ success_message () {
echo " "
}

start_success_message () {
echo " "
echo "✅ $1 has been started"
echo " "
}

already_installed_message () {
echo " "
echo "✅ $1 is already installed"
Expand Down Expand Up @@ -383,43 +389,53 @@ install_aws_cli () {
fi
}

install_databases () {
SKIP="$(check_homebrew)"
start_database() {
# Check if brew is installed
command -v brew > /dev/null 2>&1

if [[ -z "$SKIP" ]]; then
installing_dependency "Databases"
# Initialize flag
already_installed=0

brew tap mongodb/brew
if [ $? -eq 0 ]; then

DATABASES=(
mongodb-community@5.0
redis
)
brew install "${DATABASES[@]}"

echo "Run the services in the background"
# Check if mongodb is installed
brew ls --versions mongodb > /dev/null
if [ $? -eq 0 ]; then
echo "Warning: MongoDB is already installed via brew. Please uninstall it first."
already_installed=1
fi

TEST_REDIS_CMD=$(execute_command_without_error_print "redis-cli --version")
if [[ -z "$TEST_REDIS_CMD" ]] || [[ "$TEST_REDIS_CMD" == "zsh: command not found: redis-cli" ]]; then
error_message "Redis"
else
echo "Run Redis service in the background"
brew services restart redis
success_message "MongoDB"
fi
# Check if redis is installed
brew ls --versions redis > /dev/null
if [ $? -eq 0 ]; then
echo "Warning: Redis is already installed via brew. Please uninstall it first."
already_installed=1
fi
else
echo "brew is not installed, checking default ports for MongoDB and Redis"
# Check MongoDB (port 27017) and Redis (port 6379)
if lsof -Pi :27017 -sTCP:LISTEN -t >/dev/null ; then
echo "Warning: MongoDB is running on port 27017. Please stop it first."
already_installed=1
fi
if lsof -Pi :6379 -sTCP:LISTEN -t >/dev/null ; then
echo "Warning: Redis is running on port 6379. Please stop it first."
already_installed=1
fi
fi

TEST_MONGO_CMD=$(execute_command_without_error_print "mongosh --version")
if [[ -z "$TEST_MONGO_CMD" ]] || [[ "$TEST_MONGO_CMD" == "zsh: command not found: mongosh" ]]; then
error_message "MongoDB"
else
echo "Run MongoDB service in the background"
brew services start mongodb/brew/mongodb-community@5.0
success_message "MongoDB"
fi
else
skip_message "Databases"
echo "$SKIP"
fi
# Only copy the example env file and start Docker Compose if both MongoDB and Redis are not already installed
if [ $already_installed -ne 1 ]; then
# Copy the example env file
cp ./docker/.env.example ./docker/local/development/.env

# Start Docker Compose detached
docker-compose -f ./docker/local/development/docker-compose.yml up -d

start_success_message "Docker Infrastructure"
echo "Note: To manually start go to /docker in the project"
fi
}

create_local_dev_domain () {
Expand Down Expand Up @@ -448,6 +464,9 @@ check_git () {
echo "⛔️ Git is a hard dependency to clone the monorepo"
exit 1
fi

already_installed_message "git"

}

clone_monorepo () {
Expand Down Expand Up @@ -489,8 +508,8 @@ install_novu_tools () {
install_node
install_pnpm
install_docker
install_databases
install_aws_cli
start_database
create_local_dev_domain
}

Expand Down
Loading