diff --git a/.env.development.example b/.env.development.example index f9bcd361a..920c32d92 100644 --- a/.env.development.example +++ b/.env.development.example @@ -1,31 +1,16 @@ -# Coolify Configuration -APP_ENV=local -APP_NAME="Coolify Development" +APP_NAME=Coolify-localhost APP_ID=development +APP_ENV=local APP_KEY= +APP_DEBUG=true APP_URL=http://localhost APP_PORT=8000 -APP_DEBUG=true MUX_ENABLED=false -# Enable Laravel Telescope for debugging -TELESCOPE_ENABLED=false - -# Selenium Driver URL for Dusk DUSK_DRIVER_URL=http://selenium:4444 -# PostgreSQL Database Configuration -DB_DATABASE=coolify -DB_USERNAME=coolify -DB_PASSWORD=password -DB_HOST=host.docker.internal -DB_PORT=5432 - -#Set custom ray port -RAY_PORT= - -# Special Keys for Andras -# For cache purging +## For Andras only +# To purge cache BUNNY_API_KEY= -# For asset uploads +# To upload assets BUNNY_STORAGE_API_KEY= diff --git a/.env.production b/.env.production index 8e5dd4602..f15a8b0e9 100644 --- a/.env.production +++ b/.env.production @@ -1,16 +1,10 @@ -# Coolify Configuration APP_ID= +APP_NAME=Coolify APP_KEY= -# PostgreSQL Database Configuration -DB_DATABASE=coolify -DB_USERNAME= DB_PASSWORD= - -# Redis Configuration REDIS_PASSWORD= -# Pusher Configuration PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index e8d404eaf..b8156cab5 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -13,18 +13,19 @@ services: - /data/coolify/backups:/var/www/html/storage/app/backups - /data/coolify/webhooks-during-maintenance:/var/www/html/storage/app/webhooks-during-maintenance environment: - - APP_ENV=production - - APP_NAME=Coolify + - PHP_MEMORY_LIMIT - APP_ID + - APP_ENV=production + - APP_DEBUG + - APP_NAME - APP_KEY - APP_URL - - APP_DEBUG + - DB_CONNECTION + - DB_HOST + - DB_PORT - DB_DATABASE - DB_USERNAME - DB_PASSWORD - - DB_HOST - - DB_PORT - - DB_CONNECTION - QUEUE_CONNECTION - REDIS_HOST - REDIS_PASSWORD @@ -33,7 +34,6 @@ services: - HORIZON_BALANCE_MAX_SHIFT - HORIZON_BALANCE_COOLDOWN - SSL_MODE=off - - PHP_MEMORY_LIMIT - PHP_PM_CONTROL=dynamic - PHP_PM_START_SERVERS=1 - PHP_PM_MIN_SPARE_SERVERS=1 @@ -83,20 +83,18 @@ services: condition: service_healthy redis: condition: service_healthy - soketi: - condition: service_healthy postgres: volumes: - coolify-db:/var/lib/postgresql/data environment: - POSTGRES_USER: "${DB_USERNAME}" + POSTGRES_USER: "${DB_USERNAME:-coolify}" POSTGRES_PASSWORD: "${DB_PASSWORD}" POSTGRES_DB: "${DB_DATABASE:-coolify}" healthcheck: test: [ "CMD-SHELL", - "pg_isready -U ${DB_USERNAME}", + "pg_isready -U ${DB_USERNAME:-coolify}", "-d", "${DB_DATABASE:-coolify}" ] diff --git a/docker-compose.windows.yml b/docker-compose.windows.yml index a1ee1aeea..af5ecc0f7 100644 --- a/docker-compose.windows.yml +++ b/docker-compose.windows.yml @@ -71,14 +71,14 @@ services: volumes: - coolify-db:/var/lib/postgresql/data environment: - POSTGRES_USER: "${DB_USERNAME}" + POSTGRES_USER: "${DB_USERNAME:-coolify}" POSTGRES_PASSWORD: "${DB_PASSWORD}" POSTGRES_DB: "${DB_DATABASE:-coolify}" healthcheck: test: [ "CMD-SHELL", - "pg_isready -U ${DB_USERNAME}", + "pg_isready -U ${DB_USERNAME:-coolify}", "-d", "${DB_DATABASE:-coolify}" ] diff --git a/docker-compose.yml b/docker-compose.yml index 930c0a6b9..8eed44f8c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,6 @@ services: depends_on: - postgres - redis - - soketi postgres: image: postgres:15-alpine container_name: coolify-db @@ -33,4 +32,4 @@ networks: coolify: name: coolify driver: bridge - external: false + external: true diff --git a/other/newcompose/.env.development.example b/other/newcompose/.env.development.example new file mode 100644 index 000000000..f9bcd361a --- /dev/null +++ b/other/newcompose/.env.development.example @@ -0,0 +1,31 @@ +# Coolify Configuration +APP_ENV=local +APP_NAME="Coolify Development" +APP_ID=development +APP_KEY= +APP_URL=http://localhost +APP_PORT=8000 +APP_DEBUG=true +MUX_ENABLED=false + +# Enable Laravel Telescope for debugging +TELESCOPE_ENABLED=false + +# Selenium Driver URL for Dusk +DUSK_DRIVER_URL=http://selenium:4444 + +# PostgreSQL Database Configuration +DB_DATABASE=coolify +DB_USERNAME=coolify +DB_PASSWORD=password +DB_HOST=host.docker.internal +DB_PORT=5432 + +#Set custom ray port +RAY_PORT= + +# Special Keys for Andras +# For cache purging +BUNNY_API_KEY= +# For asset uploads +BUNNY_STORAGE_API_KEY= diff --git a/other/newcompose/.env.production b/other/newcompose/.env.production new file mode 100644 index 000000000..8e5dd4602 --- /dev/null +++ b/other/newcompose/.env.production @@ -0,0 +1,16 @@ +# Coolify Configuration +APP_ID= +APP_KEY= + +# PostgreSQL Database Configuration +DB_DATABASE=coolify +DB_USERNAME= +DB_PASSWORD= + +# Redis Configuration +REDIS_PASSWORD= + +# Pusher Configuration +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= diff --git a/other/newcompose/docker-compose.prod.yml b/other/newcompose/docker-compose.prod.yml new file mode 100644 index 000000000..e8d404eaf --- /dev/null +++ b/other/newcompose/docker-compose.prod.yml @@ -0,0 +1,134 @@ +services: + coolify: + image: "ghcr.io/coollabsio/coolify:${LATEST_IMAGE:-latest}" + volumes: + - type: bind + source: /data/coolify/source/.env + target: /var/www/html/.env + read_only: true + - /data/coolify/ssh:/var/www/html/storage/app/ssh + - /data/coolify/applications:/var/www/html/storage/app/applications + - /data/coolify/databases:/var/www/html/storage/app/databases + - /data/coolify/services:/var/www/html/storage/app/services + - /data/coolify/backups:/var/www/html/storage/app/backups + - /data/coolify/webhooks-during-maintenance:/var/www/html/storage/app/webhooks-during-maintenance + environment: + - APP_ENV=production + - APP_NAME=Coolify + - APP_ID + - APP_KEY + - APP_URL + - APP_DEBUG + - DB_DATABASE + - DB_USERNAME + - DB_PASSWORD + - DB_HOST + - DB_PORT + - DB_CONNECTION + - QUEUE_CONNECTION + - REDIS_HOST + - REDIS_PASSWORD + - HORIZON_BALANCE + - HORIZON_MAX_PROCESSES + - HORIZON_BALANCE_MAX_SHIFT + - HORIZON_BALANCE_COOLDOWN + - SSL_MODE=off + - PHP_MEMORY_LIMIT + - PHP_PM_CONTROL=dynamic + - PHP_PM_START_SERVERS=1 + - PHP_PM_MIN_SPARE_SERVERS=1 + - PHP_PM_MAX_SPARE_SERVERS=10 + - PUSHER_HOST + - PUSHER_BACKEND_HOST + - PUSHER_PORT + - PUSHER_BACKEND_PORT + - PUSHER_SCHEME + - PUSHER_APP_ID + - PUSHER_APP_KEY + - PUSHER_APP_SECRET + - AUTOUPDATE + - SELF_HOSTED + - SSH_MUX_PERSIST_TIME + - FEEDBACK_DISCORD_WEBHOOK + - WAITLIST + - SUBSCRIPTION_PROVIDER + - STRIPE_API_KEY + - STRIPE_WEBHOOK_SECRET + - STRIPE_PRICE_ID_BASIC_MONTHLY + - STRIPE_PRICE_ID_BASIC_YEARLY + - STRIPE_PRICE_ID_PRO_MONTHLY + - STRIPE_PRICE_ID_PRO_YEARLY + - STRIPE_PRICE_ID_ULTIMATE_MONTHLY + - STRIPE_PRICE_ID_ULTIMATE_YEARLY + - STRIPE_PRICE_ID_DYNAMIC_MONTHLY + - STRIPE_PRICE_ID_DYNAMIC_YEARLY + - STRIPE_PRICE_ID_BASIC_MONTHLY_OLD + - STRIPE_PRICE_ID_BASIC_YEARLY_OLD + - STRIPE_PRICE_ID_PRO_MONTHLY_OLD + - STRIPE_PRICE_ID_PRO_YEARLY_OLD + - STRIPE_PRICE_ID_ULTIMATE_MONTHLY_OLD + - STRIPE_PRICE_ID_ULTIMATE_YEARLY_OLD + - STRIPE_EXCLUDED_PLANS + ports: + - "${APP_PORT:-8000}:80" + expose: + - "${APP_PORT:-8000}" + healthcheck: + test: curl --fail http://127.0.0.1:80/api/health || exit 1 + interval: 5s + retries: 10 + timeout: 2s + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + soketi: + condition: service_healthy + postgres: + volumes: + - coolify-db:/var/lib/postgresql/data + environment: + POSTGRES_USER: "${DB_USERNAME}" + POSTGRES_PASSWORD: "${DB_PASSWORD}" + POSTGRES_DB: "${DB_DATABASE:-coolify}" + healthcheck: + test: + [ + "CMD-SHELL", + "pg_isready -U ${DB_USERNAME}", + "-d", + "${DB_DATABASE:-coolify}" + ] + interval: 5s + retries: 10 + timeout: 2s + redis: + command: redis-server --save 20 1 --loglevel warning --requirepass ${REDIS_PASSWORD} + environment: + REDIS_PASSWORD: "${REDIS_PASSWORD}" + volumes: + - coolify-redis:/data + healthcheck: + test: redis-cli ping + interval: 5s + retries: 10 + timeout: 2s + soketi: + ports: + - "${SOKETI_PORT:-6001}:6001" + environment: + SOKETI_DEBUG: "${SOKETI_DEBUG:-false}" + SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID}" + SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}" + SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}" + healthcheck: + test: wget -qO- http://127.0.0.1:6001/ready || exit 1 + interval: 5s + retries: 10 + timeout: 2s +volumes: + coolify-db: + name: coolify-db + coolify-redis: + name: coolify-redis diff --git a/other/newcompose/docker-compose.windows.yml b/other/newcompose/docker-compose.windows.yml new file mode 100644 index 000000000..a1ee1aeea --- /dev/null +++ b/other/newcompose/docker-compose.windows.yml @@ -0,0 +1,128 @@ +services: + coolify-testing-host: + init: true + image: "ghcr.io/coollabsio/coolify-testing-host:latest" + pull_policy: always + container_name: coolify-testing-host + volumes: + - //var/run/docker.sock://var/run/docker.sock + - ./:/data/coolify + coolify: + image: "ghcr.io/coollabsio/coolify:latest" + pull_policy: always + container_name: coolify + restart: always + working_dir: /var/www/html + extra_hosts: + - 'host.docker.internal:host-gateway' + volumes: + - type: bind + source: .env + target: /var/www/html/.env + read_only: true + - ./ssh:/var/www/html/storage/app/ssh + - ./applications:/var/www/html/storage/app/applications + - ./databases:/var/www/html/storage/app/databases + - ./services:/var/www/html/storage/app/services + - ./backups:/var/www/html/storage/app/backups + - ./webhooks-during-maintenance:/var/www/html/storage/app/webhooks-during-maintenance + env_file: + - .env + environment: + - APP_ID + - APP_ENV=production + - APP_NAME + - APP_KEY + - DB_PASSWORD + - REDIS_PASSWORD + - SSL_MODE=off + - PHP_PM_CONTROL=dynamic + - PHP_PM_START_SERVERS=1 + - PHP_PM_MIN_SPARE_SERVERS=1 + - PHP_PM_MAX_SPARE_SERVERS=10 + - PUSHER_APP_ID + - PUSHER_APP_KEY + - PUSHER_APP_SECRET + - AUTOUPDATE=true + - SELF_HOSTED=true + - MUX_ENABLED=false + - IS_WINDOWS_DOCKER_DESKTOP=true + ports: + - "${APP_PORT:-8000}:80" + expose: + - "${APP_PORT:-8000}" + healthcheck: + test: curl --fail http://localhost:80/api/health || exit 1 + interval: 5s + retries: 10 + timeout: 2s + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + postgres: + image: postgres:15-alpine + pull_policy: always + container_name: coolify-db + restart: always + env_file: + - .env + volumes: + - coolify-db:/var/lib/postgresql/data + environment: + POSTGRES_USER: "${DB_USERNAME}" + POSTGRES_PASSWORD: "${DB_PASSWORD}" + POSTGRES_DB: "${DB_DATABASE:-coolify}" + healthcheck: + test: + [ + "CMD-SHELL", + "pg_isready -U ${DB_USERNAME}", + "-d", + "${DB_DATABASE:-coolify}" + ] + interval: 5s + retries: 10 + timeout: 2s + redis: + image: redis:alpine + pull_policy: always + container_name: coolify-redis + restart: always + command: redis-server --save 20 1 --loglevel warning --requirepass ${REDIS_PASSWORD} + env_file: + - .env + environment: + REDIS_PASSWORD: "${REDIS_PASSWORD}" + volumes: + - coolify-redis:/data + healthcheck: + test: redis-cli ping + interval: 5s + retries: 10 + timeout: 2s + soketi: + image: 'quay.io/soketi/soketi:1.6-16-alpine' + pull_policy: always + container_name: coolify-realtime + restart: always + env_file: + - .env + ports: + - "${SOKETI_PORT:-6001}:6001" + environment: + SOKETI_DEBUG: "${SOKETI_DEBUG:-false}" + SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID}" + SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}" + SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}" + healthcheck: + test: wget -qO- http://localhost:6001/ready || exit 1 + interval: 5s + retries: 10 + timeout: 2s +volumes: + coolify-db: + name: coolify-db + coolify-redis: + name: coolify-redis diff --git a/other/newcompose/docker-compose.yml b/other/newcompose/docker-compose.yml new file mode 100644 index 000000000..930c0a6b9 --- /dev/null +++ b/other/newcompose/docker-compose.yml @@ -0,0 +1,36 @@ +services: + coolify: + container_name: coolify + restart: always + working_dir: /var/www/html + extra_hosts: + - 'host.docker.internal:host-gateway' + networks: + - coolify + depends_on: + - postgres + - redis + - soketi + postgres: + image: postgres:15-alpine + container_name: coolify-db + restart: always + networks: + - coolify + redis: + image: redis:alpine + container_name: coolify-redis + restart: always + networks: + - coolify + soketi: + image: 'quay.io/soketi/soketi:1.6-16-alpine' + container_name: coolify-realtime + restart: always + networks: + - coolify +networks: + coolify: + name: coolify + driver: bridge + external: false diff --git a/other/newcompose/install.sh b/other/newcompose/install.sh new file mode 100755 index 000000000..b08b0bffc --- /dev/null +++ b/other/newcompose/install.sh @@ -0,0 +1,350 @@ +#!/bin/bash +## Do not modify this file. You will lose the ability to install and auto-update! + +set -e # Exit immediately if a command exits with a non-zero status +## $1 could be empty, so we need to disable this check +#set -u # Treat unset variables as an error and exit +set -o pipefail # Cause a pipeline to return the status of the last command that exited with a non-zero status + +VERSION="1.3.4" +DOCKER_VERSION="26.0" + +CDN="https://cdn.coollabs.io/coolify" +OS_TYPE=$(grep -w "ID" /etc/os-release | cut -d "=" -f 2 | tr -d '"') +ENV_FILE="/data/coolify/source/.env" + +# Check if the OS is manjaro, if so, change it to arch +if [ "$OS_TYPE" = "manjaro" ] || [ "$OS_TYPE" = "manjaro-arm" ]; then + OS_TYPE="arch" +fi + +# Check if the OS is popOS, if so, change it to ubuntu +if [ "$OS_TYPE" = "pop" ]; then + OS_TYPE="ubuntu" +fi + +# Check if the OS is linuxmint, if so, change it to ubuntu +if [ "$OS_TYPE" = "linuxmint" ]; then + OS_TYPE="ubuntu" +fi + +#Check if the OS is zorin, if so, change it to ubuntu +if [ "$OS_TYPE" = "zorin" ]; then + OS_TYPE="ubuntu" +fi + +if [ "$OS_TYPE" = "arch" ] || [ "$OS_TYPE" = "archarm" ]; then + OS_VERSION="rolling" +else + OS_VERSION=$(grep -w "VERSION_ID" /etc/os-release | cut -d "=" -f 2 | tr -d '"') +fi + +# Install xargs on Amazon Linux 2023 - lol +if [ "$OS_TYPE" = 'amzn' ]; then + dnf install -y findutils >/dev/null +fi + +LATEST_VERSION=$(curl --silent $CDN/versions.json | grep -i version | xargs | awk '{print $2}' | tr -d ',') +DATE=$(date +"%Y%m%d-%H%M%S") + +if [ $EUID != 0 ]; then + echo "Please run as root" + exit +fi + +case "$OS_TYPE" in +arch | ubuntu | debian | raspbian | centos | fedora | rhel | ol | rocky | sles | opensuse-leap | opensuse-tumbleweed | almalinux | amzn) ;; +*) + echo "This script only supports Debian, Redhat, Arch Linux, or SLES based operating systems for now." + exit + ;; +esac + +# Overwrite LATEST_VERSION if user pass a version number +if [ "$1" != "" ]; then + LATEST_VERSION=$1 + LATEST_VERSION="${LATEST_VERSION,,}" + LATEST_VERSION="${LATEST_VERSION#v}" +fi + +echo -e "-------------" +echo -e "Welcome to Coolify v4 beta installer!" +echo -e "This script will install everything for you." +echo -e "(Source code: https://github.com/coollabsio/coolify/blob/main/scripts/install.sh )\n" +echo -e "-------------" + +echo "OS: $OS_TYPE $OS_VERSION" +echo "Coolify version: $LATEST_VERSION" + +echo -e "-------------" +echo "Installing required packages..." + +case "$OS_TYPE" in +arch) + pacman -Sy --noconfirm --needed curl wget git jq >/dev/null || true + ;; +ubuntu | debian | raspbian) + apt-get update -y >/dev/null + apt-get install -y curl wget git jq >/dev/null + ;; +centos | fedora | rhel | ol | rocky | almalinux | amzn) + if [ "$OS_TYPE" = "amzn" ]; then + dnf install -y wget git jq >/dev/null + else + if ! command -v dnf >/dev/null; then + yum install -y dnf >/dev/null + fi + if ! command -v curl >/dev/null; then + dnf install -y curl >/dev/null + fi + dnf install -y wget git jq >/dev/null + fi + ;; +sles | opensuse-leap | opensuse-tumbleweed) + zypper refresh >/dev/null + zypper install -y curl wget git jq >/dev/null + ;; +*) + echo "This script only supports Debian, Redhat, Arch Linux, or SLES based operating systems for now." + exit + ;; +esac + +# Detect OpenSSH server +SSH_DETECTED=false +if [ -x "$(command -v systemctl)" ]; then + if systemctl status sshd >/dev/null 2>&1; then + echo "OpenSSH server is installed." + SSH_DETECTED=true + fi + if systemctl status ssh >/dev/null 2>&1; then + echo "OpenSSH server is installed." + SSH_DETECTED=true + fi +elif [ -x "$(command -v service)" ]; then + if service sshd status >/dev/null 2>&1; then + echo "OpenSSH server is installed." + SSH_DETECTED=true + fi + if service ssh status >/dev/null 2>&1; then + echo "OpenSSH server is installed." + SSH_DETECTED=true + fi +fi +if [ "$SSH_DETECTED" = "false" ]; then + echo "###############################################################################" + echo "WARNING: Could not detect if OpenSSH server is installed and running - this does not mean that it is not installed, just that we could not detect it." + echo -e "Please make sure it is set, otherwise Coolify cannot connect to the host system. \n" + echo "###############################################################################" +fi + +# Detect SSH PermitRootLogin +SSH_PERMIT_ROOT_LOGIN=false +SSH_PERMIT_ROOT_LOGIN_CONFIG=$(grep "^PermitRootLogin" /etc/ssh/sshd_config | awk '{print $2}') || SSH_PERMIT_ROOT_LOGIN_CONFIG="N/A (commented out or not found at all)" +if [ "$SSH_PERMIT_ROOT_LOGIN_CONFIG" = "prohibit-password" ] || [ "$SSH_PERMIT_ROOT_LOGIN_CONFIG" = "yes" ] || [ "$SSH_PERMIT_ROOT_LOGIN_CONFIG" = "without-password" ]; then + echo "PermitRootLogin is enabled." + SSH_PERMIT_ROOT_LOGIN=true +fi + +if [ "$SSH_PERMIT_ROOT_LOGIN" != "true" ]; then + echo "###############################################################################" + echo "WARNING: PermitRootLogin is not enabled in /etc/ssh/sshd_config." + echo -e "It is set to $SSH_PERMIT_ROOT_LOGIN_CONFIG. Should be prohibit-password, yes or without-password.\n" + echo -e "Please make sure it is set, otherwise Coolify cannot connect to the host system. \n" + echo "###############################################################################" +fi + +# Detect if docker is installed via snap +if [ -x "$(command -v snap)" ]; then + if snap list | grep -q docker; then + echo "Docker is installed via snap." + echo "Please note that Coolify does not support Docker installed via snap." + echo "Please remove Docker with snap (snap remove docker) and reexecute this script." + exit 1 + fi +fi + +if ! [ -x "$(command -v docker)" ]; then + # Almalinux + if [ "$OS_TYPE" == 'almalinux' ]; then + dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo + dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin + if ! [ -x "$(command -v docker)" ]; then + echo "Docker could not be installed automatically. Please visit https://docs.docker.com/engine/install/ and install Docker manually to continue." + exit 1 + fi + systemctl start docker + systemctl enable docker + else + set +e + if ! [ -x "$(command -v docker)" ]; then + echo "Docker is not installed. Installing Docker." + # Arch Linux + if [ "$OS_TYPE" = "arch" ]; then + pacman -Sy docker docker-compose --noconfirm + systemctl enable docker.service + if [ -x "$(command -v docker)" ]; then + echo "Docker installed successfully." + else + echo "Failed to install Docker with pacman. Try to install it manually." + echo "Please visit https://wiki.archlinux.org/title/docker for more information." + exit + fi + else + # Amazon Linux 2023 + if [ "$OS_TYPE" = "amzn" ]; then + dnf install docker -y + DOCKER_CONFIG=${DOCKER_CONFIG:-/usr/local/lib/docker} + mkdir -p $DOCKER_CONFIG/cli-plugins + curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o $DOCKER_CONFIG/cli-plugins/docker-compose + chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose + systemctl start docker + systemctl enable docker + if [ -x "$(command -v docker)" ]; then + echo "Docker installed successfully." + else + echo "Failed to install Docker with pacman. Try to install it manually." + echo "Please visit https://wiki.archlinux.org/title/docker for more information." + exit + fi + else + # Automated Docker installation + curl https://releases.rancher.com/install-docker/${DOCKER_VERSION}.sh | sh + if [ -x "$(command -v docker)" ]; then + echo "Docker installed successfully." + else + echo "Docker installation failed with Rancher script. Trying with official script." + curl https://get.docker.com | sh -s -- --version ${DOCKER_VERSION} + if [ -x "$(command -v docker)" ]; then + echo "Docker installed successfully." + else + echo "Docker installation failed with official script." + echo "Maybe your OS is not supported?" + echo "Please visit https://docs.docker.com/engine/install/ and install Docker manually to continue." + exit 1 + fi + fi + fi + fi + fi + set -e + fi +fi + +echo -e "-------------" +echo -e "Check Docker Configuration..." +mkdir -p /etc/docker +# shellcheck disable=SC2015 +test -s /etc/docker/daemon.json && cp /etc/docker/daemon.json /etc/docker/daemon.json.original-"$DATE" || cat >/etc/docker/daemon.json </etc/docker/daemon.json.coolify <"$TEMP_FILE"; then + echo "Error merging JSON files" + exit 1 +fi +mv "$TEMP_FILE" /etc/docker/daemon.json + +if [ -s /etc/docker/daemon.json.original-"$DATE" ]; then + DIFF=$(diff <(jq --sort-keys . /etc/docker/daemon.json) <(jq --sort-keys . /etc/docker/daemon.json.original-"$DATE")) + if [ "$DIFF" != "" ]; then + echo "Docker configuration updated, restart docker daemon..." + systemctl restart docker + else + echo "Docker configuration is up to date." + fi +else + echo "Docker configuration updated, restart docker daemon..." + systemctl restart docker +fi + +echo -e "-------------" + +mkdir -p /data/coolify/{source,ssh,applications,databases,backups,services,proxy,webhooks-during-maintenance,metrics,logs} +mkdir -p /data/coolify/ssh/{keys,mux} +mkdir -p /data/coolify/proxy/dynamic + +chown -R 9999:root /data/coolify +chmod -R 700 /data/coolify + +echo "Downloading required files from CDN..." +curl -fsSL $CDN/docker-compose.yml -o /data/coolify/source/docker-compose.yml +curl -fsSL $CDN/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml +curl -fsSL $CDN/.env.production -o /data/coolify/source/.env.production +curl -fsSL $CDN/upgrade.sh -o /data/coolify/source/upgrade.sh + +# Copy .env.example if .env does not exist +if [ ! -f $ENV_FILE ]; then + cp /data/coolify/source/.env.production $ENV_FILE + # Generate a secure APP_ID and APP_KEY + sed -i "s|^APP_ID=.*|APP_ID=$(openssl rand -hex 16)|" "$ENV_FILE" + sed -i "s|^APP_KEY=.*|APP_KEY=base64:$(openssl rand -base64 32)|" "$ENV_FILE" + + # Generate a secure Postgres DB username and password + sed -i "s|^DB_USERNAME=.*|DB_USERNAME=$(openssl rand -hex 16)|" "$ENV_FILE" + sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$(openssl rand -base64 32)|" "$ENV_FILE" + + # Generate a secure Redis password + sed -i "s|^REDIS_PASSWORD=.*|REDIS_PASSWORD=$(openssl rand -base64 32)|" "$ENV_FILE" + + # Generate secure Pusher credentials + sed -i "s|^PUSHER_APP_ID=.*|PUSHER_APP_ID=$(openssl rand -hex 32)|" "$ENV_FILE" + sed -i "s|^PUSHER_APP_KEY=.*|PUSHER_APP_KEY=$(openssl rand -hex 32)|" "$ENV_FILE" + sed -i "s|^PUSHER_APP_SECRET=.*|PUSHER_APP_SECRET=$(openssl rand -hex 32)|" "$ENV_FILE" +fi + +# Merge .env and .env.production. New values will be added to .env +sort -u -t '=' -k 1,1 /data/coolify/source/.env /data/coolify/source/.env.production | sed '/^$/d' >/data/coolify/source/.env.temp && mv /data/coolify/source/.env.temp /data/coolify/source/.env + +if [ "$AUTOUPDATE" = "false" ]; then + if ! grep -q "AUTOUPDATE=" /data/coolify/source/.env; then + echo "AUTOUPDATE=false" >>/data/coolify/source/.env + else + sed -i "s|AUTOUPDATE=.*|AUTOUPDATE=false|g" /data/coolify/source/.env + fi +fi + +# Generate an ssh key (ed25519) at /data/coolify/ssh/keys/id.root@host.docker.internal +if [ ! -f /data/coolify/ssh/keys/id.root@host.docker.internal ]; then + ssh-keygen -t ed25519 -a 100 -f /data/coolify/ssh/keys/id.root@host.docker.internal -q -N "" -C root@coolify + chown 9999 /data/coolify/ssh/keys/id.root@host.docker.internal +fi + +addSshKey() { + cat /data/coolify/ssh/keys/id.root@host.docker.internal.pub >>~/.ssh/authorized_keys + chmod 600 ~/.ssh/authorized_keys +} + +if [ ! -f ~/.ssh/authorized_keys ]; then + mkdir -p ~/.ssh + chmod 700 ~/.ssh + touch ~/.ssh/authorized_keys + addSshKey +fi + +if ! grep -qw "root@coolify" ~/.ssh/authorized_keys; then + addSshKey +fi + +bash /data/coolify/source/upgrade.sh "${LATEST_VERSION:-latest}" + +echo "Waiting for 20 seconds for Coolify to be ready..." + +sleep 20 +echo "Please visit http://$(curl -4s https://ifconfig.io):8000 to get started." +echo -e "\nCongratulations! Your Coolify instance is ready to use.\n" diff --git a/other/newcompose/upgrade.sh b/other/newcompose/upgrade.sh new file mode 100644 index 000000000..f66125648 --- /dev/null +++ b/other/newcompose/upgrade.sh @@ -0,0 +1,37 @@ +#!/bin/bash +## Do not modify this file. You will lose the ability to autoupdate! + +VERSION="1.0.6" +CDN="https://cdn.coollabs.io/coolify" + +curl -fsSL $CDN/docker-compose.yml -o /data/coolify/source/docker-compose.yml +curl -fsSL $CDN/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml +curl -fsSL $CDN/.env.production -o /data/coolify/source/.env.production + +# Merge .env and .env.production. New values will be added to .env +sort -u -t '=' -k 1,1 /data/coolify/source/.env /data/coolify/source/.env.production | sed '/^$/d' >/data/coolify/source/.env.temp && mv /data/coolify/source/.env.temp /data/coolify/source/.env + +# Check if PUSHER_APP_ID or PUSHER_APP_KEY or PUSHER_APP_SECRET is empty in /data/coolify/source/.env +if grep -q "PUSHER_APP_ID=$" /data/coolify/source/.env; then + sed -i "s|PUSHER_APP_ID=.*|PUSHER_APP_ID=$(openssl rand -hex 32)|g" /data/coolify/source/.env +fi + +if grep -q "PUSHER_APP_KEY=$" /data/coolify/source/.env; then + sed -i "s|PUSHER_APP_KEY=.*|PUSHER_APP_KEY=$(openssl rand -hex 32)|g" /data/coolify/source/.env +fi + +if grep -q "PUSHER_APP_SECRET=$" /data/coolify/source/.env; then + sed -i "s|PUSHER_APP_SECRET=.*|PUSHER_APP_SECRET=$(openssl rand -hex 32)|g" /data/coolify/source/.env +fi + +# Make sure coolify network exists +# It is created when starting Coolify with docker compose +# docker network create --attachable coolify 2>/dev/null +# docker network create --attachable --driver=overlay coolify-overlay 2>/dev/null + +if [ -f /data/coolify/source/docker-compose.custom.yml ]; then + echo "docker-compose.custom.yml detected." + docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/coollabsio/coolify-helper bash -c "LATEST_IMAGE=${1:-} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml -f /data/coolify/source/docker-compose.custom.yml up -d --remove-orphans --force-recreate --wait --wait-timeout 60" +else + docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/coollabsio/coolify-helper bash -c "LATEST_IMAGE=${1:-} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up -d --remove-orphans --force-recreate --wait --wait-timeout 60" +fi diff --git a/scripts/install.sh b/scripts/install.sh index b08b0bffc..2aaaebaef 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -6,12 +6,11 @@ set -e # Exit immediately if a command exits with a non-zero status #set -u # Treat unset variables as an error and exit set -o pipefail # Cause a pipeline to return the status of the last command that exited with a non-zero status -VERSION="1.3.4" +VERSION="1.3.3" DOCKER_VERSION="26.0" CDN="https://cdn.coollabs.io/coolify" OS_TYPE=$(grep -w "ID" /etc/os-release | cut -d "=" -f 2 | tr -d '"') -ENV_FILE="/data/coolify/source/.env" # Check if the OS is manjaro, if so, change it to arch if [ "$OS_TYPE" = "manjaro" ] || [ "$OS_TYPE" = "manjaro-arm" ]; then @@ -84,8 +83,8 @@ arch) pacman -Sy --noconfirm --needed curl wget git jq >/dev/null || true ;; ubuntu | debian | raspbian) - apt-get update -y >/dev/null - apt-get install -y curl wget git jq >/dev/null + apt update -y >/dev/null + apt install -y curl wget git jq >/dev/null ;; centos | fedora | rhel | ol | rocky | almalinux | amzn) if [ "$OS_TYPE" = "amzn" ]; then @@ -94,10 +93,7 @@ centos | fedora | rhel | ol | rocky | almalinux | amzn) if ! command -v dnf >/dev/null; then yum install -y dnf >/dev/null fi - if ! command -v curl >/dev/null; then - dnf install -y curl >/dev/null - fi - dnf install -y wget git jq >/dev/null + dnf install -y curl wget git jq >/dev/null fi ;; sles | opensuse-leap | opensuse-tumbleweed) @@ -289,23 +285,15 @@ curl -fsSL $CDN/.env.production -o /data/coolify/source/.env.production curl -fsSL $CDN/upgrade.sh -o /data/coolify/source/upgrade.sh # Copy .env.example if .env does not exist -if [ ! -f $ENV_FILE ]; then - cp /data/coolify/source/.env.production $ENV_FILE - # Generate a secure APP_ID and APP_KEY - sed -i "s|^APP_ID=.*|APP_ID=$(openssl rand -hex 16)|" "$ENV_FILE" - sed -i "s|^APP_KEY=.*|APP_KEY=base64:$(openssl rand -base64 32)|" "$ENV_FILE" - - # Generate a secure Postgres DB username and password - sed -i "s|^DB_USERNAME=.*|DB_USERNAME=$(openssl rand -hex 16)|" "$ENV_FILE" - sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$(openssl rand -base64 32)|" "$ENV_FILE" - - # Generate a secure Redis password - sed -i "s|^REDIS_PASSWORD=.*|REDIS_PASSWORD=$(openssl rand -base64 32)|" "$ENV_FILE" - - # Generate secure Pusher credentials - sed -i "s|^PUSHER_APP_ID=.*|PUSHER_APP_ID=$(openssl rand -hex 32)|" "$ENV_FILE" - sed -i "s|^PUSHER_APP_KEY=.*|PUSHER_APP_KEY=$(openssl rand -hex 32)|" "$ENV_FILE" - sed -i "s|^PUSHER_APP_SECRET=.*|PUSHER_APP_SECRET=$(openssl rand -hex 32)|" "$ENV_FILE" +if [ ! -f /data/coolify/source/.env ]; then + cp /data/coolify/source/.env.production /data/coolify/source/.env + sed -i "s|APP_ID=.*|APP_ID=$(openssl rand -hex 16)|g" /data/coolify/source/.env + sed -i "s|APP_KEY=.*|APP_KEY=base64:$(openssl rand -base64 32)|g" /data/coolify/source/.env + sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env + sed -i "s|REDIS_PASSWORD=.*|REDIS_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env + sed -i "s|PUSHER_APP_ID=.*|PUSHER_APP_ID=$(openssl rand -hex 32)|g" /data/coolify/source/.env + sed -i "s|PUSHER_APP_KEY=.*|PUSHER_APP_KEY=$(openssl rand -hex 32)|g" /data/coolify/source/.env + sed -i "s|PUSHER_APP_SECRET=.*|PUSHER_APP_SECRET=$(openssl rand -hex 32)|g" /data/coolify/source/.env fi # Merge .env and .env.production. New values will be added to .env @@ -343,8 +331,5 @@ fi bash /data/coolify/source/upgrade.sh "${LATEST_VERSION:-latest}" -echo "Waiting for 20 seconds for Coolify to be ready..." - -sleep 20 -echo "Please visit http://$(curl -4s https://ifconfig.io):8000 to get started." echo -e "\nCongratulations! Your Coolify instance is ready to use.\n" +echo "Please visit http://$(curl -4s https://ifconfig.io):8000 to get started." diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh index f66125648..b02fe8392 100644 --- a/scripts/upgrade.sh +++ b/scripts/upgrade.sh @@ -1,7 +1,7 @@ #!/bin/bash ## Do not modify this file. You will lose the ability to autoupdate! -VERSION="1.0.6" +VERSION="1.0.5" CDN="https://cdn.coollabs.io/coolify" curl -fsSL $CDN/docker-compose.yml -o /data/coolify/source/docker-compose.yml @@ -25,13 +25,12 @@ if grep -q "PUSHER_APP_SECRET=$" /data/coolify/source/.env; then fi # Make sure coolify network exists -# It is created when starting Coolify with docker compose -# docker network create --attachable coolify 2>/dev/null +docker network create --attachable coolify 2>/dev/null # docker network create --attachable --driver=overlay coolify-overlay 2>/dev/null if [ -f /data/coolify/source/docker-compose.custom.yml ]; then echo "docker-compose.custom.yml detected." - docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/coollabsio/coolify-helper bash -c "LATEST_IMAGE=${1:-} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml -f /data/coolify/source/docker-compose.custom.yml up -d --remove-orphans --force-recreate --wait --wait-timeout 60" + docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/coollabsio/coolify-helper bash -c "LATEST_IMAGE=${1:-} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml -f /data/coolify/source/docker-compose.custom.yml up -d --remove-orphans --force-recreate" else - docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/coollabsio/coolify-helper bash -c "LATEST_IMAGE=${1:-} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up -d --remove-orphans --force-recreate --wait --wait-timeout 60" + docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/coollabsio/coolify-helper bash -c "LATEST_IMAGE=${1:-} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up -d --remove-orphans --force-recreate" fi