#!/bin/bash

# Check if .env file already exists
if [ -f .env ]; then
    echo ".env file already exists. Starting Docker Compose..."
else
    # Prompt the user for the Redis password
    read -p "Set a Redis port: " REDIS_PORT
    read -p "Enter your new Redis password: " REDIS_PASSWORD
    echo

    # Create the .env file and write the password
    cat <<EOL > .env
REDIS_PORT=$REDIS_PORT
REDIS_PASSWORD=$REDIS_PASSWORD

EOL

    # Inform the user

    echo ".env file created"
    echo
    echo "--------------------------------------------------------------"
    echo "Redis Database accesed with URI: http://127.0.0.1:$REDIS_PORT"
    echo "Redis password is: $REDIS_PASSWORD"
    echo "--------------------------------------------------------------"
fi

# Start Docker Compose
docker-compose up -d

# show docker container
echo
docker ps 
