From b5ce81cde71c40bbe7e1ea9678ce1eb20b53d52d Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Thu, 22 Aug 2024 11:57:21 +0530 Subject: [PATCH] fix: refactor --- docker-compose/setup-script/noco.sh | 1061 +++++++++++---------------- 1 file changed, 417 insertions(+), 644 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index aaed08f621..d469cd1c5a 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -1,9 +1,13 @@ #!/bin/bash -# set -x -# ****************************************************************************** -# ***************** GLOBAL VARIABLES START ********************************* +set -e +# Constants +NOCO_HOME="./nocodb" +CURRENT_PATH=$(pwd) +REQUIRED_PORTS=(80 443) + +# Color definitions RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' @@ -14,39 +18,36 @@ ORANGE='\033[0;33m' BOLD='\033[1m' NC='\033[0m' -NOCO_HOME="./nocodb" -# Get the current working directory -CURRENT_PATH=$(pwd) - -# ***************** GLOBAL VARIABLES END *********************************** -# ****************************************************************************** +# Global variables +CONFIG_DOMAIN_NAME="" +CONFIG_SSL_ENABLED="" +CONFIG_EDITION="" +CONFIG_LICENSE_KEY="" +CONFIG_REDIS_ENABLED="" +CONFIG_MINIO_ENABLED="" +CONFIG_MINIO_DOMAIN_NAME="" +CONFIG_MINIO_SSL_ENABLED="" +CONFIG_WATCHTOWER_ENABLED="" +CONFIG_NUM_INSTANCES="" +CONFIG_POSTGRES_PASSWORD="" +CONFIG_REDIS_PASSWORD="" +CONFIG_MINIO_ACCESS_KEY="" +CONFIG_MINIO_ACCESS_SECRET="" +CONFIG_DOCKER_COMMAND="" + +declare -a message_arr + +# Utility functions +print_color() { printf "${1}%s${NC}\n" "$2"; } +print_info() { print_color "$BLUE" "INFO: $1"; } +print_success() { print_color "$GREEN" "SUCCESS: $1"; } +print_warning() { print_color "$YELLOW" "WARNING: $1"; } +print_error() { print_color "$RED" "ERROR: $1"; } -# ****************************************************************************** -# ***************** HELPER FUNCTIONS START ********************************* - -# Function to URL encode special characters in a string -urlencode() { - local string="$1" - local strlen=${#string} - local encoded="" - local pos c o - - for (( pos=0 ; pos/dev/null 2>&1 +command_exists() { command -v "$1" >/dev/null 2>&1; } + +urlencode() { + local string="$1" + local strlen=${#string} + local encoded="" + local pos c o + + for (( pos=0 ; pos/dev/null; then + print_warning "Port $port is in use. Please make sure it is free." else - trap 'show_logs' INT - $DOCKER_COMMAND compose logs -f "$service" + print_info "Port $port is free." fi - elif [ "$log_choice" == "A" ] || [ "$log_choice" == "a" ]; then - trap 'show_logs' INT - $DOCKER_COMMAND compose logs -f - elif [ "$log_choice" == "0" ]; then - return - else - show_logs - fi + done - trap - INT + print_success "System check completed successfully" } -# Function to restart the service -restart_service() { - echo -e "\nRestarting nocodb..." - $DOCKER_COMMAND compose restart -} +get_user_inputs() { + CONFIG_DOMAIN_NAME=$(prompt "Enter the IP address or domain name for the NocoDB instance" "$(get_public_ip)") -# Function to upgrade the service -upgrade_service() { - echo -e "\nUpgrading nocodb..." - $DOCKER_COMMAND compose pull - $DOCKER_COMMAND compose up -d --force-recreate - $DOCKER_COMMAND image prune -a -f -} - -# Function to scale the service -scale_service() { - num_cores=$(nproc || sysctl -n hw.ncpu || echo 1) - current_scale=$($DOCKER_COMMAND compose ps -q nocodb | wc -l) - echo -e "\nCurrent number of instances: $current_scale" - echo "How many instances of NocoDB do you want to run (Maximum: ${num_cores}) ? (default: 1): " - scale_num=$(read_number_range 1 "$num_cores") - - if [ "$scale_num" -eq "$current_scale" ]; then - echo "Number of instances is already set to $scale_num. Returning to main menu." - return + if confirm "Show Advanced Options?"; then + get_advanced_options + else + set_default_options fi - - $DOCKER_COMMAND compose up -d --scale nocodb="$scale_num" } -# Function for basic monitoring -monitoring_service() { - echo -e '\nLoading stats...' - trap ' ' INT - $DOCKER_COMMAND stats -} - -management_menu() { - # Main program loop - while true; do - trap - INT - show_menu - echo "Enter your choice: " - - read -r choice - case $choice in - 1) start_service && MSG="NocoDB Started" ;; - 2) stop_service && MSG="NocoDB Stopped" ;; - 3) show_logs ;; - 4) restart_service && MSG="NocoDB Restarted" ;; - 5) upgrade_service && MSG="NocoDB has been upgraded to latest version" ;; - 6) scale_service && MSG="NocoDB has been scaled" ;; - 7) monitoring_service ;; - 0) exit 0 ;; - *) MSG="\nInvalid choice. Please select a correct option." ;; - esac - done -} - -# ****************************************************************************** -# *************************** Management END ********************************** - - -# ****************************************************************************** -# ***************** Existing Install Test ************************************ - -IS_DOCKER_REQUIRE_SUDO=$(check_for_docker_sudo) -DOCKER_COMMAND=$([ "$IS_DOCKER_REQUIRE_SUDO" = "y" ] && echo "sudo docker" || echo "docker") - -NOCO_FOUND=false - -# Check if $NOCO_HOME exists as directory -if [ -d "$NOCO_HOME" ]; then - NOCO_FOUND=true -elif $DOCKER_COMMAND ps --format '{{.Names}}' | grep -q "nocodb"; then - NOCO_ID=$(docker ps | grep "nocodb/nocodb" | cut -d ' ' -f 1) - CUSTOM_HOME=$(docker inspect --format='{{index .Mounts 0}}' "$NOCO_ID" | cut -d ' ' -f 3) - PARENT_DIR=$(dirname "$CUSTOM_HOME") - - ln -s "$PARENT_DIR" "$NOCO_HOME" - basename "$PARENT_DIR" > "$NOCO_HOME/.COMPOSE_PROJECT_NAME" - - NOCO_FOUND=true -else - mkdir -p "$NOCO_HOME" -fi - -cd "$NOCO_HOME" || exit 1 - -# Check if nocodb is already installed -if [ "$NOCO_FOUND" = true ]; then - echo "NocoDB is already installed. And running." - echo "Do you want to reinstall NocoDB? [Y/N] (default: N): " - read -r REINSTALL - - if [ -f "$NOCO_HOME/.COMPOSE_PROJECT_NAME" ]; then - COMPOSE_PROJECT_NAME=$(cat "$NOCO_HOME/.COMPOSE_PROJECT_NAME") - export COMPOSE_PROJECT_NAME - fi +get_advanced_options() { + CONFIG_SSL_ENABLED=$(confirm "Do you want to configure SSL?" && echo "Y" || echo "N") + CONFIG_EDITION=$(prompt "Choose Community or Enterprise Edition [CE/EE]" "CE") - if [ "$REINSTALL" != "Y" ] && [ "$REINSTALL" != "y" ]; then - management_menu - exit 0 - else - echo "Reinstalling NocoDB..." - $DOCKER_COMMAND compose down - - unset COMPOSE_PROJECT_NAME - cd /tmp || exit 1 - rm -rf "$NOCO_HOME" - - cd "$CURRENT_PATH" || exit 1 - mkdir -p "$NOCO_HOME" - cd "$NOCO_HOME" || exit 1 + if [ "${CONFIG_EDITION}" = "EE" ] || [ "$CONFIG_EDITION}" = "ee" ]; then + CONFIG_LICENSE_KEY=$(prompt_required "Enter the NocoDB license key") fi -fi - -# ****************************************************************************** -# ******************** SYSTEM REQUIREMENTS CHECK START ************************* + CONFIG_REDIS_ENABLED=$(confirm "Do you want to enable Redis for caching?" "Y" && echo "Y" || echo "N") + CONFIG_MINIO_ENABLED=$(confirm "Do you want to enable Minio for file storage?" "Y" && echo "Y" || echo "N") -# Check if the following requirements are met: -# a. docker, jq installed -# b. port mapping check : 80,443 are free or being used by nginx container - -REQUIRED_PORTS=(80 443) - -echo "** Performing nocodb system check and setup. This step may require sudo permissions" - -# pre-install wget if not found -if ! command_exists wget; then - echo "wget is not installed. Setting up for installation..." - install_package wget -fi - -# d. Check if required tools are installed -echo " | Checking if required tools (docker, lsof) are installed..." -for tool in docker lsof openssl; do - if ! command_exists "$tool"; then - echo "$tool is not installed. Setting up for installation..." - if [ "$tool" = "docker" ]; then - wget -qO- https://get.docker.com/ | sh - elif [ "$tool" = "lsof" ]; then - install_package lsof + if [ "${CONFIG_MINIO_ENABLED}" = "Y" ] || [ "$CONFIG_MINIO_ENABLED}" = "y" ]; then + CONFIG_MINIO_DOMAIN_NAME=$(prompt "Enter the MinIO domain name" "localhost") + CONFIG_MINIO_SSL_ENABLED=$(confirm "Do you want to configure SSL for MinIO?" && echo "Y" || echo "N") fi - fi -done - - -# f. Port mapping check -echo " | Checking port accessibility..." -for port in "${REQUIRED_PORTS[@]}"; do - if lsof -Pi :"$port" -sTCP:LISTEN -t >/dev/null; then - echo " | WARNING: Port $port is in use. Please make sure it is free." >&2 - else - echo " | Port $port is free." - fi -done - -echo "** System check completed successfully. **" - - -# Define an array to store the messages to be printed at the end -message_arr=() -# extract public ip address -PUBLIC_IP=$(dig +short myip.opendns.com @1.1.1.1) + CONFIG_WATCHTOWER_ENABLED=$(confirm "Do you want to enable Watchtower for automatic updates?" "Y" && echo "Y" || echo "N") -# Check if the public IP address is not empty, if empty then use the localhost -if [ -z "$PUBLIC_IP" ]; then - PUBLIC_IP="localhost" -fi - -message_arr+=("Setup folder: $NOCO_HOME") - -# ******************** SYSTEM REQUIREMENTS CHECK END ************************** -# ****************************************************************************** - - - -# ******************** INPUTS FROM USER START ******************************** -# ****************************************************************************** - -echo "Enter the IP address or domain name for the NocoDB instance (default: $PUBLIC_IP): " -read -r DOMAIN_NAME - -echo "Show Advanced Options [Y/N] (default: N): " -read -r ADVANCED_OPTIONS - -if [ "$ADVANCED_OPTIONS" == "Y" ]; then - ADVANCED_OPTIONS="y" -fi - -if [ -n "$DOMAIN_NAME" ]; then - if [ "$ADVANCED_OPTIONS" == "y" ]; then - echo "Do you want to configure SSL [Y/N] (default: N): " - read -r SSL_ENABLED - message_arr+=("SSL: ${SSL_ENABLED}") - fi -else - DOMAIN_NAME="$PUBLIC_IP" -fi - -message_arr+=("Domain: $PUBLIC_IP") - -if [ "$ADVANCED_OPTIONS" == "y" ]; then - echo "Choose Community or Enterprise Edition [CE/EE] (default: CE): " - read -r EDITION -fi - -if [ -n "$EDITION" ] && { [ "$EDITION" = "EE" ] || [ "$EDITION" = "ee" ]; }; then - echo "Enter the NocoDB license key: " - read -r LICENSE_KEY - if [ -z "$LICENSE_KEY" ]; then - echo "License key is required for Enterprise Edition installation" - exit 1 - fi -fi - -# Configure Redis for caching -if [ "$ADVANCED_OPTIONS" == "y" ]; then - echo "Do you want to enabled Redis for caching [Y/N] (default: Y): " - read -r REDIS_ENABLED -fi - -if [ -z "$REDIS_ENABLED" ] || { [ "$REDIS_ENABLED" != "N" ] && [ "$REDIS_ENABLED" != "n" ]; }; then - message_arr+=("Redis: Enabled") -else - message_arr+=("Redis: Disabled") -fi - -# Configure Minio for file storage -if [ "$ADVANCED_OPTIONS" == "y" ]; then - echo "Do you want to enable Minio for file storage [Y/N] (default: Y): " - read -r MINIO_ENABLED - if [ -z "$MINIO_ENABLED" ] || { [ "$MINIO_ENABLED" != "N" ] && [ "$MINIO_ENABLED" != "n" ]; }; then - message_arr+=("Minio: Enabled") - MINIO_ENABLED="y" - else - message_arr+=("Minio: Disabled") - fi -fi -# Minio Domain Name and SSL Configuration + NUM_CORES=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) + CONFIG_NUM_INSTANCES=$(prompt_number "How many instances of NocoDB do you want to run?" 1 "$NUM_CORES") +} -MINIO_DOMAIN_NAME="minio" -MINIO_SSL_ENABLED="n" +set_default_options() { + CONFIG_SSL_ENABLED="N" + CONFIG_EDITION="CE" + CONFIG_REDIS_ENABLED="Y" + CONFIG_MINIO_ENABLED="Y" + CONFIG_MINIO_DOMAIN_NAME="localhost" + CONFIG_MINIO_SSL_ENABLED="N" + CONFIG_WATCHTOWER_ENABLED="Y" + CONFIG_NUM_INSTANCES=1 +} -if [ "$ADVANCED_OPTIONS" == "y" ]; then - echo "Enter the MinIO domain name (default: $MINIO_DOMAIN_NAME): " - read -r USER_MINIO_DOMAIN_NAME +generate_credentials() { + CONFIG_POSTGRES_PASSWORD=$(generate_password) + CONFIG_REDIS_PASSWORD=$(generate_password) + CONFIG_MINIO_ACCESS_KEY=$(generate_password) + CONFIG_MINIO_ACCESS_SECRET=$(generate_password) +} - if [ -n "$USER_MINIO_DOMAIN_NAME" ]; then - MINIO_DOMAIN_NAME="$USER_MINIO_DOMAIN_NAME" - fi +create_docker_compose_file() { - # Ask to configure SSL only if MINIO_DOMAIN_NAME is set - if [ -n "$USER_MINIO_DOMAIN_NAME" ]; then - echo "Do you want to configure SSL for MinIO [Y/N] (default: N): " - read -r USER_MINIO_SSL_ENABLED + image="nocodb/nocodb:latest" - if [ -n "$USER_MINIO_SSL_ENABLED" ]; then - MINIO_SSL_ENABLED=$(echo "$USER_MINIO_SSL_ENABLED" | tr '[:upper:]' '[:lower:]') - fi + if [ "${CONFIG_EDITION}" = "EE" ] || [ "${CONFIG_EDITION}" = "ee" ]; then + image="nocodb/ee:latest" fi -fi -# Configure Watchtower for automatic updates -if [ "$ADVANCED_OPTIONS" == "y" ]; then - echo "Do you want to enabled Watchtower for automatic updates [Y/N] (default: Y): " - read -r WATCHTOWER_ENABLED -fi + local compose_file="docker-compose.yml" -if [ -z "$WATCHTOWER_ENABLED" ] || { [ "$WATCHTOWER_ENABLED" != "N" ] && [ "$WATCHTOWER_ENABLED" != "n" ]; }; then - message_arr+=("Watchtower: Enabled") -else - message_arr+=("Watchtower: Disabled") -fi - -# Configure the number of instances to run -if [ "$ADVANCED_OPTIONS" = "y" ] ; then - NUM_CORES=$(nproc || sysctl -n hw.ncpu || echo 1) - echo "How many instances of NocoDB do you want to run (Maximum: ${NUM_CORES}) ? (default: 1): " - NUM_INSTANCES=$(read_number_range 1 "$NUM_CORES") -fi - -if [ -z "$NUM_INSTANCES" ]; then - NUM_INSTANCES=1 -fi - -message_arr+=("Number of instances: $NUM_INSTANCES") - -# ****************************************************************************** -# *********************** INPUTS FROM USER END ******************************** - - -# ****************************************************************************** -# *************************** SETUP START ************************************* - -# Generate a strong random password for PostgreSQL -STRONG_PASSWORD=$(openssl rand -base64 48 | tr -dc 'a-zA-Z0-9!@#$%^&*()-_+=' | head -c 32) -REDIS_PASSWORD=$(openssl rand -base64 48 | tr -dc 'a-zA-Z0-9' | head -c 24) -MINIO_ACCESS_KEY=$(openssl rand -base64 48 | tr -dc 'a-zA-Z0-9' | head -c 24) -MINIO_ACCESS_SECRET=$(openssl rand -base64 48 | tr -dc 'a-zA-Z0-9' | head -c 24) -# Encode special characters in the password for JDBC URL usage -ENCODED_PASSWORD=$(urlencode "$STRONG_PASSWORD") - -IMAGE="nocodb/nocodb:latest"; - -# Determine the Docker image to use based on the edition -if [ -n "$EDITION" ] && { [ "$EDITION" = "EE" ] || [ "$EDITION" = "ee" ]; }; then - IMAGE="nocodb/nocodb-ee:latest" - DATABASE_URL="DATABASE_URL=postgres://postgres:${ENCODED_PASSWORD}@db:5432/nocodb" -else - # use NC_DB url until the issue with DATABASE_URL is resolved(encoding) - DATABASE_URL="NC_DB=pg://db:5432?d=nocodb&user=postgres&password=${ENCODED_PASSWORD}" -fi - - -message_arr+=("Docker image: $IMAGE") - - -DEPENDS_ON="" -MINIO_DEPENDS_ON="" - -# Add Redis service if enabled -if [ -z "$REDIS_ENABLED" ] || { [ "$REDIS_ENABLED" != "N" ] && [ "$REDIS_ENABLED" != "n" ]; }; then - DEPENDS_ON="- redis" -fi - -# Add Minio service if enabled -if [ -z "$MINIO_ENABLED" ] || { [ "$MINIO_ENABLED" != "N" ] && [ "$MINIO_ENABLED" != "n" ]; }; then - MINIO_DEPENDS_ON="- minio" -fi - -# Write the Docker Compose file with the updated password -cat < docker-compose.yml + cat > "$compose_file" <> docker-compose.yml - - "traefik.http.routers.nocodb.entrypoints=web" -EOF -else - cat <> docker-compose.yml - - "traefik.http.routers.nocodb.entrypoints=websecure" - - "traefik.http.routers.nocodb.tls=true" - - "traefik.http.routers.nocodb.tls.certresolver=letsencrypt" -EOF -fi - -cat <> docker-compose.yml + - "traefik.http.routers.nocodb.rule=Host(\`${CONFIG_DOMAIN_NAME}\`)" + - "traefik.http.routers.nocodb.entrypoints=${CONFIG_SSL_ENABLED:+websecure}" + ${CONFIG_SSL_ENABLED:+- "traefik.http.routers.nocodb.tls=true"} + ${CONFIG_SSL_ENABLED:+- "traefik.http.routers.nocodb.tls.certresolver=letsencrypt"} networks: - nocodb-network + db: image: postgres:16.1 env_file: docker.env @@ -688,10 +394,10 @@ cat <> docker-compose.yml - ./postgres:/var/lib/postgresql/data restart: unless-stopped healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s - retries: 10 - test: "pg_isready -U \"\$\$POSTGRES_USER\" -d \"\$\$POSTGRES_DB\"" - timeout: 2s + timeout: 5s + retries: 5 networks: - nocodb-network @@ -702,27 +408,12 @@ cat <> docker-compose.yml - "--providers.docker=true" - "--entrypoints.web.address=:80" - "--providers.docker.exposedByDefault=false" - - "--certificatesresolvers.letsencrypt.acme.httpchallenge=true" - - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web" -EOF -if [ "MINIO_ENABLED" != 'n' ] && [ "MINIO_ENABLED" != 'N' ]; then - cat <> docker-compose.yml - "--entrypoints.minio.address=:9000" -EOF -fi - -if [ "$SSL_ENABLED" = 'y' ] || [ "$SSL_ENABLED" = 'Y' ] || [ "$MINIO_SSL_ENABLED" = 'y' ] || [ "$MINIO_SSL_ENABLED" = 'Y' ]; then - cat <> docker-compose.yml - - "--entrypoints.websecure.address=:443" - - "--certificatesresolvers.letsencrypt.acme.email=$(generate_contact_email "$DOMAIN_NAME")" - - "--certificatesresolvers.letsencrypt.acme.storage=/etc/letsencrypt/acme.json" -EOF -else - cat <> docker-compose.yml -EOF -fi - -cat <> docker-compose.yml + ${CONFIG_SSL_ENABLED:+- "--entrypoints.websecure.address=:443"} + ${CONFIG_SSL_ENABLED:+- "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"} + ${CONFIG_SSL_ENABLED:+- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"} + ${CONFIG_SSL_ENABLED:+- "--certificatesresolvers.letsencrypt.acme.email=$(generate_contact_email "${CONFIG_DOMAIN_NAME}")"} + ${CONFIG_SSL_ENABLED:+- "--certificatesresolvers.letsencrypt.acme.storage=/etc/letsencrypt/acme.json"} ports: - "80:80" - "443:443" @@ -735,30 +426,31 @@ cat <> docker-compose.yml - ./letsencrypt:/etc/letsencrypt networks: - nocodb-network + EOF -if [ -z "$REDIS_ENABLED" ] || { [ "$REDIS_ENABLED" != "N" ] && [ "$REDIS_ENABLED" != "n" ]; }; then -cat <> docker-compose.yml + if [ "${CONFIG_REDIS_ENABLED}" = "Y" ]; then + cat >> "$compose_file" <> docker-compose.yml + if [ "${CONFIG_MINIO_ENABLED}" = "Y" ]; then + cat >> "$compose_file" <> docker-compose.yml - - "traefik.http.routers.minio.rule=Host(\`$MINIO_DOMAIN_NAME\`)" - - "traefik.http.routers.minio.entrypoints=websecure" - - "traefik.http.routers.minio.tls=true" - - "traefik.http.routers.minio.tls.certresolver=letsencrypt" -EOF -else - cat <> docker-compose.yml - - "traefik.http.routers.minio.rule=Host(\`$MINIO_DOMAIN_NAME\`)" - - "traefik.http.routers.minio.entrypoints=minio" -EOF -fi - -cat <> docker-compose.yml + - "traefik.enable=true" + - "traefik.http.services.minio.loadbalancer.server.port=9000" + - "traefik.http.routers.minio.rule=Host(\`${CONFIG_MINIO_DOMAIN_NAME}\`)" + - "traefik.http.routers.minio.entrypoints=${CONFIG_MINIO_SSL_ENABLED:+websecure}" + ${CONFIG_MINIO_SSL_ENABLED:+- "traefik.http.routers.minio.tls=true"} + ${CONFIG_MINIO_SSL_ENABLED:+- "traefik.http.routers.minio.tls.certresolver=letsencrypt"} networks: - nocodb-network + EOF + fi -if [ -z "$WATCHTOWER_ENABLED" ] || { [ "$WATCHTOWER_ENABLED" != "N" ] && [ "$WATCHTOWER_ENABLED" != "n" ]; }; then -cat <> docker-compose.yml + if [ "${CONFIG_WATCHTOWER_ENABLED}" = "Y" ]; then + cat >> "$compose_file" <> docker-compose.yml restart: unless-stopped networks: - nocodb-network + EOF -fi + fi -# Add the cache volume -if [ -z "$REDIS_ENABLED" ] || { [ "$REDIS_ENABLED" != "N" ] && [ "$REDIS_ENABLED" != "n" ]; }; then - cat <> docker-compose.yml + cat >> "$compose_file" <> docker-compose.yml networks: nocodb-network: driver: bridge EOF +} + +create_env_file() { + local env_file="docker.env" + local encoded_password=$(urlencode "${CONFIG_POSTGRES_PASSWORD}") -# Write the docker.env file -cat < docker.env + cat > "$env_file" <> docker.env -REDIS_PASSWORD=${REDIS_PASSWORD} -NC_REDIS_URL=redis://:${REDIS_PASSWORD}@redis:6379/0 + if [ "${CONFIG_EDITION}" = "EE" ] || [ "${CONFIG_EDITION}" = "ee" ]; then + echo "DATABASE_URL=postgres://postgres:${encoded_password}@db:5432/nocodb" >> "$env_file" + echo "NC_LICENSE_KEY=${CONFIG_LICENSE_KEY}" >> "$env_file" + else + echo "NC_DB=pg://db:5432?d=nocodb&user=postgres&password=${encoded_password}" >> "$env_file" + fi + + if [ "${CONFIG_REDIS_ENABLED}" = "Y" ]; then + cat >> "$env_file" <> docker.env -MINIO_ROOT_USER=${MINIO_ACCESS_KEY} -MINIO_ROOT_PASSWORD=${MINIO_ACCESS_SECRET} + if [ "${CONFIG_MINIO_ENABLED}" = "Y" ]; then + cat >> "$env_file" <> "$env_file" + else + echo "NC_S3_ENDPOINT=http://${CONFIG_MINIO_DOMAIN_NAME}:9000" >> "$env_file" + fi + fi +} -if [ "$MINIO_SSL_ENABLED" != 'Y' ] && [ "$MINIO_SSL_ENABLED" != 'y' ]; then - cat <> docker.env -NC_S3_ENDPOINT=http://${MINIO_DOMAIN_NAME}:9000 -EOF -add_to_hosts -else - cat <> docker.env -NC_S3_ENDPOINT=https://${MINIO_DOMAIN_NAME} +create_update_script() { + cat > ./update.sh < ./update.sh <