From 1d4a19fb6104bf6f8b475e4aaa299f375e98f356 Mon Sep 17 00:00:00 2001 From: Gauthier POGAM--LE MONTAGNER Date: Mon, 11 Aug 2025 12:08:17 +0200 Subject: [PATCH 01/51] fix(service): update healthcheck of penpot backend container (#6272) --- templates/compose/penpot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/compose/penpot.yaml b/templates/compose/penpot.yaml index fa92abb7f..9a4e2de8d 100644 --- a/templates/compose/penpot.yaml +++ b/templates/compose/penpot.yaml @@ -55,7 +55,7 @@ services: - PENPOT_SMTP_TLS=${PENPOT_SMTP_TLS:-false} - PENPOT_SMTP_SSL=${PENPOT_SMTP_SSL:-false} healthcheck: - test: ['CMD', 'curl', '-f', 'http://127.0.0.1:6060/readyz'] + test: ['CMD', 'node', '-e', "require('http').get({host:'127.0.0.1', port:6060, path:'/readyz'}, res => process.exit(res.statusCode===200 ? 0 : 1)).on('error', () => process.exit(1));"] interval: 10s timeout: 30s retries: 15 From 03040d6bc87c6c9c296c4d7de567ce3dbe3d9634 Mon Sep 17 00:00:00 2001 From: Gauthier POGAM--LE MONTAGNER Date: Mon, 11 Aug 2025 12:13:25 +0200 Subject: [PATCH 02/51] feat(service): add librechat template (#5654) --- public/svgs/librechat.svg | 32 +++++++ templates/compose/librechat.yaml | 157 +++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 public/svgs/librechat.svg create mode 100644 templates/compose/librechat.yaml diff --git a/public/svgs/librechat.svg b/public/svgs/librechat.svg new file mode 100644 index 000000000..36a536d65 --- /dev/null +++ b/public/svgs/librechat.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/compose/librechat.yaml b/templates/compose/librechat.yaml new file mode 100644 index 000000000..e5647bb2d --- /dev/null +++ b/templates/compose/librechat.yaml @@ -0,0 +1,157 @@ +# documentation: https://docs.librechat.ai/install/configuration/dotenv.html +# slogan: Self-hosted, powerful, and privacy-focused chat UI for multiple AI models +# tags: ai,chat,gpt,claude,palm,openai,azure,huggingface,anthropic,ollama,llm +# logo: svgs/librechat.svg +# port: 3080 + +services: + librechat: + image: ghcr.io/danny-avila/librechat-dev-api:latest + depends_on: + mongodb: + condition: service_healthy + rag_api: + condition: service_healthy + environment: + - HOST=0.0.0.0 + - PORT=3080 + - SERVICE_FQDN_LIBRECHAT_3080 + # MongoDB settings + - MONGO_URI=mongodb://${SERVICE_USER_MONGO}:${SERVICE_PASSWORD_MONGO}@mongodb:27017/librechat?authSource=admin + # Meilisearch settings + - MEILI_HOST=http://meilisearch:7700 + - MEILI_MASTER_KEY=${SERVICE_PASSWORD_MEILI} + # RAG settings + - RAG_PORT=8000 + - RAG_API_URL=http://rag_api:8000 + # Auth settings + - DOMAIN_CLIENT=${SERVICE_FQDN_LIBRECHAT} + - DOMAIN_SERVER=${SERVICE_FQDN_LIBRECHAT} + - JWT_SECRET=${SERVICE_PASSWORD_JWT} + - JWT_REFRESH_SECRET=${SERVICE_PASSWORD_64_JWT} + # App settings + - APP_TITLE=${APP_TITLE:-LibreChat} + - ALLOW_EMAIL_LOGIN=${ALLOW_EMAIL_LOGIN:-true} + - ALLOW_REGISTRATION=${ALLOW_REGISTRATION:-true} + - ALLOW_SOCIAL_LOGIN=${ALLOW_SOCIAL_LOGIN:-false} + - ALLOW_SOCIAL_REGISTRATION=${ALLOW_SOCIAL_REGISTRATION:-false} + - ALLOW_PASSWORD_RESET=${ALLOW_PASSWORD_RESET:-false} + - ALLOW_UNVERIFIED_EMAIL_LOGIN=${ALLOW_UNVERIFIED_EMAIL_LOGIN:-true} + # Encryption settings + - CREDS_KEY=${SERVICE_PASSWORD_64_CREDS} + - CREDS_IV=${SERVICE_PASSWORD_CREDS} + # API Keys + - ANTHROPIC_API_KEY=${SERVICE_ANTHROPIC_API_KEY:-user_provided} + - GOOGLE_KEY=${SERVICE_GOOGLE_API_KEY:-user_provided} + - OPENAI_API_KEY=${SERVICE_OPENAI_API_KEY:-user_provided} + - ASSISTANTS_API_KEY=${SERVICE_ASSISTANTS_API_KEY:-user_provided} + # Debug settings + - DEBUG_LOGGING=${DEBUG_LOGGING:-false} + - DEBUG_OPENAI=${DEBUG_OPENAI:-false} + - DEBUG_PLUGINS=${DEBUG_OPENAI:-false} + - NO_INDEX=${NO_INDEX:-true} + healthcheck: + test: + [ + 'CMD', + 'wget', + '--no-verbose', + '--tries=1', + '--spider', + 'http://127.0.0.1:3080/api/health', + ] + interval: 5s + timeout: 10s + retries: 3 + volumes: + - librechat-images:/app/client/public/images + - librechat-logs:/app/api/logs + - librechat-uploads:/app/uploads + - type: bind + source: ./librechat.yaml + target: /app/librechat.yaml + content: | + # For more information, see the Configuration Guide: + # https://www.librechat.ai/docs/configuration/librechat_yaml + + # Configuration version (required) + version: 1.2.8 + + mongodb: + environment: + - MONGO_INITDB_ROOT_USERNAME=${SERVICE_USER_MONGO} + - MONGO_INITDB_ROOT_PASSWORD=${SERVICE_PASSWORD_MONGO} + image: mongo:8 + volumes: + - mongodb-data:/data/db + healthcheck: + test: + [ + 'CMD', + 'mongosh', + '--eval', + "db.runCommand('ping').ok", + '127.0.0.1:27017/test', + '--quiet', + ] + interval: 5s + timeout: 10s + retries: 3 + + meilisearch: + image: getmeili/meilisearch:v1.12.3 + environment: + - MEILI_MASTER_KEY=${SERVICE_PASSWORD_MEILI} + - MEILI_NO_ANALYTICS=${MEILI_NO_ANALYTICS:-false} + - MEILI_ENV=production + - MEILI_HOST=http://meilisearch:7700 + volumes: + - meilisearch-data:/meili_data + healthcheck: + test: ['CMD', 'curl', '-f', 'http://127.0.0.1:7700/health'] + interval: 2s + timeout: 10s + retries: 15 + + vectordb: + image: ankane/pgvector:latest + environment: + - POSTGRES_DB=rag + - POSTGRES_USER=${SERVICE_USER_POSTGRES} + - POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRES} + - POSTGRES_HOST_AUTH_METHOD=trust + volumes: + - vectordb-data:/var/lib/postgresql/data + healthcheck: + test: + - CMD + - pg_isready + - '--username=$SERVICE_USER_POSTGRES' + - '--host=127.0.0.1' + - '--port=5432' + - '--dbname=rag' + interval: 2s + timeout: 1m + retries: 5 + start_period: 10s + + rag_api: + image: ghcr.io/danny-avila/librechat-rag-api-dev-lite:latest + depends_on: + vectordb: + condition: service_healthy + environment: + - POSTGRES_DB=rag + - POSTGRES_USER=${SERVICE_USER_POSTGRES} + - POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRES} + - DB_HOST=vectordb + - DB_USER=${SERVICE_USER_POSTGRES} + - DB_PASSWORD=${SERVICE_PASSWORD_POSTGRES} + - DB_NAME=rag + - RAG_PORT=8000 + - RAG_OPENAI_API_KEY=${SERVICE_OPENAI_API_KEY:-user_provided} + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')"] + interval: 5s + timeout: 10s + retries: 10 From bee98e02bc7e6335f3882162266aaeb2b3579aa7 Mon Sep 17 00:00:00 2001 From: howardshand Date: Mon, 11 Aug 2025 05:29:18 -0500 Subject: [PATCH 03/51] feat(service): add Homebox service (#6116) --- public/svgs/homebox.svg | 11 +++++++++++ templates/compose/homebox.yaml | 27 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 public/svgs/homebox.svg create mode 100644 templates/compose/homebox.yaml diff --git a/public/svgs/homebox.svg b/public/svgs/homebox.svg new file mode 100644 index 000000000..08670bbb9 --- /dev/null +++ b/public/svgs/homebox.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/templates/compose/homebox.yaml b/templates/compose/homebox.yaml new file mode 100644 index 000000000..0f645aa93 --- /dev/null +++ b/templates/compose/homebox.yaml @@ -0,0 +1,27 @@ +# documentation: https://github.com/sysadminsmedia/homebox +# slogan: Homebox is the inventory and organization system built for the Home User. +# tags: inventory, home, organize +# logo: svgs/homebox.svg +# port: 7745 + +services: + homebox: + image: 'ghcr.io/sysadminsmedia/homebox:latest' + environment: + - SERVICE_FQDN_HOMEBOX_7745 + - HBOX_OPTIONS_ALLOW_REGISTRATION=${HBOX_OPTIONS_ALLOW_REGISTRATION:-false} + - HBOX_LOG_LEVEL=${HBOX_LOG_LEVEL:-info} + - HBOX_LOG_FORMAT=${HBOX_LOG_FORMAT:-text} + - HBOX_WEB_MAX_UPLOAD_SIZE=${HBOX_WEB_MAX_UPLOAD_SIZE:-10} + - HBOX_MAILER_HOST=${HBOX_MAILER_HOST} + - HBOX_MAILER_PORT=${HBOX_MAILER_PORT:-587} + - HBOX_MAILER_USERNAME=${HBOX_MAILER_USERNAME} + - HBOX_MAILER_PASSWORD=${HBOX_MAILER_PASSWORD} + - HBOX_MAILER_FROM=${HBOX_MAILER_FROM} + volumes: + - 'homebox-data:/data/' + healthcheck: + test: ["CMD", "sh", "-c", "wget --method=GET -qO- http://localhost:7745/api/v1/status > /dev/null || exit 1"] + interval: 30s + timeout: 5s + retries: 10 From 7dcb5c43ae91aded4d50c60c596a43d84fc10878 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 11 Aug 2025 12:31:09 +0200 Subject: [PATCH 04/51] chore(service): homebox formatting --- templates/compose/homebox.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/compose/homebox.yaml b/templates/compose/homebox.yaml index 0f645aa93..6d3f3e597 100644 --- a/templates/compose/homebox.yaml +++ b/templates/compose/homebox.yaml @@ -6,7 +6,7 @@ services: homebox: - image: 'ghcr.io/sysadminsmedia/homebox:latest' + image: ghcr.io/sysadminsmedia/homebox:latest environment: - SERVICE_FQDN_HOMEBOX_7745 - HBOX_OPTIONS_ALLOW_REGISTRATION=${HBOX_OPTIONS_ALLOW_REGISTRATION:-false} @@ -19,7 +19,7 @@ services: - HBOX_MAILER_PASSWORD=${HBOX_MAILER_PASSWORD} - HBOX_MAILER_FROM=${HBOX_MAILER_FROM} volumes: - - 'homebox-data:/data/' + - homebox-data:/data healthcheck: test: ["CMD", "sh", "-c", "wget --method=GET -qO- http://localhost:7745/api/v1/status > /dev/null || exit 1"] interval: 30s From 9ec72e8769fc75b82d29bcf9f288215cdd6cdd61 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 11 Aug 2025 12:32:01 +0200 Subject: [PATCH 05/51] refactor(service): improve librechat - remove comments - format and reorder service --- templates/compose/librechat.yaml | 104 +++++++++++++++---------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/templates/compose/librechat.yaml b/templates/compose/librechat.yaml index e5647bb2d..fcb8f8c6d 100644 --- a/templates/compose/librechat.yaml +++ b/templates/compose/librechat.yaml @@ -7,29 +7,19 @@ services: librechat: image: ghcr.io/danny-avila/librechat-dev-api:latest - depends_on: - mongodb: - condition: service_healthy - rag_api: - condition: service_healthy environment: - - HOST=0.0.0.0 - - PORT=3080 - SERVICE_FQDN_LIBRECHAT_3080 - # MongoDB settings - - MONGO_URI=mongodb://${SERVICE_USER_MONGO}:${SERVICE_PASSWORD_MONGO}@mongodb:27017/librechat?authSource=admin - # Meilisearch settings - - MEILI_HOST=http://meilisearch:7700 - - MEILI_MASTER_KEY=${SERVICE_PASSWORD_MEILI} - # RAG settings - - RAG_PORT=8000 - - RAG_API_URL=http://rag_api:8000 - # Auth settings - DOMAIN_CLIENT=${SERVICE_FQDN_LIBRECHAT} - DOMAIN_SERVER=${SERVICE_FQDN_LIBRECHAT} + - HOST=0.0.0.0 + - PORT=3080 + - MONGO_URI=mongodb://${SERVICE_USER_MONGO}:${SERVICE_PASSWORD_MONGO}@mongodb:27017/librechat?authSource=admin + - MEILI_HOST=http://meilisearch:7700 + - MEILI_MASTER_KEY=${SERVICE_PASSWORD_MEILI} + - RAG_PORT=8000 + - RAG_API_URL=http://rag-api:8000 - JWT_SECRET=${SERVICE_PASSWORD_JWT} - JWT_REFRESH_SECRET=${SERVICE_PASSWORD_64_JWT} - # App settings - APP_TITLE=${APP_TITLE:-LibreChat} - ALLOW_EMAIL_LOGIN=${ALLOW_EMAIL_LOGIN:-true} - ALLOW_REGISTRATION=${ALLOW_REGISTRATION:-true} @@ -37,32 +27,16 @@ services: - ALLOW_SOCIAL_REGISTRATION=${ALLOW_SOCIAL_REGISTRATION:-false} - ALLOW_PASSWORD_RESET=${ALLOW_PASSWORD_RESET:-false} - ALLOW_UNVERIFIED_EMAIL_LOGIN=${ALLOW_UNVERIFIED_EMAIL_LOGIN:-true} - # Encryption settings - CREDS_KEY=${SERVICE_PASSWORD_64_CREDS} - CREDS_IV=${SERVICE_PASSWORD_CREDS} - # API Keys - ANTHROPIC_API_KEY=${SERVICE_ANTHROPIC_API_KEY:-user_provided} - GOOGLE_KEY=${SERVICE_GOOGLE_API_KEY:-user_provided} - OPENAI_API_KEY=${SERVICE_OPENAI_API_KEY:-user_provided} - ASSISTANTS_API_KEY=${SERVICE_ASSISTANTS_API_KEY:-user_provided} - # Debug settings - DEBUG_LOGGING=${DEBUG_LOGGING:-false} - DEBUG_OPENAI=${DEBUG_OPENAI:-false} - DEBUG_PLUGINS=${DEBUG_OPENAI:-false} - NO_INDEX=${NO_INDEX:-true} - healthcheck: - test: - [ - 'CMD', - 'wget', - '--no-verbose', - '--tries=1', - '--spider', - 'http://127.0.0.1:3080/api/health', - ] - interval: 5s - timeout: 10s - retries: 3 volumes: - librechat-images:/app/client/public/images - librechat-logs:/app/api/logs @@ -71,28 +45,46 @@ services: source: ./librechat.yaml target: /app/librechat.yaml content: | - # For more information, see the Configuration Guide: - # https://www.librechat.ai/docs/configuration/librechat_yaml - - # Configuration version (required) version: 1.2.8 + depends_on: + mongodb: + condition: service_healthy + meilisearch: + condition: service_healthy + vectordb: + condition: service_healthy + rag-api: + condition: service_healthy + healthcheck: + test: + [ + "CMD", + "wget", + "--no-verbose", + "--tries=1", + "--spider", + "http://127.0.0.1:3080/api/health", + ] + interval: 5s + timeout: 10s + retries: 5 mongodb: + image: mongo:8 environment: - MONGO_INITDB_ROOT_USERNAME=${SERVICE_USER_MONGO} - MONGO_INITDB_ROOT_PASSWORD=${SERVICE_PASSWORD_MONGO} - image: mongo:8 volumes: - mongodb-data:/data/db healthcheck: test: [ - 'CMD', - 'mongosh', - '--eval', + "CMD", + "mongosh", + "--eval", "db.runCommand('ping').ok", - '127.0.0.1:27017/test', - '--quiet', + "127.0.0.1:27017/test", + "--quiet", ] interval: 5s timeout: 10s @@ -108,7 +100,7 @@ services: volumes: - meilisearch-data:/meili_data healthcheck: - test: ['CMD', 'curl', '-f', 'http://127.0.0.1:7700/health'] + test: ["CMD", "curl", "-f", "http://127.0.0.1:7700/health"] interval: 2s timeout: 10s retries: 15 @@ -126,20 +118,17 @@ services: test: - CMD - pg_isready - - '--username=$SERVICE_USER_POSTGRES' - - '--host=127.0.0.1' - - '--port=5432' - - '--dbname=rag' + - "--username=$SERVICE_USER_POSTGRES" + - "--host=127.0.0.1" + - "--port=5432" + - "--dbname=rag" interval: 2s timeout: 1m retries: 5 start_period: 10s - rag_api: + rag-api: image: ghcr.io/danny-avila/librechat-rag-api-dev-lite:latest - depends_on: - vectordb: - condition: service_healthy environment: - POSTGRES_DB=rag - POSTGRES_USER=${SERVICE_USER_POSTGRES} @@ -150,8 +139,17 @@ services: - DB_NAME=rag - RAG_PORT=8000 - RAG_OPENAI_API_KEY=${SERVICE_OPENAI_API_KEY:-user_provided} + depends_on: + vectordb: + condition: service_healthy healthcheck: - test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')"] + test: + [ + "CMD", + "python", + "-c", + "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')", + ] interval: 5s timeout: 10s retries: 10 From e572017d27be55e56adf19d2351bfbab7cd1f679 Mon Sep 17 00:00:00 2001 From: Yanluis Fermin <32645451+Jacxk@users.noreply.github.com> Date: Mon, 11 Aug 2025 08:03:46 -0400 Subject: [PATCH 06/51] fix(api): duplicated logs in application endpoint (#6292) --- bootstrap/helpers/docker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 944c51e3c..739f98f22 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -1101,7 +1101,7 @@ function getContainerLogs(Server $server, string $container_id, int $lines = 100 ], $server); } - $output .= removeAnsiColors($output); + $output = removeAnsiColors($output); return $output; } From d53e493dcc601988490a210c90781e8c07d7c69e Mon Sep 17 00:00:00 2001 From: Aaryan meena <134821046+aaryan359@users.noreply.github.com> Date: Mon, 11 Aug 2025 18:03:31 +0530 Subject: [PATCH 07/51] chore: clarify usage of custom redis configuration (#6321) --- .../project/database/redis/general.blade.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/views/livewire/project/database/redis/general.blade.php b/resources/views/livewire/project/database/redis/general.blade.php index 577c0d3e9..b4876f325 100644 --- a/resources/views/livewire/project/database/redis/general.blade.php +++ b/resources/views/livewire/project/database/redis/general.blade.php @@ -132,8 +132,16 @@ id="database.public_port" label="Public Port" /> + placeholder="# maxmemory 256mb +# maxmemory-policy allkeys-lru +# timeout 300" + helper="You only need to provide the Redis directives you want to override — Redis will use default values for everything else.

+⚠️ Important: Coolify automatically applies the requirepass directive using the password shown in the Password field above. If you override requirepass in your custom configuration, make sure it matches the password field to avoid authentication issues.

+🔗 Tip: View the full Redis default configuration to see what options are available." + label="Custom Redis Configuration" rows="10" id="database.redis_conf" /> + + +

Advanced

Date: Mon, 11 Aug 2025 09:03:13 -0400 Subject: [PATCH 08/51] fix(service): documenso signees always pending (#6334) --- templates/compose/documenso.yaml | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/templates/compose/documenso.yaml b/templates/compose/documenso.yaml index 6a3873799..97ae6f918 100644 --- a/templates/compose/documenso.yaml +++ b/templates/compose/documenso.yaml @@ -26,6 +26,16 @@ services: - NEXT_PRIVATE_SMTP_FROM_ADDRESS=${NEXT_PRIVATE_SMTP_FROM_ADDRESS} - NEXT_PRIVATE_DATABASE_URL=postgresql://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@database/${POSTGRES_DB:-documenso-db}?schema=public - NEXT_PRIVATE_DIRECT_DATABASE_URL=postgresql://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@database/${POSTGRES_DB:-documenso-db}?schema=public + - NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH=/app/apps/remix/certs/certificate.p12 + - NEXT_PRIVATE_SIGNING_PASSPHRASE=${SERVICE_PASSWORD_DOCUMENSO} + - CERT_VALID_DAYS=${CERT_VALID_DAYS:-365} + - CERT_INFO_COUNTRY_NAME=${CERT_INFO_COUNTRY_NAME:-DO} + - CERT_INFO_STATE_OR_PROVIDENCE=${CERT_INFO_STATE_OR_PROVIDENCE:-Santiago} + - CERT_INFO_LOCALITY_NAME=${CERT_INFO_LOCALITY_NAME:-Santiago} + - CERT_INFO_ORGANIZATION_NAME=${CERT_INFO_ORGANIZATION_NAME:-Example INC} + - CERT_INFO_ORGANIZATIONAL_UNIT=${CERT_INFO_ORGANIZATIONAL_UNIT:-IT Department} + - CERT_INFO_EMAIL=${CERT_INFO_EMAIL:-example@gmail.com} + - NEXT_PUBLIC_DISABLE_SIGNUP=${DISABLE_LOGIN:-false} healthcheck: test: - CMD-SHELL @@ -33,6 +43,55 @@ services: interval: 2s timeout: 10s retries: 20 + entrypoint: + - /bin/sh + - -c + - | + echo "./certs" > /tmp/certs_dir_path + echo "./make-certs.sh" > /tmp/cert_script_path + echo "${SERVICE_PASSWORD_DOCUMENSO}" > /tmp/cert_pass + + touch /tmp/cert_info_path + cat < /tmp/cert_info_path + [ req ] + distinguished_name = req_distinguished_name + prompt = no + [ req_distinguished_name ] + C = ${CERT_INFO_COUNTRY_NAME} + ST = ${CERT_INFO_STATE_OR_PROVIDENCE} + L = ${CERT_INFO_LOCALITY_NAME} + O = ${CERT_INFO_ORGANIZATION_NAME} + OU = ${CERT_INFO_ORGANIZATIONAL_UNIT} + CN = ${SERVICE_FQDN_DOCUMENSO} + emailAddress = ${CERT_INFO_EMAIL} + EOF + + cat < "$(cat /tmp/cert_script_path)" + mkdir -p "$(cat /tmp/certs_dir_path)" && cd "$(cat /tmp/certs_dir_path)" + + openssl genrsa -out private.key 2048 + + openssl req \ + -new \ + -x509 \ + -key private.key \ + -out certificate.crt \ + -days ${CERT_VALID_DAYS} \ + -config /tmp/cert_info_path + + openssl pkcs12 \ + -export \ + -out certificate.p12 \ + -inkey private.key \ + -in certificate.crt \ + -legacy \ + -password file:/tmp/cert_pass + EOF + chmod +x "$(cat /tmp/cert_script_path)" + + sh "$(cat /tmp/cert_script_path)" + + ./start.sh database: image: postgres:17 From c404581b25c8c5319dc9fe1460bdedd9c3c532ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8F=94=EF=B8=8F=20Peak?= <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 11 Aug 2025 18:22:03 +0200 Subject: [PATCH 09/51] fix(database): custom postgres configs with SSL (#6352) --- app/Actions/Database/StartPostgresql.php | 26 +++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index a40eac17b..4314ccd2f 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -185,6 +185,8 @@ class StartPostgresql } } + $command = ['postgres']; + if (filled($this->database->postgres_conf)) { $docker_compose['services'][$container_name]['volumes'] = array_merge( $docker_compose['services'][$container_name]['volumes'], @@ -195,29 +197,25 @@ class StartPostgresql 'read_only' => true, ]] ); - $docker_compose['services'][$container_name]['command'] = [ - 'postgres', - '-c', - 'config_file=/etc/postgresql/postgresql.conf', - ]; + $command = array_merge($command, ['-c', 'config_file=/etc/postgresql/postgresql.conf']); } if ($this->database->enable_ssl) { - $docker_compose['services'][$container_name]['command'] = [ - 'postgres', - '-c', - 'ssl=on', - '-c', - 'ssl_cert_file=/var/lib/postgresql/certs/server.crt', - '-c', - 'ssl_key_file=/var/lib/postgresql/certs/server.key', - ]; + $command = array_merge($command, [ + '-c', 'ssl=on', + '-c', 'ssl_cert_file=/var/lib/postgresql/certs/server.crt', + '-c', 'ssl_key_file=/var/lib/postgresql/certs/server.key', + ]); } // Add custom docker run options $docker_run_options = convertDockerRunToCompose($this->database->custom_docker_run_options); $docker_compose = generateCustomDockerRunOptionsForDatabases($docker_run_options, $docker_compose, $container_name, $this->database->destination->network); + if (count($command) > 1) { + $docker_compose['services'][$container_name]['command'] = $command; + } + $docker_compose = Yaml::dump($docker_compose, 10); $docker_compose_base64 = base64_encode($docker_compose); $this->commands[] = "echo '{$docker_compose_base64}' | base64 -d | tee $this->configuration_dir/docker-compose.yml > /dev/null"; From bf738b2d2d8cb749a35ce7c74298f6b9961ad21b Mon Sep 17 00:00:00 2001 From: Verity <83372423+CallMeVerity@users.noreply.github.com> Date: Mon, 11 Aug 2025 17:55:37 +0100 Subject: [PATCH 10/51] feat(service): add pterodactyl & wings services (#5537) --- templates/compose/pterodactyl-with-wings.yaml | 140 ++++++++++++++++++ templates/compose/pterodactyl.yaml | 93 +++--------- templates/compose/wings.yaml | 44 ++++++ 3 files changed, 208 insertions(+), 69 deletions(-) create mode 100644 templates/compose/pterodactyl-with-wings.yaml create mode 100644 templates/compose/wings.yaml diff --git a/templates/compose/pterodactyl-with-wings.yaml b/templates/compose/pterodactyl-with-wings.yaml new file mode 100644 index 000000000..bd0c07cca --- /dev/null +++ b/templates/compose/pterodactyl-with-wings.yaml @@ -0,0 +1,140 @@ +# documentation: https://pterodactyl.io/ +# slogan: Pterodactyl is a free, open-source game server management panel +# tags: game, game server, management, panel, minecraft +# logo: svgs/pterodactyl.png +# port: 80, 8443 + +services: + mariadb: + image: mariadb:10.5 + healthcheck: + test: + ["CMD-SHELL", "healthcheck.sh --connect --innodb_initialized || exit 1"] + start_period: 10s + interval: 10s + timeout: 1s + retries: 3 + environment: + - MYSQL_ROOT_PASSWORD=$SERVICE_PASSWORD_MYSQLROOT + - MYSQL_DATABASE=pterodactyl-db + - MYSQL_USER=$SERVICE_USER_MYSQL + - MYSQL_PASSWORD=$SERVICE_PASSWORD_MYSQL + volumes: + - pterodactyl-db:/var/lib/mysql + + redis: + image: redis:alpine + healthcheck: + test: ["CMD-SHELL", "redis-cli ping || exit 1"] + interval: 10s + timeout: 1s + retries: 3 + + pterodactyl: + image: ghcr.io/pterodactyl/panel:latest + volumes: + - "panel-var:/app/var/" + - "panel-nginx:/etc/nginx/http.d/" + - "panel-certs:/etc/letsencrypt/" + - type: bind + source: ./etc/entrypoint.sh + target: /entrypoint.sh + mode: "0755" + content: | + #!/bin/sh + set -e + + echo "Setting logs permissions..." + chown -R nginx: /app/storage/logs/ + + USER_EXISTS=$(php artisan tinker --no-ansi --execute='echo \Pterodactyl\Models\User::where("email", "'"$ADMIN_EMAIL"'")->exists() ? "1" : "0";') + + if [ "$USER_EXISTS" = "0" ]; then + echo "Admin User does not exist, creating user now." + php artisan p:user:make --no-interaction \ + --admin=1 \ + --email="$ADMIN_EMAIL" \ + --username="$ADMIN_USERNAME" \ + --name-first="$ADMIN_FIRSTNAME" \ + --name-last="$ADMIN_LASTNAME" \ + --password="$ADMIN_PASSWORD" + echo "Admin user created successfully!" + else + echo "Admin User already exists, skipping creation." + fi + + exec supervisord --nodaemon + command: ["/entrypoint.sh"] + healthcheck: + test: ["CMD-SHELL", "curl -sf http://localhost:80 || exit 1"] + interval: 10s + timeout: 1s + retries: 3 + environment: + - SERVICE_FQDN_PTERODACTYL_80 + - ADMIN_EMAIL=${ADMIN_EMAIL:-admin@example.com} + - ADMIN_USERNAME=${SERVICE_USER_ADMIN} + - ADMIN_FIRSTNAME=${ADMIN_FIRSTNAME:-Admin} + - ADMIN_LASTNAME=${ADMIN_LASTNAME:-User} + - ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN} + - PTERODACTYL_HTTPS=${PTERODACTYL_HTTPS:-false} + - APP_ENV=production + - APP_ENVIRONMENT_ONLY=false + - APP_URL=$SERVICE_FQDN_PTERODACTYL + - APP_TIMEZONE=${TIMEZONE:-UTC} + - APP_SERVICE_AUTHOR=${APP_SERVICE_AUTHOR:-author@example.com} + - LOG_LEVEL=${LOG_LEVEL:-debug} + - CACHE_DRIVER=redis + - SESSION_DRIVER=redis + - QUEUE_DRIVER=redis + - REDIS_HOST=redis + - DB_DATABASE=pterodactyl-db + - DB_USERNAME=$SERVICE_USER_MYSQL + - DB_HOST=mariadb + - DB_PORT=3306 + - DB_PASSWORD=$SERVICE_PASSWORD_MYSQL + - MAIL_FROM=$MAIL_FROM + - MAIL_DRIVER=$MAIL_DRIVER + - MAIL_HOST=$MAIL_HOST + - MAIL_PORT=$MAIL_PORT + - MAIL_USERNAME=$MAIL_USERNAME + - MAIL_PASSWORD=$MAIL_PASSWORD + - MAIL_ENCRYPTION=$MAIL_ENCRYPTION + + wings: + image: "ghcr.io/pterodactyl/wings:latest" + environment: + - SERVICE_FQDN_WINGS_8443 + - "TZ=${TIMEZONE:-UTC}" + - WINGS_USERNAME=$SERVICE_USER_WINGS + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + - "/var/lib/docker/containers/:/var/lib/docker/containers/" + - "/var/lib/pterodactyl/volumes:/var/lib/pterodactyl/volumes" + - "/tmp/pterodactyl:/tmp/pterodactyl" + - wings_lib:/var/lib/pterodactyl/ + - wings_logs:/var/log/pterodactyl/ + - type: bind + source: ./etc/config.yml + target: /etc/pterodactyl/config.yml + content: | + debug: false + uuid: ReplaceConfig + token_id: ReplaceConfig + token: ReplaceConfig + api: + host: 0.0.0.0 + port: 8443 # Warning, panel must have 443 as daemon port, while here it should should be 8443, FQDN in Coolify for this service should be https://*:8443 + ssl: + enabled: false + cert: ReplaceConfig + key: ReplaceConfig + upload_limit: 100 + system: + data: /var/lib/pterodactyl/volumes + sftp: + bind_port: 2022 + allowed_mounts: [] + remote: '' + ports: + - '2022:2022' \ No newline at end of file diff --git a/templates/compose/pterodactyl.yaml b/templates/compose/pterodactyl.yaml index ea64de47a..32939ad7e 100644 --- a/templates/compose/pterodactyl.yaml +++ b/templates/compose/pterodactyl.yaml @@ -1,4 +1,3 @@ -# ignore: true # documentation: https://pterodactyl.io/ # slogan: Pterodactyl is a free, open-source game server management panel # tags: game, game server, management, panel, minecraft @@ -8,8 +7,6 @@ services: mariadb: image: mariadb:10.5 - restart: unless-stopped - command: --default-authentication-plugin=mysql_native_password healthcheck: test: ["CMD-SHELL", "healthcheck.sh --connect --innodb_initialized || exit 1"] @@ -18,17 +15,15 @@ services: timeout: 1s retries: 3 environment: - - SERVICE_PASSWORD_MYSQL - MYSQL_ROOT_PASSWORD=$SERVICE_PASSWORD_MYSQLROOT - - MYSQL_DATABASE=panel - - MYSQL_USER=pterodactyl + - MYSQL_DATABASE=pterodactyl-db + - MYSQL_USER=$SERVICE_USER_MYSQL - MYSQL_PASSWORD=$SERVICE_PASSWORD_MYSQL volumes: - pterodactyl-db:/var/lib/mysql redis: image: redis:alpine - restart: unless-stopped healthcheck: test: ["CMD-SHELL", "redis-cli ping || exit 1"] interval: 10s @@ -37,7 +32,6 @@ services: pterodactyl: image: ghcr.io/pterodactyl/panel:latest - restart: unless-stopped volumes: - "panel-var:/app/var/" - "panel-nginx:/etc/nginx/http.d/" @@ -50,28 +44,26 @@ services: #!/bin/sh set -e - echo "Waiting for services to be ready..." - sleep 30 + echo "Setting logs permissions..." + chown -R nginx: /app/storage/logs/ - echo "Setting logs permissions..." - chown -R nginx: /app/storage/logs/ + USER_EXISTS=$(php artisan tinker --no-ansi --execute='echo \Pterodactyl\Models\User::where("email", "'"$ADMIN_EMAIL"'")->exists() ? "1" : "0";') - if ! php artisan p:user:list | grep -q "$ADMIN_EMAIL"; then - echo "Creating admin user..." - php artisan p:user:make --no-interaction \ - --admin=1 \ - --email="$ADMIN_EMAIL" \ - --username="$ADMIN_USERNAME" \ - --name-first="$ADMIN_FIRSTNAME" \ - --name-last="$ADMIN_LASTNAME" \ - --password="$ADMIN_PASSWORD" - echo "Admin user created" - else - echo "Admin user already exists, skipping creation" - fi - - exec supervisord -c --nodaemon + if [ "$USER_EXISTS" = "0" ]; then + echo "Admin User does not exist, creating user now." + php artisan p:user:make --no-interaction \ + --admin=1 \ + --email="$ADMIN_EMAIL" \ + --username="$ADMIN_USERNAME" \ + --name-first="$ADMIN_FIRSTNAME" \ + --name-last="$ADMIN_LASTNAME" \ + --password="$ADMIN_PASSWORD" + echo "Admin user created successfully!" + else + echo "Admin User already exists, skipping creation." + fi + exec supervisord --nodaemon command: ["/entrypoint.sh"] healthcheck: test: ["CMD-SHELL", "curl -sf http://localhost:80 || exit 1"] @@ -79,7 +71,7 @@ services: timeout: 1s retries: 3 environment: - - SERVICE_FQDN_PTERODACTYL + - SERVICE_FQDN_PTERODACTYL_80 - ADMIN_EMAIL=${ADMIN_EMAIL:-admin@example.com} - ADMIN_USERNAME=${SERVICE_USER_ADMIN} - ADMIN_FIRSTNAME=${ADMIN_FIRSTNAME:-Admin} @@ -88,7 +80,7 @@ services: - PTERODACTYL_HTTPS=${PTERODACTYL_HTTPS:-false} - APP_ENV=production - APP_ENVIRONMENT_ONLY=false - - APP_URL=${PTERODACTYL_PUBLIC_FQDN:-$SERVICE_FQDN_PTERODACTYL} + - APP_URL=$SERVICE_FQDN_PTERODACTYL - APP_TIMEZONE=${TIMEZONE:-UTC} - APP_SERVICE_AUTHOR=${APP_SERVICE_AUTHOR:-author@example.com} - LOG_LEVEL=${LOG_LEVEL:-debug} @@ -96,6 +88,8 @@ services: - SESSION_DRIVER=redis - QUEUE_DRIVER=redis - REDIS_HOST=redis + - DB_DATABASE=pterodactyl-db + - DB_USERNAME=$SERVICE_USER_MYSQL - DB_HOST=mariadb - DB_PORT=3306 - DB_PASSWORD=$SERVICE_PASSWORD_MYSQL @@ -105,43 +99,4 @@ services: - MAIL_PORT=$MAIL_PORT - MAIL_USERNAME=$MAIL_USERNAME - MAIL_PASSWORD=$MAIL_PASSWORD - - MAIL_ENCRYPTION=$MAIL_ENCRYPTION - - wings: - image: ghcr.io/pterodactyl/wings:latest - restart: unless-stopped - environment: - - SERVICE_FQDN_WINGS_8080 - - TZ=${TIMEZONE:-UTC} - - WINGS_USERNAME=pterodactyl - volumes: - - "/var/run/docker.sock:/var/run/docker.sock" - - "/var/lib/docker/containers/:/var/lib/docker/containers/" - - "/var/lib/pterodactyl/:/var/lib/pterodactyl/" # See https://discord.com/channels/122900397965705216/493443725012500490/1272195151309045902 - - "/tmp/pterodactyl/:/tmp/pterodactyl/" # See https://discord.com/channels/122900397965705216/493443725012500490/1272195151309045902 - - "wings-logs:/var/log/pterodactyl/" - - - type: bind - source: ./etc/config.yml - target: /etc/pterodactyl/config.yml - content: | - docker: - network: - interface: 172.28.0.1 - dns: - - 1.1.1.1 - - 1.0.0.1 - name: pterodactyl_nw - ispn: false - driver: "" - network_mode: pterodactyl_nw - is_internal: false - enable_icc: true - network_mtu: 1500 - interfaces: - v4: - subnet: 172.28.0.0/16 - gateway: 172.28.0.1 - v6: - subnet: fdba:17c8:6c94::/64 - gateway: fdba:17c8:6c94::1011 + - MAIL_ENCRYPTION=$MAIL_ENCRYPTION \ No newline at end of file diff --git a/templates/compose/wings.yaml b/templates/compose/wings.yaml new file mode 100644 index 000000000..ce4a073f8 --- /dev/null +++ b/templates/compose/wings.yaml @@ -0,0 +1,44 @@ +# documentation: https://pterodactyl.io/ +# slogan: Wings is Pterodactyl's server control plane +# tags: game, game server, management, panel, minecraft +# logo: svgs/pterodactyl.png +# port: 8443 + +services: + wings: + image: "ghcr.io/pterodactyl/wings:latest" + environment: + - SERVICE_FQDN_WINGS_8443 + - "TZ=${TIMEZONE:-UTC}" + - WINGS_USERNAME=$SERVICE_USER_WINGS + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + - "/var/lib/docker/containers/:/var/lib/docker/containers/" + - "/var/lib/pterodactyl/volumes:/var/lib/pterodactyl/volumes" + - "/tmp/pterodactyl:/tmp/pterodactyl" + - wings_lib:/var/lib/pterodactyl/ + - wings_logs:/var/log/pterodactyl/ + - type: bind + source: ./etc/config.yml + target: /etc/pterodactyl/config.yml + content: | + debug: false + uuid: ReplaceConfig + token_id: ReplaceConfig + token: ReplaceConfig + api: + host: 0.0.0.0 + port: 8443 # Warning, panel must have 443 as daemon port, while here it should should be 8443, FQDN in Coolify for this service should be https://*:8443 + ssl: + enabled: false + cert: ReplaceConfig + key: ReplaceConfig + upload_limit: 100 + system: + data: /var/lib/pterodactyl/volumes + sftp: + bind_port: 2022 + allowed_mounts: [] + remote: '' + ports: + - '2022:2022' \ No newline at end of file From 9d7e4286b66076f305dbf1876dc192a9d14a4686 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 11 Aug 2025 19:25:59 +0200 Subject: [PATCH 11/51] Update service-templates.json --- templates/service-templates.json | 83 +++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 2 deletions(-) diff --git a/templates/service-templates.json b/templates/service-templates.json index 9f2c0a773..49884462f 100644 --- a/templates/service-templates.json +++ b/templates/service-templates.json @@ -685,7 +685,7 @@ "documenso": { "documentation": "https://docs.documenso.com/?utm_source=coolify.io", "slogan": "Document signing, finally open source", - "compose": "c2VydmljZXM6CiAgZG9jdW1lbnNvOgogICAgaW1hZ2U6IGRvY3VtZW5zby9kb2N1bWVuc28KICAgIGRlcGVuZHNfb246CiAgICAgIGRhdGFiYXNlOgogICAgICAgIGNvbmRpdGlvbjogc2VydmljZV9oZWFsdGh5CiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fRE9DVU1FTlNPXzMwMDAKICAgICAgLSAnTkVYVEFVVEhfVVJMPSR7U0VSVklDRV9GUUROX0RPQ1VNRU5TT30nCiAgICAgIC0gJ05FWFRBVVRIX1NFQ1JFVD0ke1NFUlZJQ0VfQkFTRTY0X0FVVEhTRUNSRVR9JwogICAgICAtICdORVhUX1BSSVZBVEVfRU5DUllQV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c3dvcmQgZmlsZTovdG1wL2NlcnRfcGFzc1xuRU9GXG5jaG1vZCAreCBcIiQoY2F0IC90bXAvY2VydF9zY3JpcHRfcGF0aClcIlxuXG5zaCBcIiQoY2F0IC90bXAvY2VydF9zY3JpcHRfcGF0aClcIlxuXG4uL3N0YXJ0LnNoXG4iCiAgZGF0YWJhc2U6CiAgICBpbWFnZTogJ3Bvc3RncmVzOjE3JwogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gJ1BPU1RHUkVTX1VTRVI9JHtTRVJWSUNFX1VTRVJfUE9TVEdSRVN9JwogICAgICAtICdQT1NUR1JFU19QQVNTV09SRD0ke1NFUlZJQ0VfUEFTU1dPUkRfUE9TVEdSRVN9JwogICAgICAtICdQT1NUR1JFU19EQj0ke1BPU1RHUkVTX0RCOi1kb2N1bWVuc28tZGJ9JwogICAgdm9sdW1lczoKICAgICAgLSAnZG9jdW1lbnNvX3Bvc3RncmVzcWxfZGF0YTovdmFyL2xpYi9wb3N0Z3Jlc3FsL2RhdGEnCiAgICBoZWFsdGhjaGVjazoKICAgICAgdGVzdDoKICAgICAgICAtIENNRC1TSEVMTAogICAgICAgIC0gJ3BnX2lzcmVhZHkgLVUgJCR7UE9TVEdSRVNfVVNFUn0gLWQgJCR7UE9TVEdSRVNfREJ9JwogICAgICBpbnRlcnZhbDogNXMKICAgICAgdGltZW91dDogMjBzCiAgICAgIHJldHJpZXM6IDEwCg==", "tags": [ "signing", "opensource", @@ -1480,6 +1480,19 @@ "minversion": "0.0.0", "port": "7575" }, + "homebox": { + "documentation": "https://github.com/sysadminsmedia/homebox?utm_source=coolify.io", + "slogan": "Homebox is the inventory and organization system built for the Home User.", + "compose": "c2VydmljZXM6CiAgaG9tZWJveDoKICAgIGltYWdlOiAnZ2hjci5pby9zeXNhZG1pbnNtZWRpYS9ob21lYm94OmxhdGVzdCcKICAgIGVudmlyb25tZW50OgogICAgICAtIFNFUlZJQ0VfRlFETl9IT01FQk9YXzc3NDUKICAgICAgLSAnSEJPWF9PUFRJT05TX0FMTE9XX1JFR0lTVFJBVElPTj0ke0hCT1hfT1BUSU9OU19BTExPV19SRUdJU1RSQVRJT046LWZhbHNlfScKICAgICAgLSAnSEJPWF9MT0dfTEVWRUw9JHtIQk9YX0xPR19MRVZFTDotaW5mb30nCiAgICAgIC0gJ0hCT1hfTE9HX0ZPUk1BVD0ke0hCT1hfTE9HX0ZPUk1BVDotdGV4dH0nCiAgICAgIC0gJ0hCT1hfV0VCX01BWF9VUExPQURfU0laRT0ke0hCT1hfV0VCX01BWF9VUExPQURfU0laRTotMTB9JwogICAgICAtICdIQk9YX01BSUxFUl9IT1NUPSR7SEJPWF9NQUlMRVJfSE9TVH0nCiAgICAgIC0gJ0hCT1hfTUFJTEVSX1BPUlQ9JHtIQk9YX01BSUxFUl9QT1JUOi01ODd9JwogICAgICAtICdIQk9YX01BSUxFUl9VU0VSTkFNRT0ke0hCT1hfTUFJTEVSX1VTRVJOQU1FfScKICAgICAgLSAnSEJPWF9NQUlMRVJfUEFTU1dPUkQ9JHtIQk9YX01BSUxFUl9QQVNTV09SRH0nCiAgICAgIC0gJ0hCT1hfTUFJTEVSX0ZST009JHtIQk9YX01BSUxFUl9GUk9NfScKICAgIHZvbHVtZXM6CiAgICAgIC0gJ2hvbWVib3gtZGF0YTovZGF0YScKICAgIGhlYWx0aGNoZWNrOgogICAgICB0ZXN0OgogICAgICAgIC0gQ01ECiAgICAgICAgLSBzaAogICAgICAgIC0gJy1jJwogICAgICAgIC0gJ3dnZXQgLS1tZXRob2Q9R0VUIC1xTy0gaHR0cDovL2xvY2FsaG9zdDo3NzQ1L2FwaS92MS9zdGF0dXMgPiAvZGV2L251bGwgfHwgZXhpdCAxJwogICAgICBpbnRlcnZhbDogMzBzCiAgICAgIHRpbWVvdXQ6IDVzCiAgICAgIHJldHJpZXM6IDEwCg==", + "tags": [ + "inventory", + "home", + "organize" + ], + "logo": "svgs/homebox.svg", + "minversion": "0.0.0", + "port": "7745" + }, "homepage": { "documentation": "https://gethomepage.dev/latest/?utm_source=coolify.io", "slogan": "A modern, fully static, fast, secure fully proxied, highly customizable application dashboard", @@ -1806,6 +1819,27 @@ "minversion": "0.0.0", "port": "8080" }, + "librechat": { + "documentation": "https://docs.librechat.ai/install/configuration/dotenv.html?utm_source=coolify.io", + "slogan": "Self-hosted, powerful, and privacy-focused chat UI for multiple AI models", + "compose": "c2VydmljZXM6CiAgbGlicmVjaGF0OgogICAgaW1hZ2U6ICdnaGNyLmlvL2Rhbm55LWF2aWxhL2xpYnJlY2hhdC1kZXYtYXBpOmxhdGVzdCcKICAgIGVudmlyb25tZW50OgogICAgICAtIFNFUlZJQ0VfRlFETl9MSUJSRUNIQVRfMzA4MAogICAgICAtICdET01BSU5fQ0xJRU5UPSR7U0VSVklDRV9GUUROX0xJQlJFQ0hBVH0nCiAgICAgIC0gJ0RPTUFJTl9TRVJWRVI9JHtTRVJWSUNFX0ZRRE5fTElCUkVDSEFUfScKICAgICAgLSBIT1NUPTAuMC4wLjAKICAgICAgLSBQT1JUPTMwODAKICAgICAgLSAnTU9OR09fVVJJPW1vbmdvZGI6Ly8ke1NFUlZJQ0VfVVNFUl9NT05HT306JHtTRVJWSUNFX1BBU1NXT1JEX01PTkdPfUBtb25nb2RiOjI3MDE3L2xpYnJlY2hhdD9hdXRoU291cmNlPWFkbWluJwogICAgICAtICdNRUlMSV9IT1NUPWh0dHA6Ly9tZWlsaXNlYXJjaDo3NzAwJwogICAgICAtICdNRUlMSV9NQVNURVJfS0VZPSR7U0VSVklDRV9QQVNTV09SRF9NRUlMSX0nCiAgICAgIC0gUkFHX1BPUlQ9ODAwMAogICAgICAtICdSQUdfQVBJX1VSTD1odHRwOi8vcmFnLWFwaTo4MDAwJwogICAgICAtICdKV1RfU0VDUkVUPSR7U0VSVklDRV9QQVNTV09SRF9KV1R9JwogICAgICAtICdKV1RfUkVGUkVTSF9TRUNSRVQ9JHtTRVJWSUNFX1BBU1NXT1JEXzY0X0pXVH0nCiAgICAgIC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dfTE9HR0lORzotZmFsc2V9JwogICAgICAtICdERUJVR19PUEVOQUk9JHtERUJVR19PUEVOQUk6LWZhbHNlfScKICAgICAgLSAnREVCVUdfUExVR0lOUz0ke0RFQlVHX09QRU5BSTotZmFsc2V9JwogICAgICAtICdOT19JTkRFWD0ke05PX0lOREVYOi10cnVlfScKICAgIHZvbHVtZXM6CiAgICAgIC0gJ2xpYnJlY2hhdC1pbWFnZXM6L2FwcC9jbGllbnQvcHVibGljL2ltYWdlcycKICAgICAgLSAnbGlicmVjaGF0LWxvZ3M6L2FwcC9hcGkvbG9ncycKICAgICAgLSAnbGlicmVjaGF0LXVwbG9hZHM6L2FwcC91cGxvYWRzJwogICAgICAtCiAgICAgICAgdHlwZTogYmluZAogICAgICAgIHNvdXJjZTogLi9saWJyZWNoYXQueWFtbAogICAgICAgIHRhcmdldDogL2FwcC9saWJyZWNoYXQueWFtbAogICAgICAgIGNvbnRlbnQ6ICJ2ZXJzaW9uOiAxLjIuOFxuIgogICAgZGVwZW5kc19vbjoKICAgICAgbW9uZ29kYjoKICAgICAgICBjb25kaXRpb246IHNlcnZpY2VfaGVhbHRoeQogICAgICBtZWlsaXNlYXJjaDoKICAgICAgICBjb25kaXRpb246IHNlcnZpY2VfaGVhbHRoeQogICAgICB2ZWN0b3JkYjoKICAgICAgICBjb25kaXRpb246IHNlcnZpY2VfaGVhbHRoeQogICAgICByYWctYXBpOgogICAgICAgIGNvbmRpdGlvbjogc2VydmljZV9oZWFsdGh5CiAgICBoZWFsdGhjaGVjazoKICAgICAgdGVzdDoKICAgICAgICAtIENNRAogICAgICAgIC0gd2dldAogICAgICAgIC0gJy0tbm8tdmVyYm9zZScKICAgICAgICAtICctLXRyaWVzPTEnCiAgICAgICAgLSAnLS1zcGlkZXInCiAgICAgICAgLSAnaHR0cDovLzEyNy4wLjAuMTozMDgwL2FwaS9oZWFsdGgnCiAgICAgIGludGVydmFsOiA1cwogICAgICB0aW1lb3V0OiAxMHMKICAgICAgcmV0cmllczogNQogIG1vbmdvZGI6CiAgICBpbWFnZTogJ21vbmdvOjgnCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSAnTU9OR09fSU5JVERCX1JPT1RfVVNFUk5BTUU9JHtTRVJWSUNFX1VTRVJfTU9OR099JwogICAgICAtICdNT05HT19JTklUREJfUk9PVF9QQVNTV09SRD0ke1NFUlZJQ0VfUEFTU1dPUkRfTU9OR099JwogICAgdm9sdW1lczoKICAgICAgLSAnbW9uZ29kYi1kYXRhOi9kYXRhL2RiJwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQKICAgICAgICAtIG1vbmdvc2gKICAgICAgICAtICctLWV2YWwnCiAgICAgICAgLSAiZGIucnVuQ29tbWFuZCgncGluZycpLm9rIgogICAgICAgIC0gJzEyNy4wLjAuMToyNzAxNy90ZXN0JwogICAgICAgIC0gJy0tcXVpZXQnCiAgICAgIGludGVydmFsOiA1cwogICAgICB0aW1lb3V0OiAxMHMKICAgICAgcmV0cmllczogMwogIG1laWxpc2VhcmNoOgogICAgaW1hZ2U6ICdnZXRtZWlsaS9tZWlsaXNlYXJjaDp2MS4xMi4zJwogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gJ01FSUxJX01BU1RFUl9LRVk9JHtTRVJWSUNFX1BBU1NXT1JEX01FSUxJfScKICAgICAgLSAnTUVJTElfTk9fQU5BTFlUSUNTPSR7TUVJTElfTk9fQU5BTFlUSUNTOi1mYWxzZX0nCiAgICAgIC0gTUVJTElfRU5WPXByb2R1Y3Rpb24KICAgICAgLSAnTUVJTElfSE9TVD1odHRwOi8vbWVpbGlzZWFyY2g6NzcwMCcKICAgIHZvbHVtZXM6CiAgICAgIC0gJ21laWxpc2VhcmNoLWRhdGE6L21laWxpX2RhdGEnCiAgICBoZWFsdGhjaGVjazoKICAgICAgdGVzdDoKICAgICAgICAtIENNRAogICAgICAgIC0gY3VybAogICAgICAgIC0gJy1mJwogICAgICAgIC0gJ2h0dHA6Ly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UlZJQ0VfUEFTU1dPUkRfUE9TVEdSRVN9JwogICAgICAtIERCX0hPU1Q9dmVjdG9yZGIKICAgICAgLSAnREJfVVNFUj0ke1NFUlZJQ0VfVVNFUl9QT1NUR1JFU30nCiAgICAgIC0gJ0RCX1BBU1NXT1JEPSR7U0VSVklDRV9QQVNTV09SRF9QT1NUR1JFU30nCiAgICAgIC0gREJfTkFNRT1yYWcKICAgICAgLSBSQUdfUE9SVD04MDAwCiAgICAgIC0gJ1JBR19PUEVOQUlfQVBJX0tFWT0ke1NFUlZJQ0VfT1BFTkFJX0FQSV9LRVk6LXVzZXJfcHJvdmlkZWR9JwogICAgZGVwZW5kc19vbjoKICAgICAgdmVjdG9yZGI6CiAgICAgICAgY29uZGl0aW9uOiBzZXJ2aWNlX2hlYWx0aHkKICAgIGhlYWx0aGNoZWNrOgogICAgICB0ZXN0OgogICAgICAgIC0gQ01ECiAgICAgICAgLSBweXRob24KICAgICAgICAtICctYycKICAgICAgICAtICJpbXBvcnQgdXJsbGliLnJlcXVlc3Q7IHVybGxpYi5yZXF1ZXN0LnVybG9wZW4oJ2h0dHA6Ly8xMjcuMC4wLjE6ODAwMC9oZWFsdGgnKSIKICAgICAgaW50ZXJ2YWw6IDVzCiAgICAgIHRpbWVvdXQ6IDEwcwogICAgICByZXRyaWVzOiAxMAo=", + "tags": [ + "ai", + "chat", + "gpt", + "claude", + "palm", + "openai", + "azure", + "huggingface", + "anthropic", + "ollama", + "llm" + ], + "logo": "svgs/librechat.svg", + "minversion": "0.0.0", + "port": "3080" + }, "libreoffice": { "documentation": "https://docs.linuxserver.io/images/docker-libreoffice/?utm_source=coolify.io", "slogan": "LibreOffice is a free and powerful office suite.", @@ -2715,7 +2749,7 @@ "penpot": { "documentation": "https://help.penpot.app/technical-guide/getting-started/#install-with-docker?utm_source=coolify.io", "slogan": "Penpot is the first Open Source design and prototyping platform for product teams.", - "compose": "c2VydmljZXM6CiAgZnJvbnRlbmQ6CiAgICBpbWFnZTogJ3BlbnBvdGFwcC9mcm9udGVuZDpsYXRlc3QnCiAgICB2b2x1bWVzOgogICAgICAtICdwZW5wb3QtYXNzZXRzOi9vcHQvZGF0YS9hc3NldHMnCiAgICBkZXBlbmRzX29uOgogICAgICBwZW5wb3QtYmFja2VuZDoKICAgICAgICBjb25kaXRpb246IHNlcnZpY2VfaGVhbHRoeQogICAgICBwZW5wb3QtZXhwb3J0ZXI6CiAgICAgICAgY29uZGl0aW9uOiBzZXJ2aWNlX2hlYWx0aHkKICAgIGVudmlyb25tZW50OgogICAgICAtIFNFUlZJQ0VfRlFETl9GUk9OVEVORF84MDgwCiAgICAgIC0gJ1BFTlBPVF9GTEFHUz0ke1BFTlBPVF9GUk9OVEVORF9GTEFHUzotZW5hYmxlLWxvZ2luLXdpdGgtcGFzc3dvcmR9JwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQKICAgICAgICAtIGN1cmwKICAgICAgICAtICctZicKICAgICAgICAtICdodHRwOi8vMTI3LjAuMC4xOjgwODAnCiAgICAgIGludGVydmFsOiAycwogICAgICB0aW1lb3V0OiAxMHMKICAgICAgcmV0cmllczogMTUKICBwZW5wb3QtYmFja2VuZDoKICAgIGltYWdlOiAncGVucG90YXBwL2JhY2tlbmQ6bGF0ZXN0JwogICAgdm9sdW1lczoKICAgICAgLSAncGVucG90LWFzc2V0czovb3B0L2RhdGEvYXNzZXRzJwogICAgZGVwZW5kc19vbjoKICAgICAgcG9zdGdyZXM6CiAgICAgICAgY29uZGl0aW9uOiBzZXJ2aWNlX2hlYWx0aHkKICAgICAgcmVkaXM6CiAgICAgICAgY29uZGl0aW9uOiBzZXJ2aWNlX2hlYWx0aHkKICAgIGVudmlyb25tZW50OgogICAgICAtICdQRU5QT1RfRkxBR1M9JHtQRU5QT1RfQkFDS0VORF9GTEFHUzotZW5hYmxlLWxvZ2luLXdpdGgtcGFzc3dvcmQgZW5hYmxlLXNtdHAgZW5hYmxlLXByZXBsLXNlcnZl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MC4xOjYwNjEvcmVhZHl6JwogICAgICBpbnRlcnZhbDogMnMKICAgICAgdGltZW91dDogMTBzCiAgICAgIHJldHJpZXM6IDE1CiAgbWFpbHBpdDoKICAgIGltYWdlOiAnYXhsbGVudC9tYWlscGl0OmxhdGVzdCcKICAgIGVudmlyb25tZW50OgogICAgICAtIFNFUlZJQ0VfRlFETl9NQUlMUElUXzgwMjUKICAgIGhlYWx0aGNoZWNrOgogICAgICB0ZXN0OgogICAgICAgIC0gQ01ECiAgICAgICAgLSAvbWFpbHBpdAogICAgICAgIC0gcmVhZHl6CiAgICAgIGludGVydmFsOiA1cwogICAgICB0aW1lb3V0OiAyMHMKICAgICAgcmV0cmllczogMTAKICBwb3N0Z3JlczoKICAgIGltYWdlOiAncG9zdGdyZXM6MTUnCiAgICB2b2x1bWVzOgogICAgICAtICdwZW5wb3QtcG9zdGdyZXNxbC1kYXRhOi92YXIvbGliL3Bvc3RncmVzcWwvZGF0YScKICAgIGVudmlyb25tZW50OgogICAgICAtIFBPU1RHUkVTX0lOSVREQl9BUkdTPS0tZGF0YS1jaGVja3N1bXMKICAgICAgLSBQT1NUR1JFU19VU0VSPSRTRVJWSUNFX1VTRVJfUE9TVEdSRVMKICAgICAgLSBQT1NUR1JFU19QQVNTV09SRD0kU0VSVklDRV9QQVNTV09SRF9QT1NUR1JFUwogICAgICAtICdQT1NUR1JFU19EQj0ke1BPU1RHUkVTX0RCOi1wZW5wb3R9JwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQtU0hFTEwKICAgICAgICAtICdwZ19pc3JlYWR5IC1VICQke1BPU1RHUkVTX1VTRVJ9IC1kICQke1BPU1RHUkVTX0RCfScKICAgICAgaW50ZXJ2YWw6IDVzCiAgICAgIHRpbWVvdXQ6IDIwcwogICAgICByZXRyaWVzOiAxMAogIHJlZGlzOgogICAgaW1hZ2U6ICdyZWRpczo3LWFscGluZScKICAgIGNvbW1hbmQ6ICdyZWRpcy1zZXJ2ZXIgLS1hcHBlbmRvbmx5IHllcycKICAgIHZvbHVtZXM6CiAgICAgIC0gJ3BlbnBvdC1yZWRpcy1kYXRhOi9kYXRhJwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQKICAgICAgICAtIHJlZGlzLWNsaQogICAgICAgIC0gcGluZwogICAgICBpbnRlcnZhbDogNXMKICAgICAgdGltZW91dDogMjBzCiAgICAgIHJldHJpZXM6IDEwCg==", + "compose": "c2VydmljZXM6CiAgZnJvbnRlbmQ6CiAgICBpbWFnZTogJ3BlbnBvdGFwcC9mcm9udGVuZDpsYXRlc3QnCiAgICB2b2x1bWVzOgogICAgICAtICdwZW5wb3QtYXNzZXRzOi9vcHQvZGF0YS9hc3NldHMnCiAgICBkZXBlbmRzX29uOgogICAgICBwZW5wb3QtYmFja2VuZDoKICAgICAgICBjb25kaXRpb246IHNlcnZpY2VfaGVhbHRoeQogICAgICBwZW5wb3QtZXhwb3J0ZXI6CiAgICAgICAgY29uZGl0aW9uOiBzZXJ2aWNlX2hlYWx0aHkKICAgIGVudmlyb25tZW50OgogICAgICAtIFNFUlZJQ0VfRlFETl9GUk9OVEVORF84MDgwCiAgICAgIC0gJ1BFTlBPVF9GTEFHUz0ke1BFTlBPVF9GUk9OVEVORF9GTEFHUzotZW5hYmxlLWxvZ2luLXdpdGgtcGFzc3dvcmR9JwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQKICAgICAgICAtIGN1cmwKICAgICAgICAtICctZicKICAgICAgICAtICdodHRwOi8vMTI3LjAuMC4xOjgwODAnCiAgICAgIGludGVydmFsOiAycwogICAgICB0aW1lb3V0OiAxMHMKICAgICAgcmV0cmllczogMTUKICBwZW5wb3QtYmFja2VuZDoKICAgIGltYWdlOiAncGVucG90YXBwL2JhY2tlbmQ6bGF0ZXN0JwogICAgdm9sdW1lczoKICAgICAgLSAncGVucG90LWFzc2V0czovb3B0L2Rh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kYXRhLWNoZWNrc3VtcwogICAgICAtIFBPU1RHUkVTX1VTRVI9JFNFUlZJQ0VfVVNFUl9QT1NUR1JFUwogICAgICAtIFBPU1RHUkVTX1BBU1NXT1JEPSRTRVJWSUNFX1BBU1NXT1JEX1BPU1RHUkVTCiAgICAgIC0gJ1BPU1RHUkVTX0RCPSR7UE9TVEdSRVNfREI6LXBlbnBvdH0nCiAgICBoZWFsdGhjaGVjazoKICAgICAgdGVzdDoKICAgICAgICAtIENNRC1TSEVMTAogICAgICAgIC0gJ3BnX2lzcmVhZHkgLVUgJCR7UE9TVEdSRVNfVVNFUn0gLWQgJCR7UE9TVEdSRVNfREJ9JwogICAgICBpbnRlcnZhbDogNXMKICAgICAgdGltZW91dDogMjBzCiAgICAgIHJldHJpZXM6IDEwCiAgcmVkaXM6CiAgICBpbWFnZTogJ3JlZGlzOjctYWxwaW5lJwogICAgY29tbWFuZDogJ3JlZGlzLXNlcnZlciAtLWFwcGVuZG9ubHkgeWVzJwogICAgdm9sdW1lczoKICAgICAgLSAncGVucG90LXJlZGlzLWRhdGE6L2RhdGEnCiAgICBoZWFsdGhjaGVjazoKICAgICAgdGVzdDoKICAgICAgICAtIENNRAogICAgICAgIC0gcmVkaXMtY2xpCiAgICAgICAgLSBwaW5nCiAgICAgIGludGVydmFsOiA1cwogICAgICB0aW1lb3V0OiAyMHMKICAgICAgcmV0cmllczogMTAK", "tags": [ "penpot", "design", @@ -2949,6 +2983,36 @@ "minversion": "0.0.0", "port": "9696" }, + "pterodactyl-with-wings": { + "documentation": "https://pterodactyl.io/?utm_source=coolify.io", + "slogan": "Pterodactyl is a free, open-source game server management panel", + "compose": "c2VydmljZXM6CiAgbWFyaWFkYjoKICAgIGltYWdlOiAnbWFyaWFkYjoxMC41JwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQtU0hFTEwKICAgICAgICAtICdoZWFsdGhjaGVjay5zaCAtLWNvbm5lY3QgLS1pbm5vZGJ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6L3Zhci9saWIvcHRlcm9kYWN0eWwvdm9sdW1lcycKICAgICAgLSAnL3RtcC9wdGVyb2RhY3R5bDovdG1wL3B0ZXJvZGFjdHlsJwogICAgICAtICd3aW5nc19saWI6L3Zhci9saWIvcHRlcm9kYWN0eWwvJwogICAgICAtICd3aW5nc19sb2dzOi92YXIvbG9nL3B0ZXJvZGFjdHlsLycKICAgICAgLQogICAgICAgIHR5cGU6IGJpbmQKICAgICAgICBzb3VyY2U6IC4vZXRjL2NvbmZpZy55bWwKICAgICAgICB0YXJnZXQ6IC9ldGMvcHRlcm9kYWN0eWwvY29uZmlnLnltbAogICAgICAgIGNvbnRlbnQ6ICJkZWJ1ZzogZmFsc2VcbnV1aWQ6IFJlcGxhY2VDb25maWdcbnRva2VuX2lkOiBSZXBsYWNlQ29uZmlnXG50b2tlbjogUmVwbGFjZUNvbmZpZ1xuYXBpOlxuICBob3N0OiAwLjAuMC4wXG4gIHBvcnQ6IDg0NDMgIyBXYXJuaW5nLCBwYW5lbCBtdXN0IGhhdmUgNDQzIGFzIGRhZW1vbiBwb3J0LCB3aGlsZSBoZXJlIGl0IHNob3VsZCBzaG91bGQgYmUgODQ0MywgRlFETiBpbiBDb29saWZ5IGZvciB0aGlzIHNlcnZpY2Ugc2hvdWxkIGJlIGh0dHBzOi8vKjo4NDQzXG4gIHNzbDpcbiAgICBlbmFibGVkOiBmYWxzZVxuICAgIGNlcnQ6IFJlcGxhY2VDb25maWdcbiAgICBrZXk6IFJlcGxhY2VDb25maWdcbiAgdXBsb2FkX2xpbWl0OiAxMDBcbnN5c3RlbTpcbiAgZGF0YTogL3Zhci9saWIvcHRlcm9kYWN0eWwvdm9sdW1lc1xuICBzZnRwOlxuICAgIGJpbmRfcG9ydDogMjAyMlxuYWxsb3dlZF9tb3VudHM6IFtdXG5yZW1vdGU6ICcnIgogICAgcG9ydHM6CiAgICAgIC0gJzIwMjI6MjAyMicK", + "tags": [ + "game", + "game server", + "management", + "panel", + "minecraft" + ], + "logo": "svgs/pterodactyl.png", + "minversion": "0.0.0", + "port": "80, 8443" + }, + "pterodactyl": { + "documentation": "https://pterodactyl.io/?utm_source=coolify.io", + "slogan": "Pterodactyl is a free, open-source game server management panel", + "compose": "c2VydmljZXM6CiAgbWFyaWFkYjoKICAgIGltYWdlOiAnbWFyaWFkYjoxMC41JwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQtU0hFTEwKICAgICAgICAtICdoZWFsdGhjaGVjay5zaCAtLWNvbm5lY3QgLS1pbm5vZGJfaW5pdGlhbGl6ZWQgfHwgZXhpdCAxJwogICAgICBzdGFydF9wZXJpb2Q6IDEwcwogICAgICBpbnRlcnZhbDogMTBzCiAgICAgIHRpbWVvdXQ6IDFzCiAgICAgIHJldHJpZXM6IDMKICAgIGVudmlyb25tZW50OgogICAgICAtIE1ZU1FMX1JPT1RfUEFTU1dPUkQ9JFNFUlZJQ0VfUEFTU1dPUkRfTVlTUUxST09UCiAgICAgIC0gTVlTUUxfREFUQUJBU0U9cHRlcm9kYWN0eWwtZGIKICAgICAgLSBNWVNRTF9VU0VSPSRTRVJWSUNFX1VTRVJfTVlTUUwKICAgICAgLSBNWVNRTF9QQVNTV09SRD0kU0VSVklDRV9QQVNTV09SRF9NWVNRTAogICAgdm9sdW1lczoKICAgICAgLSAncHRlcm9kYWN0eWwtZGI6L3Zhci9saWIvbXlzcWwnCiAgcmVkaXM6CiAgICBpbWFnZTogJ3JlZGlzOmFscGluZScKICAgIGhlYWx0aGNoZWNrOgogICAgICB0ZXN0OgogICAgICAgIC0gQ01ELVNIRUxMCiAgICAgICAgLSAncmVkaXMtY2xpIHBpbmcgfHwgZXhpdCAxJwogICAgICBpbnRlcnZhbDogMTBzCiAgICAgIHRpbWVvdXQ6IDFzCiAgICAgIHJldHJpZXM6IDMKICBwdGVyb2RhY3R5bDoKICAgIGltYWdlOiAnZ2hjci5pby9wdGVyb2RhY3R5bC9wYW5lbDpsYXRlc3QnCiAg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ZhbHNlCiAgICAgIC0gQVBQX1VSTD0kU0VSVklDRV9GUUROX1BURVJPREFDVFlMCiAgICAgIC0gJ0FQUF9USU1FWk9ORT0ke1RJTUVaT05FOi1VVEN9JwogICAgICAtICdBUFBfU0VSVklDRV9BVVRIT1I9JHtBUFBfU0VSVklDRV9BVVRIT1I6LWF1dGhvckBleGFtcGxlLmNvbX0nCiAgICAgIC0gJ0xPR19MRVZFTD0ke0xPR19MRVZFTDotZGVidWd9JwogICAgICAtIENBQ0hFX0RSSVZFUj1yZWRpcwogICAgICAtIFNFU1NJT05fRFJJVkVSPXJlZGlzCiAgICAgIC0gUVVFVUVfRFJJVkVSPXJlZGlzCiAgICAgIC0gUkVESVNfSE9TVD1yZWRpcwogICAgICAtIERCX0RBVEFCQVNFPXB0ZXJvZGFjdHlsLWRiCiAgICAgIC0gREJfVVNFUk5BTUU9JFNFUlZJQ0VfVVNFUl9NWVNRTAogICAgICAtIERCX0hPU1Q9bWFyaWFkYgogICAgICAtIERCX1BPUlQ9MzMwNgogICAgICAtIERCX1BBU1NXT1JEPSRTRVJWSUNFX1BBU1NXT1JEX01ZU1FMCiAgICAgIC0gTUFJTF9GUk9NPSRNQUlMX0ZST00KICAgICAgLSBNQUlMX0RSSVZFUj0kTUFJTF9EUklWRVIKICAgICAgLSBNQUlMX0hPU1Q9JE1BSUxfSE9TVAogICAgICAtIE1BSUxfUE9SVD0kTUFJTF9QT1JUCiAgICAgIC0gTUFJTF9VU0VSTkFNRT0kTUFJTF9VU0VSTkFNRQogICAgICAtIE1BSUxfUEFTU1dPUkQ9JE1BSUxfUEFTU1dPUkQKICAgICAgLSBNQUlMX0VOQ1JZUFRJT049JE1BSUxfRU5DUllQVElPTgo=", + "tags": [ + "game", + "game server", + "management", + "panel", + "minecraft" + ], + "logo": "svgs/pterodactyl.png", + "minversion": "0.0.0", + "port": "80" + }, "qbittorrent": { "documentation": "https://docs.linuxserver.io/images/docker-qbittorrent/?utm_source=coolify.io", "slogan": "The qBittorrent project aims to provide an open-source software alternative to \u03bcTorrent.", @@ -3793,6 +3857,21 @@ "minversion": "0.0.0", "port": "8000" }, + "wings": { + "documentation": "https://pterodactyl.io/?utm_source=coolify.io", + "slogan": "Wings is Pterodactyl's server control plane", + "compose": "c2VydmljZXM6CiAgd2luZ3M6CiAgICBpbWFnZTogJ2doY3IuaW8vcHRlcm9kYWN0eWwvd2luZ3M6bGF0ZXN0JwogICAgZW52aXJvbm1lbnQ6CiAgICAgIC0gU0VSVklDRV9GUUROX1dJTkdTXzg0NDMKICAgICAgLSAnVFo9JHtUSU1FWk9ORTotVVRDfScKICAgICAgLSBXSU5HU19VU0VSTkFNRT0kU0VSVklDRV9VU0VSX1dJTkdTCiAgICB2b2x1bWVzOgogICAgICAtICcvdmFyL3J1bi9kb2NrZXIuc29jazovdmFyL3J1bi9kb2NrZXIuc29jaycKICAgICAgLSAnL3Zhci9saWIvZG9ja2VyL2NvbnRhaW5lcnMvOi92YXIvbGliL2RvY2tlci9jb250YWluZXJzLycKICAgICAgLSAnL3Zhci9saWIvcHRlcm9kYWN0eWwvdm9sdW1lczovdmFyL2xpYi9wdGVyb2RhY3R5bC92b2x1bWVzJwogICAgICAtICcvdG1wL3B0ZXJvZGFjdHlsOi90bXAvcHRlcm9kYWN0eWwnCiAgICAgIC0gJ3dpbmdzX2xpYjovdmFyL2xpYi9wdGVyb2RhY3R5bC8nCiAgICAgIC0gJ3dpbmdzX2xvZ3M6L3Zhci9sb2cvcHRlcm9kYWN0eWwvJwogICAgICAtCiAgICAgICAgdHlwZTogYmluZAogICAgICAgIHNvdXJjZTogLi9ldGMvY29uZmlnLnltbAogICAgICAgIHRhcmdldDogL2V0Yy9wdGVyb2RhY3R5bC9jb25maWcueW1sCiAgICAgICAgY29udGVudDogImRlYnVnOiBmYWxzZVxudXVpZDogUmVwbGFjZUNvbmZpZ1xudG9rZW5faWQ6IFJlcGxhY2VDb25maWdcbnRva2VuOiBSZXBsYWNlQ29uZmlnXG5hcGk6XG4gIGhvc3Q6IDAuMC4wLjBcbiAgcG9ydDogODQ0MyAjIFdhcm5pbmcsIHBhbmVsIG11c3QgaGF2ZSA0NDMgYXMgZGFlbW9uIHBvcnQsIHdoaWxlIGhlcmUgaXQgc2hvdWxkIHNob3VsZCBiZSA4NDQzLCBGUUROIGluIENvb2xpZnkgZm9yIHRoaXMgc2VydmljZSBzaG91bGQgYmUgaHR0cHM6Ly8qOjg0NDNcbiAgc3NsOlxuICAgIGVuYWJsZWQ6IGZhbHNlXG4gICAgY2VydDogUmVwbGFjZUNvbmZpZ1xuICAgIGtleTogUmVwbGFjZUNvbmZpZ1xuICB1cGxvYWRfbGltaXQ6IDEwMFxuc3lzdGVtOlxuICBkYXRhOiAvdmFyL2xpYi9wdGVyb2RhY3R5bC92b2x1bWVzXG4gIHNmdHA6XG4gICAgYmluZF9wb3J0OiAyMDIyXG5hbGxvd2VkX21vdW50czogW11cbnJlbW90ZTogJyciCiAgICBwb3J0czoKICAgICAgLSAnMjAyMjoyMDIyJwo=", + "tags": [ + "game", + "game server", + "management", + "panel", + "minecraft" + ], + "logo": "svgs/pterodactyl.png", + "minversion": "0.0.0", + "port": "8443" + }, "wireguard-easy": { "documentation": "https://github.com/wg-easy/wg-easy?utm_source=coolify.io", "slogan": "The easiest way to run WireGuard VPN + Web-based Admin UI.", From 8eb3f94644908c6b80ce0d07fdb34333668ad769 Mon Sep 17 00:00:00 2001 From: Scan <103391616+scanash00@users.noreply.github.com> Date: Mon, 11 Aug 2025 11:55:35 -0800 Subject: [PATCH 12/51] feat(service): add Bluesky PDS template (#6302) --- public/svgs/bluesky.svg | 3 ++ templates/compose/bluesky-pds.yaml | 72 +++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 public/svgs/bluesky.svg diff --git a/public/svgs/bluesky.svg b/public/svgs/bluesky.svg new file mode 100644 index 000000000..77ebea072 --- /dev/null +++ b/public/svgs/bluesky.svg @@ -0,0 +1,3 @@ + + + diff --git a/templates/compose/bluesky-pds.yaml b/templates/compose/bluesky-pds.yaml index 679eb8e79..7d2804421 100644 --- a/templates/compose/bluesky-pds.yaml +++ b/templates/compose/bluesky-pds.yaml @@ -1,34 +1,64 @@ -# ignore: true # documentation: https://github.com/bluesky-social/pds -# slogan: A social network for the decentralized web -# tags: pds, bluesky, social, network, decentralized -# logo: +# slogan: Bluesky PDS (Personal Data Server) +# tags: bluesky, pds, platform +# logo: svgs/bluesky.svg # port: 3000 services: pds: - image: ghcr.io/bluesky-social/pds:0.4 + image: 'ghcr.io/bluesky-social/pds:latest' volumes: - - pds-data:/pds + - ./pds-data:/pds environment: - SERVICE_FQDN_PDS_3000 - - PDS_JWT_SECRET=${SERVICE_BASE64_PDS} - - PDS_ADMIN_PASSWORD=${SERVICE_PASSWORD_PDS} - - PDS_ADMIN_EMAIL=${PDS_ADMIN_EMAIL:-admin@example.com} - - PDS_DATADIR=${PDS_DATADIR:-/pds} - - PDS_BLOBSTORE_DISK_LOCATION=${PDS_DATADIR:-/pds}/blocks - - PDS_BLOB_UPLOAD_LIMIT=${PDS_BLOB_UPLOAD_LIMIT:-52428800} - PDS_HOSTNAME=${SERVICE_URL_PDS} - - PDS_DID_PLC_URL=https://plc.directory - - PDS_BSKY_APP_VIEW_URL=https://api.bsky.app - - PDS_BSKY_APP_VIEW_DID=did:web:api.bsky.app - - PDS_REPORT_SERVICE_URL=https://mod.bsky.app - - PDS_REPORT_SERVICE_DID=did:plc:ar7c4by46qjdydhdevvrndac - - PDS_CRAWLERS=https://bsky.network + - PDS_JWT_SECRET=${SERVICE_PASSWORD_JWT_SECRET} + - PDS_ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN} + - PDS_ADMIN_EMAIL=${SERVICE_EMAIL_ADMIN} + - PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=${PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX} + - PDS_DATA_DIRECTORY=${PDS_DATA_DIRECTORY:-/pds} + - PDS_BLOBSTORE_DISK_LOCATION=${PDS_DATA_DIRECTORY:-/pds}/blocks + - PDS_BLOB_UPLOAD_LIMIT=${PDS_BLOB_UPLOAD_LIMIT:-52428800} + - PDS_DID_PLC_URL=${PDS_DID_PLC_URL:-https://plc.directory} + - PDS_BSKY_APP_VIEW_URL=${PDS_BSKY_APP_VIEW_URL:-https://api.bsky.app} + - PDS_BSKY_APP_VIEW_DID=${PDS_BSKY_APP_VIEW_DID:-did:web:api.bsky.app} + - PDS_REPORT_SERVICE_URL=${PDS_REPORT_SERVICE_URL:-https://mod.bsky.app/xrpc/com.atproto.moderation.createReport} + - PDS_REPORT_SERVICE_DID=${PDS_REPORT_SERVICE_DID:-did:plc:ar7c4by46qjdydhdevvrndac} + - PDS_CRAWLERS=${PDS_CRAWLERS:-https://bsky.network} - LOG_ENABLED=${LOG_ENABLED:-true} - - PDS_EMAIL_SMTP_URL=${PDS_EMAIL_SMTP_URL:-smtp://localhost:8025} - - PDS_EMAIL_FROM_ADDRESS=${PDS_EMAIL_FROM_ADDRESS:-admin@example.com} - - PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=${SERVICE_HEX_32_ROTATIONKEY} + + command: > + sh -c ' + echo "Installing curl, bash, and pdsadmin..." + apk add --no-cache curl bash && \ + curl -o /usr/local/bin/pdsadmin.sh https://raw.githubusercontent.com/bluesky-social/pds/main/pdsadmin.sh && \ + chmod +x /usr/local/bin/pdsadmin.sh && \ + ln -sf /usr/local/bin/pdsadmin.sh /usr/local/bin/pdsadmin + + echo "Generating /pds/pds.env..." + printf "%s\n" \ + "SERVICE_FQDN_PDS_3000=$${SERVICE_FQDN_PDS_3000}" \ + "PDS_HOSTNAME=$${PDS_HOSTNAME}" \ + "PDS_JWT_SECRET=$${PDS_JWT_SECRET}" \ + "PDS_ADMIN_PASSWORD=$${PDS_ADMIN_PASSWORD}" \ + "PDS_ADMIN_EMAIL=$${PDS_ADMIN_EMAIL}" \ + "PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=$${PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX}" \ + "PDS_DATA_DIRECTORY=$${PDS_DATA_DIRECTORY}" \ + "PDS_BLOBSTORE_DISK_LOCATION=$${PDS_DATA_DIRECTORY}/blocks" \ + "PDS_BLOB_UPLOAD_LIMIT=$${PDS_BLOB_UPLOAD_LIMIT}" \ + "PDS_DID_PLC_URL=$${PDS_DID_PLC_URL}" \ + "PDS_BSKY_APP_VIEW_URL=$${PDS_BSKY_APP_VIEW_URL}" \ + "PDS_BSKY_APP_VIEW_DID=$${PDS_BSKY_APP_VIEW_DID}" \ + "PDS_REPORT_SERVICE_URL=$${PDS_REPORT_SERVICE_URL}" \ + "PDS_REPORT_SERVICE_DID=$${PDS_REPORT_SERVICE_DID}" \ + "PDS_CRAWLERS=$${PDS_CRAWLERS}" \ + "LOG_ENABLED=$${LOG_ENABLED}" \ + > /pds/pds.env + + echo "Launching PDS..." + exec node --enable-source-maps index.js + ' + healthcheck: test: ["CMD", "wget", "--spider", "http://127.0.0.1:3000/xrpc/_health"] interval: 2s From 158711a1658e9ca000711f33852d73f6a76b838c Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 11 Aug 2025 22:03:52 +0200 Subject: [PATCH 13/51] Update service-templates.json --- templates/service-templates.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/templates/service-templates.json b/templates/service-templates.json index 49884462f..1dbfac94b 100644 --- a/templates/service-templates.json +++ b/templates/service-templates.json @@ -203,6 +203,19 @@ "logo": "svgs/bitcoin.svg", "minversion": "0.0.0" }, + "bluesky-pds": { + "documentation": "https://github.com/bluesky-social/pds?utm_source=coolify.io", + "slogan": "Bluesky PDS (Personal Data Server)", + "compose": "c2VydmljZXM6CiAgcGRzOgogICAgaW1hZ2U6ICdnaGNyLmlvL2JsdWVza3ktc29jaWFsL3BkczpsYXRlc3QnCiAgICB2b2x1bWVzOgogICAgICAtICcuL3Bk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XCJcbiAgZXhlYyBub2RlIC0tZW5hYmxlLXNvdXJjZS1tYXBzIGluZGV4LmpzXG4nXG4iCiAgICBoZWFsdGhjaGVjazoKICAgICAgdGVzdDoKICAgICAgICAtIENNRAogICAgICAgIC0gd2dldAogICAgICAgIC0gJy0tc3BpZGVyJwogICAgICAgIC0gJ2h0dHA6Ly8xMjcuMC4wLjE6MzAwMC94cnBjL19oZWFsdGgnCiAgICAgIGludGVydmFsOiAycwogICAgICB0aW1lb3V0OiAxMHMKICAgICAgcmV0cmllczogMTAK", + "tags": [ + "bluesky", + "pds", + "platform" + ], + "logo": "svgs/bluesky.svg", + "minversion": "0.0.0", + "port": "3000" + }, "bookstack": { "documentation": "https://www.bookstackapp.com/docs/?utm_source=coolify.io", "slogan": "BookStack is a simple, self-hosted, easy-to-use platform for organising and storing information", From 103a9c2df29c0c47983ea5faec8d75fe373884c0 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Wed, 23 Jul 2025 17:57:05 +0200 Subject: [PATCH 14/51] fix(policy): update delete method to check for admin status in S3StoragePolicy --- app/Policies/S3StoragePolicy.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Policies/S3StoragePolicy.php b/app/Policies/S3StoragePolicy.php index 28f5f8426..4f837a3dd 100644 --- a/app/Policies/S3StoragePolicy.php +++ b/app/Policies/S3StoragePolicy.php @@ -21,7 +21,7 @@ class S3StoragePolicy */ public function view(User $user, S3Storage $storage): bool { - return $user->teams()->where('id', $storage->team_id)->exists(); + return $user->teams()->get()->firstWhere('id', $storage->team_id)->exists(); } /** @@ -37,7 +37,7 @@ class S3StoragePolicy */ public function update(User $user, Server $server): bool { - return $user->teams()->get()->firstWhere('id', $server->team_id) !== null; + return $user->teams()->get()->firstWhere('id', $server->team_id)->exists() && $user->isAdmin(); } /** @@ -45,7 +45,7 @@ class S3StoragePolicy */ public function delete(User $user, S3Storage $storage): bool { - return $user->teams()->where('id', $storage->team_id)->exists(); + return $user->teams()->get()->firstWhere('id', $storage->team_id)->exists() && $user->isAdmin(); } /** From cc5abc093d35be0b25bb6a69fefa34575df1eba3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Wed, 23 Jul 2025 20:49:12 +0200 Subject: [PATCH 15/51] fix(container): sort containers alphabetically by name in ExecuteContainerCommand and update filtering in Terminal Index --- app/Livewire/Project/Shared/ExecuteContainerCommand.php | 6 ++++++ app/Livewire/Terminal/Index.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Project/Shared/ExecuteContainerCommand.php b/app/Livewire/Project/Shared/ExecuteContainerCommand.php index 2d55807c7..6833492a6 100644 --- a/app/Livewire/Project/Shared/ExecuteContainerCommand.php +++ b/app/Livewire/Project/Shared/ExecuteContainerCommand.php @@ -132,6 +132,12 @@ class ExecuteContainerCommand extends Component }); } } + + // Sort containers alphabetically by name + $this->containers = $this->containers->sortBy(function ($container) { + return data_get($container, 'container.Names'); + }); + if ($this->containers->count() === 1) { $this->selected_container = data_get($this->containers->first(), 'container.Names'); } diff --git a/app/Livewire/Terminal/Index.php b/app/Livewire/Terminal/Index.php index 10084a991..f4008cb1c 100644 --- a/app/Livewire/Terminal/Index.php +++ b/app/Livewire/Terminal/Index.php @@ -59,7 +59,7 @@ class Index extends Component return null; })->filter(); - }); + })->sortBy('name'); } public function updatedSelectedUuid() From a0bc4dac55e5f9255376dc017874035eb8642fa7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Thu, 24 Jul 2025 09:39:27 +0200 Subject: [PATCH 16/51] fix(application): streamline environment variable updates for Docker Compose services and enhance FQDN generation logic --- app/Livewire/Project/Application/General.php | 63 +- app/Livewire/Project/Resource/Create.php | 2 +- app/Models/Application.php | 2 +- app/Models/Service.php | 4 +- bootstrap/helpers/parsers.php | 1657 ++++++++++++++++++ bootstrap/helpers/services.php | 201 +-- bootstrap/helpers/shared.php | 113 +- 7 files changed, 1794 insertions(+), 248 deletions(-) create mode 100644 bootstrap/helpers/parsers.php diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index 58a35caa0..2eadbaa0e 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -4,7 +4,6 @@ namespace App\Livewire\Project\Application; use App\Actions\Application\GenerateConfig; use App\Models\Application; -use App\Models\EnvironmentVariable; use Illuminate\Support\Collection; use Livewire\Component; use Spatie\Url\Url; @@ -270,7 +269,6 @@ class General extends Component $this->application->save(); $this->dispatch('success', 'Domain generated.'); if ($this->application->build_pack === 'dockercompose') { - $this->updateServiceEnvironmentVariables(); $this->loadComposeFile(showToast: false); } @@ -344,7 +342,7 @@ class General extends Component $this->application->custom_labels = base64_encode($this->customLabels); $this->application->save(); if ($this->application->build_pack === 'dockercompose') { - $this->loadComposeFile(); + $this->loadComposeFile(showToast: false); } $this->dispatch('configurationChanged'); } catch (\Throwable $e) { @@ -421,7 +419,7 @@ class General extends Component } if ($this->application->build_pack === 'dockercompose' && $this->initialDockerComposeLocation !== $this->application->docker_compose_location) { - $compose_return = $this->loadComposeFile(); + $compose_return = $this->loadComposeFile(showToast: false); if ($compose_return instanceof \Livewire\Features\SupportEvents\Event) { return; } @@ -470,7 +468,6 @@ class General extends Component } $this->application->docker_compose_domains = json_encode($originalDomains); - foreach ($originalDomains as $serviceName => $service) { $domain = data_get($service, 'domain'); if ($domain) { @@ -486,12 +483,6 @@ class General extends Component } $this->application->custom_labels = base64_encode($this->customLabels); $this->application->save(); - - // Update SERVICE_FQDN_ and SERVICE_URL_ environment variables for Docker Compose applications - if ($this->application->build_pack === 'dockercompose') { - $this->updateServiceEnvironmentVariables(); - } - $showToaster && ! $warning && $this->dispatch('success', 'Application settings updated!'); } catch (\Throwable $e) { $originalFqdn = $this->application->getOriginal('fqdn'); @@ -525,25 +516,33 @@ class General extends Component foreach ($domains as $serviceName => $service) { $serviceNameFormatted = str($serviceName)->upper()->replace('-', '_'); $domain = data_get($service, 'domain'); + // Delete SERVICE_FQDN_ and SERVICE_URL_ variables if domain is removed + $this->application->environment_variables()->where('resourceable_type', Application::class) + ->where('resourceable_id', $this->application->id) + ->where('key', 'LIKE', "SERVICE_FQDN_{$serviceNameFormatted}%") + ->delete(); + + $this->application->environment_variables()->where('resourceable_type', Application::class) + ->where('resourceable_id', $this->application->id) + ->where('key', 'LIKE', "SERVICE_URL_{$serviceNameFormatted}%") + ->delete(); if ($domain) { // Create or update SERVICE_FQDN_ and SERVICE_URL_ variables $fqdn = Url::fromString($domain); $port = $fqdn->getPort(); $path = $fqdn->getPath(); - $fqdnValue = $fqdn->getScheme().'://'.$fqdn->getHost(); - if ($path !== '/') { - $fqdnValue = $fqdnValue.$path; - } - $urlValue = str($domain)->after('://'); + $urlValue = $fqdn->getScheme().'://'.$fqdn->getHost(); if ($path !== '/') { $urlValue = $urlValue.$path; } + $fqdnValue = str($domain)->after('://'); + if ($path !== '/') { + $fqdnValue = $fqdnValue.$path; + } // Create/update SERVICE_FQDN_ - EnvironmentVariable::updateOrCreate([ - 'resourceable_type' => Application::class, - 'resourceable_id' => $this->application->id, + $this->application->environment_variables()->updateOrCreate([ 'key' => "SERVICE_FQDN_{$serviceNameFormatted}", ], [ 'value' => $fqdnValue, @@ -552,21 +551,16 @@ class General extends Component ]); // Create/update SERVICE_URL_ - EnvironmentVariable::updateOrCreate([ - 'resourceable_type' => Application::class, - 'resourceable_id' => $this->application->id, + $this->application->environment_variables()->updateOrCreate([ 'key' => "SERVICE_URL_{$serviceNameFormatted}", ], [ 'value' => $urlValue, 'is_build_time' => false, 'is_preview' => false, ]); - // Create/update port-specific variables if port exists - if ($port) { - EnvironmentVariable::updateOrCreate([ - 'resourceable_type' => Application::class, - 'resourceable_id' => $this->application->id, + if (filled($port)) { + $this->application->environment_variables()->updateOrCreate([ 'key' => "SERVICE_FQDN_{$serviceNameFormatted}_{$port}", ], [ 'value' => $fqdnValue, @@ -574,9 +568,7 @@ class General extends Component 'is_preview' => false, ]); - EnvironmentVariable::updateOrCreate([ - 'resourceable_type' => Application::class, - 'resourceable_id' => $this->application->id, + $this->application->environment_variables()->updateOrCreate([ 'key' => "SERVICE_URL_{$serviceNameFormatted}_{$port}", ], [ 'value' => $urlValue, @@ -584,17 +576,6 @@ class General extends Component 'is_preview' => false, ]); } - } else { - // Delete SERVICE_FQDN_ and SERVICE_URL_ variables if domain is removed - EnvironmentVariable::where('resourceable_type', Application::class) - ->where('resourceable_id', $this->application->id) - ->where('key', 'LIKE', "SERVICE_FQDN_{$serviceNameFormatted}%") - ->delete(); - - EnvironmentVariable::where('resourceable_type', Application::class) - ->where('resourceable_id', $this->application->id) - ->where('key', 'LIKE', "SERVICE_URL_{$serviceNameFormatted}%") - ->delete(); } } } diff --git a/app/Livewire/Project/Resource/Create.php b/app/Livewire/Project/Resource/Create.php index e7cff4f29..d8e397e59 100644 --- a/app/Livewire/Project/Resource/Create.php +++ b/app/Livewire/Project/Resource/Create.php @@ -102,7 +102,7 @@ class Create extends Component } }); } - $service->parse(isNew: true); + $service->parse(isNew: true, isOneClick: true); return redirect()->route('project.service.configuration', [ 'service_uuid' => $service->uuid, diff --git a/app/Models/Application.php b/app/Models/Application.php index 86eea1de8..ed97454d2 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -1353,7 +1353,7 @@ class Application extends BaseModel public function parse(int $pull_request_id = 0, ?int $preview_id = null) { if ((int) $this->compose_parsing_version >= 3) { - return newParser($this, $pull_request_id, $preview_id); + return applicationParser($this, $pull_request_id, $preview_id); } elseif ($this->docker_compose_raw) { return parseDockerComposeFile(resource: $this, isNew: false, pull_request_id: $pull_request_id, preview_id: $preview_id); } else { diff --git a/app/Models/Service.php b/app/Models/Service.php index da6c34fbb..4bef46642 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -1274,10 +1274,10 @@ class Service extends BaseModel instant_remote_process($commands, $this->server); } - public function parse(bool $isNew = false): Collection + public function parse(bool $isNew = false, bool $isOneClick = false): Collection { if ((int) $this->compose_parsing_version >= 3) { - return newParser($this); + return serviceParser($this, isOneClick: $isOneClick); } elseif ($this->docker_compose_raw) { return parseDockerComposeFile($this, $isNew); } else { diff --git a/bootstrap/helpers/parsers.php b/bootstrap/helpers/parsers.php new file mode 100644 index 000000000..649de731d --- /dev/null +++ b/bootstrap/helpers/parsers.php @@ -0,0 +1,1657 @@ +fileStorages(); + + try { + $yaml = Yaml::parse($compose); + } catch (\Exception) { + return collect([]); + } + $services = data_get($yaml, 'services', collect([])); + $topLevel = collect([ + 'volumes' => collect(data_get($yaml, 'volumes', [])), + 'networks' => collect(data_get($yaml, 'networks', [])), + 'configs' => collect(data_get($yaml, 'configs', [])), + 'secrets' => collect(data_get($yaml, 'secrets', [])), + ]); + // If there are predefined volumes, make sure they are not null + if ($topLevel->get('volumes')->count() > 0) { + $temp = collect([]); + foreach ($topLevel['volumes'] as $volumeName => $volume) { + if (is_null($volume)) { + continue; + } + $temp->put($volumeName, $volume); + } + $topLevel['volumes'] = $temp; + } + // Get the base docker network + $baseNetwork = collect([$uuid]); + if ($isPullRequest) { + $baseNetwork = collect(["{$uuid}-{$pullRequestId}"]); + } + + $parsedServices = collect([]); + + $allMagicEnvironments = collect([]); + foreach ($services as $serviceName => $service) { + $magicEnvironments = collect([]); + $image = data_get_str($service, 'image'); + $environment = collect(data_get($service, 'environment', [])); + $buildArgs = collect(data_get($service, 'build.args', [])); + $environment = $environment->merge($buildArgs); + + $environment = collect(data_get($service, 'environment', [])); + $buildArgs = collect(data_get($service, 'build.args', [])); + $environment = $environment->merge($buildArgs); + + // convert environment variables to one format + $environment = convertToKeyValueCollection($environment); + + // Add Coolify defined environments + $allEnvironments = $resource->environment_variables()->get(['key', 'value']); + + $allEnvironments = $allEnvironments->mapWithKeys(function ($item) { + return [$item['key'] => $item['value']]; + }); + // filter and add magic environments + foreach ($environment as $key => $value) { + // Get all SERVICE_ variables from keys and values + $key = str($key); + $value = str($value); + $regex = '/\$(\{?([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)\}?)/'; + preg_match_all($regex, $value, $valueMatches); + if (count($valueMatches[1]) > 0) { + foreach ($valueMatches[1] as $match) { + $match = replaceVariables($match); + if ($match->startsWith('SERVICE_')) { + if ($magicEnvironments->has($match->value())) { + continue; + } + $magicEnvironments->put($match->value(), ''); + } + } + } + // Get magic environments where we need to preset the FQDN + if ($key->startsWith('SERVICE_FQDN_')) { + // SERVICE_FQDN_APP or SERVICE_FQDN_APP_3000 + if (substr_count(str($key)->value(), '_') === 3) { + $fqdnFor = $key->after('SERVICE_FQDN_')->beforeLast('_')->lower()->value(); + $port = $key->afterLast('_')->value(); + } else { + $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); + $port = null; + } + $fqdn = $resource->fqdn; + if (blank($resource->fqdn)) { + $fqdn = generateFqdn($server, "$uuid"); + } + + if ($value && get_class($value) === \Illuminate\Support\Stringable::class && $value->startsWith('/')) { + $path = $value->value(); + if ($path !== '/') { + $fqdn = "$fqdn$path"; + } + } + $fqdnWithPort = $fqdn; + if ($port) { + $fqdnWithPort = "$fqdn:$port"; + } + if (is_null($resource->fqdn)) { + data_forget($resource, 'environment_variables'); + data_forget($resource, 'environment_variables_preview'); + $resource->fqdn = $fqdnWithPort; + $resource->save(); + } + + if (substr_count(str($key)->value(), '_') === 2) { + $resource->environment_variables()->updateOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + if (substr_count(str($key)->value(), '_') === 3) { + + $newKey = str($key)->beforeLast('_'); + $resource->environment_variables()->updateOrCreate([ + 'key' => $newKey->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + } + } + + $allMagicEnvironments = $allMagicEnvironments->merge($magicEnvironments); + if ($magicEnvironments->count() > 0) { + foreach ($magicEnvironments as $key => $value) { + $key = str($key); + $value = replaceVariables($value); + $command = parseCommandFromMagicEnvVariable($key); + if ($command->value() === 'FQDN') { + if ($isOneClick) { + $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); + if (str($fqdnFor)->contains('_')) { + $fqdnFor = str($fqdnFor)->before('_'); + } + $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + } elseif ($command->value() === 'URL') { + if ($isOneClick) { + $fqdnFor = $key->after('SERVICE_URL_')->lower()->value(); + if (str($fqdnFor)->contains('_')) { + $fqdnFor = str($fqdnFor)->before('_'); + } + $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); + $fqdn = str($fqdn)->replace('http://', '')->replace('https://', ''); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + } else { + $value = generateEnvValue($command, $resource); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $value, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + } + } + } + + // Parse the rest of the services + foreach ($services as $serviceName => $service) { + $image = data_get_str($service, 'image'); + $restart = data_get_str($service, 'restart', RESTART_MODE); + $logging = data_get($service, 'logging'); + + if ($server->isLogDrainEnabled()) { + if ($resource->isLogDrainEnabled()) { + $logging = generate_fluentd_configuration(); + } + } + $volumes = collect(data_get($service, 'volumes', [])); + $networks = collect(data_get($service, 'networks', [])); + $use_network_mode = data_get($service, 'network_mode') !== null; + $depends_on = collect(data_get($service, 'depends_on', [])); + $labels = collect(data_get($service, 'labels', [])); + if ($labels->count() > 0) { + if (isAssociativeArray($labels)) { + $newLabels = collect([]); + $labels->each(function ($value, $key) use ($newLabels) { + $newLabels->push("$key=$value"); + }); + $labels = $newLabels; + } + } + $environment = collect(data_get($service, 'environment', [])); + $ports = collect(data_get($service, 'ports', [])); + $buildArgs = collect(data_get($service, 'build.args', [])); + $environment = $environment->merge($buildArgs); + + $environment = convertToKeyValueCollection($environment); + $coolifyEnvironments = collect([]); + + $isDatabase = isDatabaseImage($image, $service); + $volumesParsed = collect([]); + + $baseName = generateApplicationContainerName( + application: $resource, + pull_request_id: $pullRequestId + ); + $containerName = "$serviceName-$baseName"; + $predefinedPort = null; + + $originalResource = $resource; + + if ($volumes->count() > 0) { + foreach ($volumes as $index => $volume) { + $type = null; + $source = null; + $target = null; + $content = null; + $isDirectory = false; + if (is_string($volume)) { + $source = str($volume)->before(':'); + $target = str($volume)->after(':')->beforeLast(':'); + $foundConfig = $fileStorages->whereMountPath($target)->first(); + if (sourceIsLocal($source)) { + $type = str('bind'); + if ($foundConfig) { + $contentNotNull_temp = data_get($foundConfig, 'content'); + if ($contentNotNull_temp) { + $content = $contentNotNull_temp; + } + $isDirectory = data_get($foundConfig, 'is_directory'); + } else { + // By default, we cannot determine if the bind is a directory or not, so we set it to directory + $isDirectory = true; + } + } else { + $type = str('volume'); + } + } elseif (is_array($volume)) { + $type = data_get_str($volume, 'type'); + $source = data_get_str($volume, 'source'); + $target = data_get_str($volume, 'target'); + $content = data_get($volume, 'content'); + $isDirectory = (bool) data_get($volume, 'isDirectory', null) || (bool) data_get($volume, 'is_directory', null); + + $foundConfig = $fileStorages->whereMountPath($target)->first(); + if ($foundConfig) { + $contentNotNull_temp = data_get($foundConfig, 'content'); + if ($contentNotNull_temp) { + $content = $contentNotNull_temp; + } + $isDirectory = data_get($foundConfig, 'is_directory'); + } else { + // if isDirectory is not set (or false) & content is also not set, we assume it is a directory + if ((is_null($isDirectory) || ! $isDirectory) && is_null($content)) { + $isDirectory = true; + } + } + } + if ($type->value() === 'bind') { + if ($source->value() === '/var/run/docker.sock') { + $volume = $source->value().':'.$target->value(); + } elseif ($source->value() === '/tmp' || $source->value() === '/tmp/') { + $volume = $source->value().':'.$target->value(); + } else { + if ((int) $resource->compose_parsing_version >= 4) { + $mainDirectory = str(base_configuration_dir().'/applications/'.$uuid); + } else { + $mainDirectory = str(base_configuration_dir().'/applications/'.$uuid); + } + $source = replaceLocalSource($source, $mainDirectory); + if ($isPullRequest) { + $source = $source."-pr-$pullRequestId"; + } + LocalFileVolume::updateOrCreate( + [ + 'mount_path' => $target, + 'resource_id' => $originalResource->id, + 'resource_type' => get_class($originalResource), + ], + [ + 'fs_path' => $source, + 'mount_path' => $target, + 'content' => $content, + 'is_directory' => $isDirectory, + 'resource_id' => $originalResource->id, + 'resource_type' => get_class($originalResource), + ] + ); + if (isDev()) { + if ((int) $resource->compose_parsing_version >= 4) { + $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/applications/'.$uuid); + } else { + $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/applications/'.$uuid); + } + } + $volume = "$source:$target"; + } + } elseif ($type->value() === 'volume') { + if ($topLevel->get('volumes')->has($source->value())) { + $temp = $topLevel->get('volumes')->get($source->value()); + if (data_get($temp, 'driver_opts.type') === 'cifs') { + continue; + } + if (data_get($temp, 'driver_opts.type') === 'nfs') { + continue; + } + } + $slugWithoutUuid = Str::slug($source, '-'); + $name = "{$uuid}_{$slugWithoutUuid}"; + + if ($isPullRequest) { + $name = "{$name}-pr-$pullRequestId"; + } + if (is_string($volume)) { + $source = str($volume)->before(':'); + $target = str($volume)->after(':')->beforeLast(':'); + $source = $name; + $volume = "$source:$target"; + } elseif (is_array($volume)) { + data_set($volume, 'source', $name); + } + $topLevel->get('volumes')->put($name, [ + 'name' => $name, + ]); + LocalPersistentVolume::updateOrCreate( + [ + 'name' => $name, + 'resource_id' => $originalResource->id, + 'resource_type' => get_class($originalResource), + ], + [ + 'name' => $name, + 'mount_path' => $target, + 'resource_id' => $originalResource->id, + 'resource_type' => get_class($originalResource), + ] + ); + } + dispatch(new ServerFilesFromServerJob($originalResource)); + $volumesParsed->put($index, $volume); + } + } + + if ($depends_on?->count() > 0) { + if ($isPullRequest) { + $newDependsOn = collect([]); + $depends_on->each(function ($dependency, $condition) use ($pullRequestId, $newDependsOn) { + if (is_numeric($condition)) { + $dependency = "$dependency-pr-$pullRequestId"; + + $newDependsOn->put($condition, $dependency); + } else { + $condition = "$condition-pr-$pullRequestId"; + $newDependsOn->put($condition, $dependency); + } + }); + $depends_on = $newDependsOn; + } + } + if (! $use_network_mode) { + if ($topLevel->get('networks')?->count() > 0) { + foreach ($topLevel->get('networks') as $networkName => $network) { + if ($networkName === 'default') { + continue; + } + // ignore aliases + if ($network['aliases'] ?? false) { + continue; + } + $networkExists = $networks->contains(function ($value, $key) use ($networkName) { + return $value == $networkName || $key == $networkName; + }); + if (! $networkExists) { + $networks->put($networkName, null); + } + } + } + $baseNetworkExists = $networks->contains(function ($value, $_) use ($baseNetwork) { + return $value == $baseNetwork; + }); + if (! $baseNetworkExists) { + foreach ($baseNetwork as $network) { + $topLevel->get('networks')->put($network, [ + 'name' => $network, + 'external' => true, + ]); + } + } + } + + // Collect/create/update ports + $collectedPorts = collect([]); + if ($ports->count() > 0) { + foreach ($ports as $sport) { + if (is_string($sport) || is_numeric($sport)) { + $collectedPorts->push($sport); + } + if (is_array($sport)) { + $target = data_get($sport, 'target'); + $published = data_get($sport, 'published'); + $protocol = data_get($sport, 'protocol'); + $collectedPorts->push("$target:$published/$protocol"); + } + } + } + + $networks_temp = collect(); + + if (! $use_network_mode) { + foreach ($networks as $key => $network) { + if (gettype($network) === 'string') { + // networks: + // - appwrite + $networks_temp->put($network, null); + } elseif (gettype($network) === 'array') { + // networks: + // default: + // ipv4_address: 192.168.203.254 + $networks_temp->put($key, $network); + } + } + foreach ($baseNetwork as $key => $network) { + $networks_temp->put($network, null); + } + + if (data_get($resource, 'settings.connect_to_docker_network')) { + $network = $resource->destination->network; + $networks_temp->put($network, null); + $topLevel->get('networks')->put($network, [ + 'name' => $network, + 'external' => true, + ]); + } + } + + $normalEnvironments = $environment->diffKeys($allMagicEnvironments); + $normalEnvironments = $normalEnvironments->filter(function ($value, $key) { + return ! str($value)->startsWith('SERVICE_'); + }); + foreach ($normalEnvironments as $key => $value) { + $key = str($key); + $value = str($value); + $originalValue = $value; + $parsedValue = replaceVariables($value); + if ($value->startsWith('$SERVICE_')) { + $resource->environment_variables()->firstOrCreate([ + 'key' => $key, + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $value, + 'is_build_time' => false, + 'is_preview' => false, + ]); + + continue; + } + if (! $value->startsWith('$')) { + continue; + } + if ($key->value() === $parsedValue->value()) { + $value = null; + $resource->environment_variables()->firstOrCreate([ + 'key' => $key, + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $value, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } else { + if ($value->startsWith('$')) { + $isRequired = false; + if ($value->contains(':-')) { + $value = replaceVariables($value); + $key = $value->before(':'); + $value = $value->after(':-'); + } elseif ($value->contains('-')) { + $value = replaceVariables($value); + + $key = $value->before('-'); + $value = $value->after('-'); + } elseif ($value->contains(':?')) { + $value = replaceVariables($value); + + $key = $value->before(':'); + $value = $value->after(':?'); + $isRequired = true; + } elseif ($value->contains('?')) { + $value = replaceVariables($value); + + $key = $value->before('?'); + $value = $value->after('?'); + $isRequired = true; + } + if ($originalValue->value() === $value->value()) { + // This means the variable does not have a default value, so it needs to be created in Coolify + $parsedKeyValue = replaceVariables($value); + $resource->environment_variables()->firstOrCreate([ + 'key' => $parsedKeyValue, + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'is_build_time' => false, + 'is_preview' => false, + 'is_required' => $isRequired, + ]); + // Add the variable to the environment so it will be shown in the deployable compose file + $environment[$parsedKeyValue->value()] = $value; + + continue; + } + $resource->environment_variables()->firstOrCreate([ + 'key' => $key, + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $value, + 'is_build_time' => false, + 'is_preview' => false, + 'is_required' => $isRequired, + ]); + } + } + } + $branch = $originalResource->git_branch; + if ($pullRequestId !== 0) { + $branch = "pull/{$pullRequestId}/head"; + } + if ($originalResource->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) { + $coolifyEnvironments->put('COOLIFY_BRANCH', "\"{$branch}\""); + } + + // Add COOLIFY_RESOURCE_UUID to environment + if ($resource->environment_variables->where('key', 'COOLIFY_RESOURCE_UUID')->isEmpty()) { + $coolifyEnvironments->put('COOLIFY_RESOURCE_UUID', "{$resource->uuid}"); + } + + // Add COOLIFY_CONTAINER_NAME to environment + if ($resource->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) { + $coolifyEnvironments->put('COOLIFY_CONTAINER_NAME', "{$containerName}"); + } + + if ($isPullRequest) { + $preview = $resource->previews()->find($preview_id); + $domains = collect(json_decode(data_get($preview, 'docker_compose_domains'))) ?? collect([]); + } else { + $domains = collect(json_decode($resource->docker_compose_domains)) ?? collect([]); + } + ray($domains); + $fqdns = data_get($domains, "$serviceName.domain"); + // Generate SERVICE_FQDN & SERVICE_URL for dockercompose + if ($resource->build_pack === 'dockercompose') { + foreach ($domains as $forServiceName => $domain) { + $parsedDomain = data_get($domain, 'domain'); + $serviceNameFormatted = str($serviceName)->upper()->replace('-', '_'); + + if (filled($parsedDomain)) { + $parsedDomain = str($parsedDomain)->explode(',')->first(); + $coolifyUrl = Url::fromString($parsedDomain); + $coolifyScheme = $coolifyUrl->getScheme(); + $coolifyFqdn = $coolifyUrl->getHost(); + $coolifyUrl = $coolifyUrl->withScheme($coolifyScheme)->withHost($coolifyFqdn)->withPort(null); + $coolifyEnvironments->put('SERVICE_URL_'.str($forServiceName)->upper()->replace('-', '_'), $coolifyUrl->__toString()); + $coolifyEnvironments->put('SERVICE_FQDN_'.str($forServiceName)->upper()->replace('-', '_'), $coolifyFqdn); + $resource->environment_variables()->updateOrCreate([ + 'resourceable_type' => Application::class, + 'resourceable_id' => $resource->id, + 'key' => 'SERVICE_URL_'.str($forServiceName)->upper()->replace('-', '_'), + ], [ + 'value' => $coolifyUrl->__toString(), + 'is_build_time' => false, + 'is_preview' => false, + ]); + $resource->environment_variables()->updateOrCreate([ + 'resourceable_type' => Application::class, + 'resourceable_id' => $resource->id, + 'key' => 'SERVICE_FQDN_'.str($forServiceName)->upper()->replace('-', '_'), + ], [ + 'value' => $coolifyFqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } else { + $resource->environment_variables()->where('resourceable_type', Application::class) + ->where('resourceable_id', $resource->id) + ->where('key', 'LIKE', "SERVICE_FQDN_{$serviceNameFormatted}%") + ->delete(); + $resource->environment_variables()->where('resourceable_type', Application::class) + ->where('resourceable_id', $resource->id) + ->where('key', 'LIKE', "SERVICE_URL_{$serviceNameFormatted}%") + ->delete(); + } + } + } + // If the domain is set, we need to generate the FQDNs for the preview + if (filled($fqdns)) { + $fqdns = str($fqdns)->explode(','); + if ($isPullRequest) { + $preview = $resource->previews()->find($preview_id); + $docker_compose_domains = collect(json_decode(data_get($preview, 'docker_compose_domains'))); + if ($docker_compose_domains->count() > 0) { + $found_fqdn = data_get($docker_compose_domains, "$serviceName.domain"); + if ($found_fqdn) { + $fqdns = collect($found_fqdn); + } else { + $fqdns = collect([]); + } + } else { + $fqdns = $fqdns->map(function ($fqdn) use ($pullRequestId, $resource) { + $preview = ApplicationPreview::findPreviewByApplicationAndPullId($resource->id, $pullRequestId); + $url = Url::fromString($fqdn); + $template = $resource->preview_url_template; + $host = $url->getHost(); + $schema = $url->getScheme(); + $random = new Cuid2; + $preview_fqdn = str_replace('{{random}}', $random, $template); + $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn); + $preview_fqdn = str_replace('{{pr_id}}', $pullRequestId, $preview_fqdn); + $preview_fqdn = "$schema://$preview_fqdn"; + $preview->fqdn = $preview_fqdn; + $preview->save(); + + return $preview_fqdn; + }); + } + } + } + $defaultLabels = defaultLabels( + id: $resource->id, + name: $containerName, + projectName: $resource->project()->name, + resourceName: $resource->name, + pull_request_id: $pullRequestId, + type: 'application', + environment: $resource->environment->name, + ); + + $isDatabase = isDatabaseImage($image, $service); + // Add COOLIFY_FQDN & COOLIFY_URL to environment + if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) { + $fqdnsWithoutPort = $fqdns->map(function ($fqdn) { + return str($fqdn)->after('://')->before(':')->prepend(str($fqdn)->before('://')->append('://')); + }); + $coolifyEnvironments->put('COOLIFY_URL', $fqdnsWithoutPort->implode(',')); + + $urls = $fqdns->map(function ($fqdn) { + return str($fqdn)->replace('http://', '')->replace('https://', '')->before(':'); + }); + $coolifyEnvironments->put('COOLIFY_FQDN', $urls->implode(',')); + } + add_coolify_default_environment_variables($resource, $coolifyEnvironments, $resource->environment_variables); + if ($environment->count() > 0) { + $environment = $environment->filter(function ($value, $key) { + return ! str($key)->startsWith('SERVICE_FQDN_'); + })->map(function ($value, $key) use ($resource) { + // if value is empty, set it to null so if you set the environment variable in the .env file (Coolify's UI), it will used + if (str($value)->isEmpty()) { + if ($resource->environment_variables()->where('key', $key)->exists()) { + $value = $resource->environment_variables()->where('key', $key)->first()->value; + } else { + $value = null; + } + } + + return $value; + }); + } + $serviceLabels = $labels->merge($defaultLabels); + if ($serviceLabels->count() > 0) { + $isContainerLabelEscapeEnabled = data_get($resource, 'settings.is_container_label_escape_enabled'); + if ($isContainerLabelEscapeEnabled) { + $serviceLabels = $serviceLabels->map(function ($value, $key) { + return escapeDollarSign($value); + }); + } + } + if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) { + $shouldGenerateLabelsExactly = $resource->destination->server->settings->generate_exact_labels; + $uuid = $resource->uuid; + $network = data_get($resource, 'destination.network'); + if ($isPullRequest) { + $uuid = "{$resource->uuid}-{$pullRequestId}"; + } + if ($isPullRequest) { + $network = "{$resource->destination->network}-{$pullRequestId}"; + } + if ($shouldGenerateLabelsExactly) { + switch ($server->proxyType()) { + case ProxyTypes::TRAEFIK->value: + $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik( + uuid: $uuid, + domains: $fqdns, + is_force_https_enabled: true, + serviceLabels: $serviceLabels, + is_gzip_enabled: $originalResource->isGzipEnabled(), + is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), + service_name: $serviceName, + image: $image + )); + break; + case ProxyTypes::CADDY->value: + $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy( + network: $network, + uuid: $uuid, + domains: $fqdns, + is_force_https_enabled: true, + serviceLabels: $serviceLabels, + is_gzip_enabled: $originalResource->isGzipEnabled(), + is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), + service_name: $serviceName, + image: $image, + predefinedPort: $predefinedPort + )); + break; + } + } else { + $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik( + uuid: $uuid, + domains: $fqdns, + is_force_https_enabled: true, + serviceLabels: $serviceLabels, + is_gzip_enabled: $originalResource->isGzipEnabled(), + is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), + service_name: $serviceName, + image: $image + )); + $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy( + network: $network, + uuid: $uuid, + domains: $fqdns, + is_force_https_enabled: true, + serviceLabels: $serviceLabels, + is_gzip_enabled: $originalResource->isGzipEnabled(), + is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), + service_name: $serviceName, + image: $image, + predefinedPort: $predefinedPort + )); + } + } + data_forget($service, 'volumes.*.content'); + data_forget($service, 'volumes.*.isDirectory'); + data_forget($service, 'volumes.*.is_directory'); + data_forget($service, 'exclude_from_hc'); + + $volumesParsed = $volumesParsed->map(function ($volume) { + data_forget($volume, 'content'); + data_forget($volume, 'is_directory'); + data_forget($volume, 'isDirectory'); + + return $volume; + }); + + $payload = collect($service)->merge([ + 'container_name' => $containerName, + 'restart' => $restart->value(), + 'labels' => $serviceLabels, + ]); + if (! $use_network_mode) { + $payload['networks'] = $networks_temp; + } + if ($ports->count() > 0) { + $payload['ports'] = $ports; + } + if ($volumesParsed->count() > 0) { + $payload['volumes'] = $volumesParsed; + } + if ($environment->count() > 0 || $coolifyEnvironments->count() > 0) { + $payload['environment'] = $environment->merge($coolifyEnvironments); + } + if ($logging) { + $payload['logging'] = $logging; + } + if ($depends_on->count() > 0) { + $payload['depends_on'] = $depends_on; + } + if ($isPullRequest) { + $serviceName = "{$serviceName}-pr-{$pullRequestId}"; + } + + $parsedServices->put($serviceName, $payload); + } + $topLevel->put('services', $parsedServices); + + $customOrder = ['services', 'volumes', 'networks', 'configs', 'secrets']; + + $topLevel = $topLevel->sortBy(function ($value, $key) use ($customOrder) { + return array_search($key, $customOrder); + }); + + $resource->docker_compose = Yaml::dump(convertToArray($topLevel), 10, 2); + data_forget($resource, 'environment_variables'); + data_forget($resource, 'environment_variables_preview'); + $resource->save(); + + return $topLevel; +} + +function serviceParser(Service $resource, bool $isOneClick = false): Collection +{ + $uuid = data_get($resource, 'uuid'); + $compose = data_get($resource, 'docker_compose_raw'); + if (! $compose) { + return collect([]); + } + + $server = data_get($resource, 'server'); + $allServices = get_service_templates(); + + try { + $yaml = Yaml::parse($compose); + } catch (\Exception) { + return collect([]); + } + $services = data_get($yaml, 'services', collect([])); + $topLevel = collect([ + 'volumes' => collect(data_get($yaml, 'volumes', [])), + 'networks' => collect(data_get($yaml, 'networks', [])), + 'configs' => collect(data_get($yaml, 'configs', [])), + 'secrets' => collect(data_get($yaml, 'secrets', [])), + ]); + // If there are predefined volumes, make sure they are not null + if ($topLevel->get('volumes')->count() > 0) { + $temp = collect([]); + foreach ($topLevel['volumes'] as $volumeName => $volume) { + if (is_null($volume)) { + continue; + } + $temp->put($volumeName, $volume); + } + $topLevel['volumes'] = $temp; + } + // Get the base docker network + $baseNetwork = collect([$uuid]); + + $parsedServices = collect([]); + + $allMagicEnvironments = collect([]); + foreach ($services as $serviceName => $service) { + $predefinedPort = null; + $magicEnvironments = collect([]); + $image = data_get_str($service, 'image'); + $environment = collect(data_get($service, 'environment', [])); + $buildArgs = collect(data_get($service, 'build.args', [])); + $environment = $environment->merge($buildArgs); + $isDatabase = isDatabaseImage($image, $service); + + $containerName = "$serviceName-{$resource->uuid}"; + + if ($serviceName === 'registry') { + $tempServiceName = 'docker-registry'; + } else { + $tempServiceName = $serviceName; + } + if (str(data_get($service, 'image'))->contains('glitchtip')) { + $tempServiceName = 'glitchtip'; + } + if ($serviceName === 'supabase-kong') { + $tempServiceName = 'supabase'; + } + $serviceDefinition = data_get($allServices, $tempServiceName); + $predefinedPort = data_get($serviceDefinition, 'port'); + if ($serviceName === 'plausible') { + $predefinedPort = '8000'; + } + if ($isDatabase) { + $applicationFound = ServiceApplication::where('name', $serviceName)->where('service_id', $resource->id)->first(); + if ($applicationFound) { + $savedService = $applicationFound; + } else { + $savedService = ServiceDatabase::firstOrCreate([ + 'name' => $serviceName, + 'service_id' => $resource->id, + ]); + } + } else { + $savedService = ServiceApplication::firstOrCreate([ + 'name' => $serviceName, + 'service_id' => $resource->id, + ], [ + 'is_gzip_enabled' => true, + ]); + } + // Check if image changed + if ($savedService->image !== $image) { + $savedService->image = $image; + $savedService->save(); + } + // Pocketbase does not need gzip for SSE. + if (str($savedService->image)->contains('pocketbase') && $savedService->is_gzip_enabled) { + $savedService->is_gzip_enabled = false; + $savedService->save(); + } + + $environment = collect(data_get($service, 'environment', [])); + $buildArgs = collect(data_get($service, 'build.args', [])); + $environment = $environment->merge($buildArgs); + + // convert environment variables to one format + $environment = convertToKeyValueCollection($environment); + + // Add Coolify defined environments + $allEnvironments = $resource->environment_variables()->get(['key', 'value']); + + $allEnvironments = $allEnvironments->mapWithKeys(function ($item) { + return [$item['key'] => $item['value']]; + }); + // filter and add magic environments + foreach ($environment as $key => $value) { + // Get all SERVICE_ variables from keys and values + $key = str($key); + $value = str($value); + $regex = '/\$(\{?([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)\}?)/'; + preg_match_all($regex, $value, $valueMatches); + if (count($valueMatches[1]) > 0) { + foreach ($valueMatches[1] as $match) { + $match = replaceVariables($match); + if ($match->startsWith('SERVICE_')) { + if ($magicEnvironments->has($match->value())) { + continue; + } + $magicEnvironments->put($match->value(), ''); + } + } + } + // Get magic environments where we need to preset the FQDN + if ($key->startsWith('SERVICE_FQDN_')) { + // SERVICE_FQDN_APP or SERVICE_FQDN_APP_3000 + if (substr_count(str($key)->value(), '_') === 3) { + $fqdnFor = $key->after('SERVICE_FQDN_')->beforeLast('_')->lower()->value(); + $port = $key->afterLast('_')->value(); + } else { + $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); + $port = null; + } + if ($isOneClick) { + if (blank($savedService->fqdn)) { + if ($fqdnFor) { + $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); + } else { + $fqdn = generateFqdn($server, "{$savedService->name}-$uuid"); + } + } else { + $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); + } + + } else { + // For services which are not one-click, if no explicit FQDN is set, leave SERVICE_FQDN_ variables empty + if (blank($savedService->fqdn)) { + $fqdn = ''; + } else { + $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); + } + } + if ($value && get_class($value) === \Illuminate\Support\Stringable::class && $value->startsWith('/')) { + $path = $value->value(); + if ($path !== '/') { + $fqdn = "$fqdn$path"; + } + } + $fqdnWithPort = $fqdn; + if ($port) { + $fqdnWithPort = "$fqdn:$port"; + } + if (is_null($savedService->fqdn)) { + $savedService->fqdn = $fqdnWithPort; + $savedService->save(); + } + + if (substr_count(str($key)->value(), '_') === 2) { + $resource->environment_variables()->updateOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + if (substr_count(str($key)->value(), '_') === 3) { + $newKey = str($key)->beforeLast('_'); + $resource->environment_variables()->updateOrCreate([ + 'key' => $newKey->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + } + } + + $allMagicEnvironments = $allMagicEnvironments->merge($magicEnvironments); + if ($magicEnvironments->count() > 0) { + foreach ($magicEnvironments as $key => $value) { + $key = str($key); + $value = replaceVariables($value); + $command = parseCommandFromMagicEnvVariable($key); + if ($command->value() === 'FQDN') { + if ($isOneClick) { + $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); + if (str($fqdnFor)->contains('_')) { + $fqdnFor = str($fqdnFor)->before('_'); + } + $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + } elseif ($command->value() === 'URL') { + if ($isOneClick) { + $fqdnFor = $key->after('SERVICE_URL_')->lower()->value(); + if (str($fqdnFor)->contains('_')) { + $fqdnFor = str($fqdnFor)->before('_'); + } + $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); + $fqdn = str($fqdn)->replace('http://', '')->replace('https://', ''); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + } else { + $value = generateEnvValue($command, $resource); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $value, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } + } + } + } + + $serviceAppsLogDrainEnabledMap = $resource->applications()->get()->keyBy('name')->map(function ($app) { + return $app->isLogDrainEnabled(); + }); + + // Parse the rest of the services + foreach ($services as $serviceName => $service) { + $image = data_get_str($service, 'image'); + $restart = data_get_str($service, 'restart', RESTART_MODE); + $logging = data_get($service, 'logging'); + + if ($server->isLogDrainEnabled()) { + if ($serviceAppsLogDrainEnabledMap->get($serviceName)) { + $logging = generate_fluentd_configuration(); + } + } + $volumes = collect(data_get($service, 'volumes', [])); + $networks = collect(data_get($service, 'networks', [])); + $use_network_mode = data_get($service, 'network_mode') !== null; + $depends_on = collect(data_get($service, 'depends_on', [])); + $labels = collect(data_get($service, 'labels', [])); + if ($labels->count() > 0) { + if (isAssociativeArray($labels)) { + $newLabels = collect([]); + $labels->each(function ($value, $key) use ($newLabels) { + $newLabels->push("$key=$value"); + }); + $labels = $newLabels; + } + } + $environment = collect(data_get($service, 'environment', [])); + $ports = collect(data_get($service, 'ports', [])); + $buildArgs = collect(data_get($service, 'build.args', [])); + $environment = $environment->merge($buildArgs); + + $environment = convertToKeyValueCollection($environment); + $coolifyEnvironments = collect([]); + + $isDatabase = isDatabaseImage($image, $service); + $volumesParsed = collect([]); + + $containerName = "$serviceName-{$resource->uuid}"; + + if ($serviceName === 'registry') { + $tempServiceName = 'docker-registry'; + } else { + $tempServiceName = $serviceName; + } + if (str(data_get($service, 'image'))->contains('glitchtip')) { + $tempServiceName = 'glitchtip'; + } + if ($serviceName === 'supabase-kong') { + $tempServiceName = 'supabase'; + } + $serviceDefinition = data_get($allServices, $tempServiceName); + $predefinedPort = data_get($serviceDefinition, 'port'); + if ($serviceName === 'plausible') { + $predefinedPort = '8000'; + } + + if ($isDatabase) { + $applicationFound = ServiceApplication::where('name', $serviceName)->where('image', $image)->where('service_id', $resource->id)->first(); + if ($applicationFound) { + $savedService = $applicationFound; + } else { + $savedService = ServiceDatabase::firstOrCreate([ + 'name' => $serviceName, + 'image' => $image, + 'service_id' => $resource->id, + ]); + } + } else { + $savedService = ServiceApplication::firstOrCreate([ + 'name' => $serviceName, + 'image' => $image, + 'service_id' => $resource->id, + ]); + } + $fileStorages = $savedService->fileStorages(); + if ($savedService->image !== $image) { + $savedService->image = $image; + $savedService->save(); + } + + $originalResource = $savedService; + + if ($volumes->count() > 0) { + foreach ($volumes as $index => $volume) { + $type = null; + $source = null; + $target = null; + $content = null; + $isDirectory = false; + if (is_string($volume)) { + $source = str($volume)->before(':'); + $target = str($volume)->after(':')->beforeLast(':'); + $foundConfig = $fileStorages->whereMountPath($target)->first(); + if (sourceIsLocal($source)) { + $type = str('bind'); + if ($foundConfig) { + $contentNotNull_temp = data_get($foundConfig, 'content'); + if ($contentNotNull_temp) { + $content = $contentNotNull_temp; + } + $isDirectory = data_get($foundConfig, 'is_directory'); + } else { + // By default, we cannot determine if the bind is a directory or not, so we set it to directory + $isDirectory = true; + } + } else { + $type = str('volume'); + } + } elseif (is_array($volume)) { + $type = data_get_str($volume, 'type'); + $source = data_get_str($volume, 'source'); + $target = data_get_str($volume, 'target'); + $content = data_get($volume, 'content'); + $isDirectory = (bool) data_get($volume, 'isDirectory', null) || (bool) data_get($volume, 'is_directory', null); + + $foundConfig = $fileStorages->whereMountPath($target)->first(); + if ($foundConfig) { + $contentNotNull_temp = data_get($foundConfig, 'content'); + if ($contentNotNull_temp) { + $content = $contentNotNull_temp; + } + $isDirectory = data_get($foundConfig, 'is_directory'); + } else { + // if isDirectory is not set (or false) & content is also not set, we assume it is a directory + if ((is_null($isDirectory) || ! $isDirectory) && is_null($content)) { + $isDirectory = true; + } + } + } + if ($type->value() === 'bind') { + if ($source->value() === '/var/run/docker.sock') { + $volume = $source->value().':'.$target->value(); + } elseif ($source->value() === '/tmp' || $source->value() === '/tmp/') { + $volume = $source->value().':'.$target->value(); + } else { + if ((int) $resource->compose_parsing_version >= 4) { + $mainDirectory = str(base_configuration_dir().'/services/'.$uuid); + } else { + $mainDirectory = str(base_configuration_dir().'/applications/'.$uuid); + } + $source = replaceLocalSource($source, $mainDirectory); + LocalFileVolume::updateOrCreate( + [ + 'mount_path' => $target, + 'resource_id' => $originalResource->id, + 'resource_type' => get_class($originalResource), + ], + [ + 'fs_path' => $source, + 'mount_path' => $target, + 'content' => $content, + 'is_directory' => $isDirectory, + 'resource_id' => $originalResource->id, + 'resource_type' => get_class($originalResource), + ] + ); + if (isDev()) { + if ((int) $resource->compose_parsing_version >= 4) { + $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/services/'.$uuid); + } else { + $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/applications/'.$uuid); + } + } + $volume = "$source:$target"; + } + } elseif ($type->value() === 'volume') { + if ($topLevel->get('volumes')->has($source->value())) { + $temp = $topLevel->get('volumes')->get($source->value()); + if (data_get($temp, 'driver_opts.type') === 'cifs') { + continue; + } + if (data_get($temp, 'driver_opts.type') === 'nfs') { + continue; + } + } + $slugWithoutUuid = Str::slug($source, '-'); + $name = "{$uuid}_{$slugWithoutUuid}"; + + if (is_string($volume)) { + $source = str($volume)->before(':'); + $target = str($volume)->after(':')->beforeLast(':'); + $source = $name; + $volume = "$source:$target"; + } elseif (is_array($volume)) { + data_set($volume, 'source', $name); + } + $topLevel->get('volumes')->put($name, [ + 'name' => $name, + ]); + LocalPersistentVolume::updateOrCreate( + [ + 'name' => $name, + 'resource_id' => $originalResource->id, + 'resource_type' => get_class($originalResource), + ], + [ + 'name' => $name, + 'mount_path' => $target, + 'resource_id' => $originalResource->id, + 'resource_type' => get_class($originalResource), + ] + ); + } + dispatch(new ServerFilesFromServerJob($originalResource)); + $volumesParsed->put($index, $volume); + } + } + + if (! $use_network_mode) { + if ($topLevel->get('networks')?->count() > 0) { + foreach ($topLevel->get('networks') as $networkName => $network) { + if ($networkName === 'default') { + continue; + } + // ignore aliases + if ($network['aliases'] ?? false) { + continue; + } + $networkExists = $networks->contains(function ($value, $key) use ($networkName) { + return $value == $networkName || $key == $networkName; + }); + if (! $networkExists) { + $networks->put($networkName, null); + } + } + } + $baseNetworkExists = $networks->contains(function ($value, $_) use ($baseNetwork) { + return $value == $baseNetwork; + }); + if (! $baseNetworkExists) { + foreach ($baseNetwork as $network) { + $topLevel->get('networks')->put($network, [ + 'name' => $network, + 'external' => true, + ]); + } + } + } + + // Collect/create/update ports + $collectedPorts = collect([]); + if ($ports->count() > 0) { + foreach ($ports as $sport) { + if (is_string($sport) || is_numeric($sport)) { + $collectedPorts->push($sport); + } + if (is_array($sport)) { + $target = data_get($sport, 'target'); + $published = data_get($sport, 'published'); + $protocol = data_get($sport, 'protocol'); + $collectedPorts->push("$target:$published/$protocol"); + } + } + } + $originalResource->ports = $collectedPorts->implode(','); + $originalResource->save(); + + $networks_temp = collect(); + + if (! $use_network_mode) { + foreach ($networks as $key => $network) { + if (gettype($network) === 'string') { + // networks: + // - appwrite + $networks_temp->put($network, null); + } elseif (gettype($network) === 'array') { + // networks: + // default: + // ipv4_address: 192.168.203.254 + $networks_temp->put($key, $network); + } + } + foreach ($baseNetwork as $key => $network) { + $networks_temp->put($network, null); + } + } + + $normalEnvironments = $environment->diffKeys($allMagicEnvironments); + $normalEnvironments = $normalEnvironments->filter(function ($value, $key) { + return ! str($value)->startsWith('SERVICE_'); + }); + foreach ($normalEnvironments as $key => $value) { + $key = str($key); + $value = str($value); + $originalValue = $value; + $parsedValue = replaceVariables($value); + if ($value->startsWith('$SERVICE_')) { + $resource->environment_variables()->firstOrCreate([ + 'key' => $key, + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $value, + 'is_build_time' => false, + 'is_preview' => false, + ]); + + continue; + } + if (! $value->startsWith('$')) { + continue; + } + if ($key->value() === $parsedValue->value()) { + $value = null; + $resource->environment_variables()->firstOrCreate([ + 'key' => $key, + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $value, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } else { + if ($value->startsWith('$')) { + $isRequired = false; + if ($value->contains(':-')) { + $value = replaceVariables($value); + $key = $value->before(':'); + $value = $value->after(':-'); + } elseif ($value->contains('-')) { + $value = replaceVariables($value); + + $key = $value->before('-'); + $value = $value->after('-'); + } elseif ($value->contains(':?')) { + $value = replaceVariables($value); + + $key = $value->before(':'); + $value = $value->after(':?'); + $isRequired = true; + } elseif ($value->contains('?')) { + $value = replaceVariables($value); + + $key = $value->before('?'); + $value = $value->after('?'); + $isRequired = true; + } + if ($originalValue->value() === $value->value()) { + // This means the variable does not have a default value, so it needs to be created in Coolify + $parsedKeyValue = replaceVariables($value); + $resource->environment_variables()->firstOrCreate([ + 'key' => $parsedKeyValue, + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'is_build_time' => false, + 'is_preview' => false, + 'is_required' => $isRequired, + ]); + // Add the variable to the environment so it will be shown in the deployable compose file + $environment[$parsedKeyValue->value()] = $value; + + continue; + } + $resource->environment_variables()->firstOrCreate([ + 'key' => $key, + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $value, + 'is_build_time' => false, + 'is_preview' => false, + 'is_required' => $isRequired, + ]); + } + } + } + + // Add COOLIFY_RESOURCE_UUID to environment + if ($resource->environment_variables->where('key', 'COOLIFY_RESOURCE_UUID')->isEmpty()) { + $coolifyEnvironments->put('COOLIFY_RESOURCE_UUID', "{$resource->uuid}"); + } + + // Add COOLIFY_CONTAINER_NAME to environment + if ($resource->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) { + $coolifyEnvironments->put('COOLIFY_CONTAINER_NAME', "{$containerName}"); + } + + if ($savedService->serviceType()) { + $fqdns = generateServiceSpecificFqdns($savedService); + } else { + $fqdns = collect(data_get($savedService, 'fqdns'))->filter(); + } + + $defaultLabels = defaultLabels( + id: $resource->id, + name: $containerName, + projectName: $resource->project()->name, + resourceName: $resource->name, + type: 'service', + subType: $isDatabase ? 'database' : 'application', + subId: $savedService->id, + subName: $savedService->human_name ?? $savedService->name, + environment: $resource->environment->name, + ); + + // Add COOLIFY_FQDN & COOLIFY_URL to environment + if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) { + $fqdnsWithoutPort = $fqdns->map(function ($fqdn) { + return str($fqdn)->replace('http://', '')->replace('https://', '')->before(':'); + }); + $coolifyEnvironments->put('COOLIFY_FQDN', $fqdnsWithoutPort->implode(',')); + $urls = $fqdns->map(function ($fqdn) { + return str($fqdn)->after('://')->before(':')->prepend(str($fqdn)->before('://')->append('://')); + }); + $coolifyEnvironments->put('COOLIFY_URL', $urls->implode(',')); + } + add_coolify_default_environment_variables($resource, $coolifyEnvironments, $resource->environment_variables); + if ($environment->count() > 0) { + $environment = $environment->filter(function ($value, $key) { + return ! str($key)->startsWith('SERVICE_FQDN_'); + })->map(function ($value, $key) use ($resource) { + // if value is empty, set it to null so if you set the environment variable in the .env file (Coolify's UI), it will used + if (str($value)->isEmpty()) { + if ($resource->environment_variables()->where('key', $key)->exists()) { + $value = $resource->environment_variables()->where('key', $key)->first()->value; + } else { + $value = null; + } + } + + return $value; + }); + } + $serviceLabels = $labels->merge($defaultLabels); + if ($serviceLabels->count() > 0) { + $isContainerLabelEscapeEnabled = data_get($resource, 'is_container_label_escape_enabled'); + if ($isContainerLabelEscapeEnabled) { + $serviceLabels = $serviceLabels->map(function ($value, $key) { + return escapeDollarSign($value); + }); + } + } + if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) { + $shouldGenerateLabelsExactly = $resource->server->settings->generate_exact_labels; + $uuid = $resource->uuid; + $network = data_get($resource, 'destination.network'); + if ($shouldGenerateLabelsExactly) { + switch ($server->proxyType()) { + case ProxyTypes::TRAEFIK->value: + $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik( + uuid: $uuid, + domains: $fqdns, + is_force_https_enabled: true, + serviceLabels: $serviceLabels, + is_gzip_enabled: $originalResource->isGzipEnabled(), + is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), + service_name: $serviceName, + image: $image + )); + break; + case ProxyTypes::CADDY->value: + $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy( + network: $network, + uuid: $uuid, + domains: $fqdns, + is_force_https_enabled: true, + serviceLabels: $serviceLabels, + is_gzip_enabled: $originalResource->isGzipEnabled(), + is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), + service_name: $serviceName, + image: $image, + predefinedPort: $predefinedPort + )); + break; + } + } else { + $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik( + uuid: $uuid, + domains: $fqdns, + is_force_https_enabled: true, + serviceLabels: $serviceLabels, + is_gzip_enabled: $originalResource->isGzipEnabled(), + is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), + service_name: $serviceName, + image: $image + )); + $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy( + network: $network, + uuid: $uuid, + domains: $fqdns, + is_force_https_enabled: true, + serviceLabels: $serviceLabels, + is_gzip_enabled: $originalResource->isGzipEnabled(), + is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), + service_name: $serviceName, + image: $image, + predefinedPort: $predefinedPort + )); + } + } + if (data_get($service, 'restart') === 'no' || data_get($service, 'exclude_from_hc')) { + $savedService->update(['exclude_from_status' => true]); + } + data_forget($service, 'volumes.*.content'); + data_forget($service, 'volumes.*.isDirectory'); + data_forget($service, 'volumes.*.is_directory'); + data_forget($service, 'exclude_from_hc'); + + $volumesParsed = $volumesParsed->map(function ($volume) { + data_forget($volume, 'content'); + data_forget($volume, 'is_directory'); + data_forget($volume, 'isDirectory'); + + return $volume; + }); + + $payload = collect($service)->merge([ + 'container_name' => $containerName, + 'restart' => $restart->value(), + 'labels' => $serviceLabels, + ]); + if (! $use_network_mode) { + $payload['networks'] = $networks_temp; + } + if ($ports->count() > 0) { + $payload['ports'] = $ports; + } + if ($volumesParsed->count() > 0) { + $payload['volumes'] = $volumesParsed; + } + if ($environment->count() > 0 || $coolifyEnvironments->count() > 0) { + $payload['environment'] = $environment->merge($coolifyEnvironments); + } + if ($logging) { + $payload['logging'] = $logging; + } + if ($depends_on->count() > 0) { + $payload['depends_on'] = $depends_on; + } + + $parsedServices->put($serviceName, $payload); + } + $topLevel->put('services', $parsedServices); + + $customOrder = ['services', 'volumes', 'networks', 'configs', 'secrets']; + + $topLevel = $topLevel->sortBy(function ($value, $key) use ($customOrder) { + return array_search($key, $customOrder); + }); + + $resource->docker_compose = Yaml::dump(convertToArray($topLevel), 10, 2); + data_forget($resource, 'environment_variables'); + data_forget($resource, 'environment_variables_preview'); + $resource->save(); + + return $topLevel; +} diff --git a/bootstrap/helpers/services.php b/bootstrap/helpers/services.php index 1e1d2a073..cf12a28a5 100644 --- a/bootstrap/helpers/services.php +++ b/bootstrap/helpers/services.php @@ -1,7 +1,6 @@ image = $updatedImage; $resource->save(); } + + $serviceName = str($resource->name)->upper()->replace('-', '_'); + $resource->service->environment_variables()->where('key', 'LIKE', "SERVICE_FQDN_{$serviceName}%")->delete(); + $resource->service->environment_variables()->where('key', 'LIKE', "SERVICE_URL_{$serviceName}%")->delete(); + if ($resource->fqdn) { $resourceFqdns = str($resource->fqdn)->explode(','); - if ($resourceFqdns->count() === 1) { - $resourceFqdns = $resourceFqdns->first(); - $variableName = 'SERVICE_FQDN_'.str($resource->name)->upper()->replace('-', '_'); - $fqdn = Url::fromString($resourceFqdns); - $port = $fqdn->getPort(); - $path = $fqdn->getPath(); - $fqdn = $fqdn->getScheme().'://'.$fqdn->getHost(); - $fqdnValue = ($path === '/') ? $fqdn : $fqdn.$path; - EnvironmentVariable::updateOrCreate([ - 'resourceable_type' => Service::class, - 'resourceable_id' => $resource->service_id, - 'key' => $variableName, - ], [ - 'value' => $fqdnValue, - 'is_build_time' => false, - 'is_preview' => false, - ]); - if ($port) { - $variableName = $variableName."_$port"; - EnvironmentVariable::updateOrCreate([ - 'resourceable_type' => Service::class, - 'resourceable_id' => $resource->service_id, - 'key' => $variableName, - ], [ - 'value' => $fqdnValue, - 'is_build_time' => false, - 'is_preview' => false, - ]); - } - $variableName = 'SERVICE_URL_'.str($resource->name)->upper()->replace('-', '_'); - $url = Url::fromString($fqdn); - $port = $url->getPort(); - $path = $url->getPath(); - $url = $url->getHost(); - $urlValue = str($fqdn)->after('://'); - if ($path !== '/') { - $urlValue = $urlValue.$path; - } - EnvironmentVariable::updateOrCreate([ + $resourceFqdns = $resourceFqdns->first(); + $variableName = 'SERVICE_URL_'.str($resource->name)->upper()->replace('-', '_'); + $url = Url::fromString($resourceFqdns); + $port = $url->getPort(); + $path = $url->getPath(); + $urlValue = $url->getScheme().'://'.$url->getHost(); + $urlValue = ($path === '/') ? $urlValue : $urlValue.$path; + $resource->service->environment_variables()->updateOrCreate([ + 'resourceable_type' => Service::class, + 'resourceable_id' => $resource->service_id, + 'key' => $variableName, + ], [ + 'value' => $urlValue, + 'is_build_time' => false, + 'is_preview' => false, + ]); + if ($port) { + $variableName = $variableName."_$port"; + $resource->service->environment_variables()->updateOrCreate([ 'resourceable_type' => Service::class, 'resourceable_id' => $resource->service_id, 'key' => $variableName, @@ -164,114 +148,37 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource) 'is_build_time' => false, 'is_preview' => false, ]); - if ($port) { - $variableName = $variableName."_$port"; - EnvironmentVariable::updateOrCreate([ - 'resourceable_type' => Service::class, - 'resourceable_id' => $resource->service_id, - 'key' => $variableName, - ], [ - 'value' => $urlValue, - 'is_build_time' => false, - 'is_preview' => false, - ]); - } - } elseif ($resourceFqdns->count() > 1) { - foreach ($resourceFqdns as $fqdn) { - $host = Url::fromString($fqdn); - $port = $host->getPort(); - $url = $host->getHost(); - $path = $host->getPath(); - $host = $host->getScheme().'://'.$host->getHost(); - if ($port) { - $port_envs = EnvironmentVariable::where('resourceable_type', Service::class) - ->where('resourceable_id', $resource->service_id) - ->where('key', 'like', "SERVICE_FQDN_%_$port") - ->get(); - foreach ($port_envs as $port_env) { - $service_fqdn = str($port_env->key)->beforeLast('_')->after('SERVICE_FQDN_'); - $env = EnvironmentVariable::where('resourceable_type', Service::class) - ->where('resourceable_id', $resource->service_id) - ->where('key', 'SERVICE_FQDN_'.$service_fqdn) - ->first(); - if ($env) { - if ($path === '/') { - $env->value = $host; - } else { - $env->value = $host.$path; - } - $env->save(); - } - if ($path === '/') { - $port_env->value = $host; - } else { - $port_env->value = $host.$path; - } - $port_env->save(); - } - $port_envs_url = EnvironmentVariable::where('resourceable_type', Service::class) - ->where('resourceable_id', $resource->service_id) - ->where('key', 'like', "SERVICE_URL_%_$port") - ->get(); - foreach ($port_envs_url as $port_env_url) { - $service_url = str($port_env_url->key)->beforeLast('_')->after('SERVICE_URL_'); - $env = EnvironmentVariable::where('resourceable_type', Service::class) - ->where('resourceable_id', $resource->service_id) - ->where('key', 'SERVICE_URL_'.$service_url) - ->first(); - if ($env) { - if ($path === '/') { - $env->value = $url; - } else { - $env->value = $url.$path; - } - $env->save(); - } - if ($path === '/') { - $port_env_url->value = $url; - } else { - $port_env_url->value = $url.$path; - } - $port_env_url->save(); - } - } else { - $variableName = 'SERVICE_FQDN_'.str($resource->name)->upper()->replace('-', '_'); - $generatedEnv = EnvironmentVariable::where('resourceable_type', Service::class) - ->where('resourceable_id', $resource->service_id) - ->where('key', $variableName) - ->first(); - $fqdn = Url::fromString($fqdn); - $fqdn = $fqdn->getScheme().'://'.$fqdn->getHost().$fqdn->getPath(); - if ($generatedEnv) { - $generatedEnv->value = $fqdn; - $generatedEnv->save(); - } - $variableName = 'SERVICE_URL_'.str($resource->name)->upper()->replace('-', '_'); - $generatedEnv = EnvironmentVariable::where('resourceable_type', Service::class) - ->where('resourceable_id', $resource->service_id) - ->where('key', $variableName) - ->first(); - $url = Url::fromString($fqdn); - $url = $url->getHost().$url->getPath(); - if ($generatedEnv) { - $url = str($fqdn)->after('://'); - $generatedEnv->value = $url; - $generatedEnv->save(); - } - } - } } - } else { - // If FQDN is removed, delete the corresponding environment variables - $serviceName = str($resource->name)->upper()->replace('-', '_'); - EnvironmentVariable::where('resourceable_type', Service::class) - ->where('resourceable_id', $resource->service_id) - ->where('key', 'LIKE', "SERVICE_FQDN_{$serviceName}%") - ->delete(); - EnvironmentVariable::where('resourceable_type', Service::class) - ->where('resourceable_id', $resource->service_id) - ->where('key', 'LIKE', "SERVICE_URL_{$serviceName}%") - ->delete(); + $variableName = 'SERVICE_FQDN_'.str($resource->name)->upper()->replace('-', '_'); + $fqdn = Url::fromString($resourceFqdns); + $port = $fqdn->getPort(); + $path = $fqdn->getPath(); + $fqdn = $fqdn->getHost(); + $fqdnValue = str($fqdn)->after('://'); + if ($path !== '/') { + $fqdnValue = $fqdnValue.$path; + } + $resource->service->environment_variables()->updateOrCreate([ + 'resourceable_type' => Service::class, + 'resourceable_id' => $resource->service_id, + 'key' => $variableName, + ], [ + 'value' => $fqdnValue, + 'is_build_time' => false, + 'is_preview' => false, + ]); + if ($port) { + $variableName = $variableName."_$port"; + $resource->service->environment_variables()->updateOrCreate([ + 'resourceable_type' => Service::class, + 'resourceable_id' => $resource->service_id, + 'key' => $variableName, + ], [ + 'value' => $fqdnValue, + 'is_build_time' => false, + 'is_preview' => false, + ]); + } } } catch (\Throwable $e) { return handleError($e); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 7ce511f2c..1e9b95288 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -2918,10 +2918,18 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal } } -function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $preview_id = null): Collection +function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $preview_id = null, bool $isOneClick = false): Collection { $isApplication = $resource instanceof Application; $isService = $resource instanceof Service; + if ($isApplication) { + return applicationParser($resource, $pull_request_id, $preview_id); + } + if ($isService) { + return serviceParser($resource, $isOneClick); + } + + return collect([]); $uuid = data_get($resource, 'uuid'); $compose = data_get($resource, 'docker_compose_raw'); @@ -3078,14 +3086,25 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $fqdn = generateFqdn($server, "$uuid"); } } elseif ($isService) { - if (blank($savedService->fqdn)) { - if ($fqdnFor) { - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); + if ($isOneClick) { + if (blank($savedService->fqdn)) { + if ($fqdnFor) { + $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); + } else { + $fqdn = generateFqdn($server, "{$savedService->name}-$uuid"); + } } else { - $fqdn = generateFqdn($server, "{$savedService->name}-$uuid"); + $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); } + } else { - $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); + // For services which are not one-click, if no explicit FQDN is set, leave SERVICE_FQDN_ variables empty + if (blank($savedService->fqdn)) { + $fqdn = ''; + } else { + $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); + } + ray($fqdn); } } @@ -3141,51 +3160,41 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $key = str($key); $value = replaceVariables($value); $command = parseCommandFromMagicEnvVariable($key); - $found = $resource->environment_variables()->where('key', $key->value())->where('resourceable_type', get_class($resource))->where('resourceable_id', $resource->id)->first(); - if ($found) { - continue; - } if ($command->value() === 'FQDN') { - if ($isApplication && $resource->build_pack === 'dockercompose') { - continue; + if ($isOneClick) { + $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); + if (str($fqdnFor)->contains('_')) { + $fqdnFor = str($fqdnFor)->before('_'); + } + $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); } - $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); - if (str($fqdnFor)->contains('_')) { - $fqdnFor = str($fqdnFor)->before('_'); - } - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - $resource->environment_variables()->firstOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, - ]); } elseif ($command->value() === 'URL') { - if ($isApplication && $resource->build_pack === 'dockercompose') { - continue; + if ($isOneClick) { + $fqdnFor = $key->after('SERVICE_URL_')->lower()->value(); + if (str($fqdnFor)->contains('_')) { + $fqdnFor = str($fqdnFor)->before('_'); + } + $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); + $fqdn = str($fqdn)->replace('http://', '')->replace('https://', ''); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); } - // For services, only generate URL if explicit FQDN is set - if ($isService && blank($savedService->fqdn)) { - continue; - } - $fqdnFor = $key->after('SERVICE_URL_')->lower()->value(); - if (str($fqdnFor)->contains('_')) { - $fqdnFor = str($fqdnFor)->before('_'); - } - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - $fqdn = str($fqdn)->replace('http://', '')->replace('https://', ''); - $resource->environment_variables()->firstOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, - ]); } else { $value = generateEnvValue($command, $resource); $resource->environment_variables()->firstOrCreate([ @@ -3279,12 +3288,6 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $applicationFound = ServiceApplication::where('name', $serviceName)->where('image', $image)->where('service_id', $resource->id)->first(); if ($applicationFound) { $savedService = $applicationFound; - // $savedService = ServiceDatabase::firstOrCreate([ - // 'name' => $applicationFound->name, - // 'image' => $applicationFound->image, - // 'service_id' => $applicationFound->service_id, - // ]); - // $applicationFound->delete(); } else { $savedService = ServiceDatabase::firstOrCreate([ 'name' => $serviceName, @@ -3550,7 +3553,6 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $normalEnvironments = $normalEnvironments->filter(function ($value, $key) { return ! str($value)->startsWith('SERVICE_'); }); - foreach ($normalEnvironments as $key => $value) { $key = str($key); $value = str($value); @@ -3669,6 +3671,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $fqdns = data_get($domains, "$serviceName.domain"); // Generate SERVICE_FQDN & SERVICE_URL for dockercompose if ($resource->build_pack === 'dockercompose') { + foreach ($domains as $forServiceName => $domain) { $parsedDomain = data_get($domain, 'domain'); if (filled($parsedDomain)) { @@ -3731,7 +3734,6 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int } else { $fqdns = collect(data_get($savedService, 'fqdns'))->filter(); } - $defaultLabels = defaultLabels( id: $resource->id, name: $containerName, @@ -3757,7 +3759,6 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $coolifyEnvironments->put('COOLIFY_FQDN', $urls->implode(',')); } add_coolify_default_environment_variables($resource, $coolifyEnvironments, $resource->environment_variables); - if ($environment->count() > 0) { $environment = $environment->filter(function ($value, $key) { return ! str($key)->startsWith('SERVICE_FQDN_'); From 1ddec358a55793bd12a2d4f99d6b866c756dbb37 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sat, 2 Aug 2025 15:45:21 +0200 Subject: [PATCH 17/51] feat(input): add autofocus attribute to input component for improved accessibility --- app/View/Components/Forms/Input.php | 1 + resources/views/components/forms/input.blade.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/View/Components/Forms/Input.php b/app/View/Components/Forms/Input.php index 7283ef20f..a7bd87949 100644 --- a/app/View/Components/Forms/Input.php +++ b/app/View/Components/Forms/Input.php @@ -25,6 +25,7 @@ class Input extends Component public string $autocomplete = 'off', public ?int $minlength = null, public ?int $maxlength = null, + public bool $autofocus = false, ) {} public function render(): View|Closure|string diff --git a/resources/views/components/forms/input.blade.php b/resources/views/components/forms/input.blade.php index 20e6485bf..799a5f110 100644 --- a/resources/views/components/forms/input.blade.php +++ b/resources/views/components/forms/input.blade.php @@ -32,7 +32,7 @@ wire:dirty.class="dark:focus:ring-warning dark:ring-warning" wire:loading.attr="disabled" type="{{ $type }}" @readonly($readonly) @disabled($disabled) id="{{ $id }}" name="{{ $name }}" placeholder="{{ $attributes->get('placeholder') }}" - aria-placeholder="{{ $attributes->get('placeholder') }}"> + aria-placeholder="{{ $attributes->get('placeholder') }}" @if ($autofocus) x-ref="autofocusInput" @endif>
@else @@ -45,7 +45,7 @@ max="{{ $attributes->get('max') }}" minlength="{{ $attributes->get('minlength') }}" maxlength="{{ $attributes->get('maxlength') }}" @if ($id !== 'null') id={{ $id }} @endif name="{{ $name }}" - placeholder="{{ $attributes->get('placeholder') }}"> + placeholder="{{ $attributes->get('placeholder') }}" @if ($autofocus) x-ref="autofocusInput" @endif> @endif @if (!$label && $helper) From a2c5f4b9d1f9afa68db054ad9f392533a9c29977 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sat, 2 Aug 2025 15:50:09 +0200 Subject: [PATCH 18/51] refactor(public-git-repository): enhance form structure and add autofocus to repository URL input --- .../new/public-git-repository.blade.php | 162 ++++++++++-------- 1 file changed, 86 insertions(+), 76 deletions(-) diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.php index ad48b6d4d..e07cfaaae 100644 --- a/resources/views/livewire/project/new/public-git-repository.blade.php +++ b/resources/views/livewire/project/new/public-git-repository.blade.php @@ -1,84 +1,94 @@ -
+

Create a new Application

Deploy any public Git repositories.
+ +
-
-
- - - Check repository - -
-
- For example application deployments, checkout Coolify - Examples. -
- @if ($branchFound) - @if ($rate_limit_remaining && $rate_limit_reset) -
-
Rate Limit
- -
- @endif -
-
- @if ($git_source === 'other') - - @else - - @endif - - - - - - - @if ($isStatic) - - @endif -
- @if ($build_pack === 'dockercompose') - - - Compose file location in your repository:{{ Str::start($base_directory . $docker_compose_location, '/') }} - @else - - @endif - @if ($show_is_static) - -
- -
- @endif - {{--
- -
--}} - {{-- @if ($build_pack === 'dockercompose' && isDev()) -
If you choose Docker Compose based deployments, you cannot - change it afterwards.
- - @endif --}} -
- - Continue - - @endif +
+ + + Check repository + +
+
+ For example application deployments, checkout Coolify + Examples.
+ + @if ($branchFound) + @if ($rate_limit_remaining && $rate_limit_reset) +
+
Rate Limit
+ +
+ @endif + + +
+
+
+ @if ($git_source === 'other') + + @else + + @endif + + + + + + + @if ($isStatic) + + @endif +
+ @if ($build_pack === 'dockercompose') +
+ + +
+ + Compose file location in your repository: +
+
+ @else + + @endif + @if ($show_is_static) + +
+ +
+ @endif + {{--
+ +
--}} + {{-- @if ($build_pack === 'dockercompose' && isDev()) +
If you choose Docker Compose based deployments, you cannot + change it afterwards.
+ + @endif --}} +
+ + Continue + +
+ @endif
From e2518e53d9d5842265b0dd95b9102af1680e41df Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 4 Aug 2025 10:21:15 +0200 Subject: [PATCH 19/51] refactor(public-git-repository): remove commented-out code for cleaner template --- .../livewire/project/new/public-git-repository.blade.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.php index e07cfaaae..ba9e37784 100644 --- a/resources/views/livewire/project/new/public-git-repository.blade.php +++ b/resources/views/livewire/project/new/public-git-repository.blade.php @@ -76,15 +76,6 @@ helper="If your application is a static site or the final build assets should be served as a static site, enable this." />
@endif - {{--
- -
--}} - {{-- @if ($build_pack === 'dockercompose' && isDev()) -
If you choose Docker Compose based deployments, you cannot - change it afterwards.
- - @endif --}}
Continue From e8892b3d29290b69b796a6f2bddeab84d323b392 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 4 Aug 2025 10:46:59 +0200 Subject: [PATCH 20/51] feat(core): finally fqdn is fqdn and url is url. haha --- app/Livewire/Project/Application/General.php | 18 +- .../Project/Application/PreviewsCompose.php | 2 +- app/Livewire/Project/CloneMe.php | 2 +- app/Livewire/Project/Resource/Create.php | 2 +- .../Project/Shared/ResourceOperations.php | 2 +- app/Models/Application.php | 18 +- app/Models/Service.php | 6 +- bootstrap/helpers/docker.php | 8 +- bootstrap/helpers/parsers.php | 235 +- bootstrap/helpers/shared.php | 1914 +++++++++-------- 10 files changed, 1159 insertions(+), 1048 deletions(-) diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index 2eadbaa0e..e7515b23f 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -227,7 +227,19 @@ class General extends Component return; } - $this->application->parse(); + + // Refresh parsedServiceDomains to reflect any changes in docker_compose_domains + $this->application->refresh(); + $this->parsedServiceDomains = $this->application->docker_compose_domains ? json_decode($this->application->docker_compose_domains, true) : []; + ray($this->parsedServiceDomains); + // Convert service names with dots to use underscores for HTML form binding + $sanitizedDomains = []; + foreach ($this->parsedServiceDomains as $serviceName => $domain) { + $sanitizedKey = str($serviceName)->slug('_')->toString(); + $sanitizedDomains[$sanitizedKey] = $domain; + } + $this->parsedServiceDomains = $sanitizedDomains; + $showToast && $this->dispatch('success', 'Docker compose file loaded.'); $this->dispatch('compose_loaded'); $this->dispatch('refreshStorages'); @@ -245,7 +257,7 @@ class General extends Component public function generateDomain(string $serviceName) { $uuid = new Cuid2; - $domain = generateFqdn($this->application->destination->server, $uuid); + $domain = generateUrl(server: $this->application->destination->server, random: $uuid); $sanitizedKey = str($serviceName)->slug('_')->toString(); $this->parsedServiceDomains[$sanitizedKey]['domain'] = $domain; @@ -315,7 +327,7 @@ class General extends Component { $server = data_get($this->application, 'destination.server'); if ($server) { - $fqdn = generateFqdn($server, $this->application->uuid); + $fqdn = generateFqdn(server: $server, random: $this->application->uuid, parserVersion: $this->application->compose_parsing_version); $this->application->fqdn = $fqdn; $this->application->save(); $this->resetDefaultLabels(); diff --git a/app/Livewire/Project/Application/PreviewsCompose.php b/app/Livewire/Project/Application/PreviewsCompose.php index 334d96cad..5938b2944 100644 --- a/app/Livewire/Project/Application/PreviewsCompose.php +++ b/app/Livewire/Project/Application/PreviewsCompose.php @@ -48,7 +48,7 @@ class PreviewsCompose extends Component $random = new Cuid2; // Generate a unique domain like main app services do - $generated_fqdn = generateFqdn($server, $random); + $generated_fqdn = generateFqdn(server: $server, random: $random, parserVersion: $this->preview->application->compose_parsing_version); $preview_fqdn = str_replace('{{random}}', $random, $template); $preview_fqdn = str_replace('{{domain}}', str($generated_fqdn)->after('://'), $preview_fqdn); diff --git a/app/Livewire/Project/CloneMe.php b/app/Livewire/Project/CloneMe.php index a5d80a11a..57f4a0c68 100644 --- a/app/Livewire/Project/CloneMe.php +++ b/app/Livewire/Project/CloneMe.php @@ -129,7 +129,7 @@ class CloneMe extends Component $uuid = (string) new Cuid2; $url = $application->fqdn; if ($this->server->proxyType() !== 'NONE' && $applicationSettings->is_container_label_readonly_enabled === true) { - $url = generateFqdn($this->server, $uuid); + $url = generateFqdn(server: $this->server, random: $uuid, parserVersion: $application->compose_parsing_version); } $newApplication = $application->replicate([ diff --git a/app/Livewire/Project/Resource/Create.php b/app/Livewire/Project/Resource/Create.php index d8e397e59..e7cff4f29 100644 --- a/app/Livewire/Project/Resource/Create.php +++ b/app/Livewire/Project/Resource/Create.php @@ -102,7 +102,7 @@ class Create extends Component } }); } - $service->parse(isNew: true, isOneClick: true); + $service->parse(isNew: true); return redirect()->route('project.service.configuration', [ 'service_uuid' => $service->uuid, diff --git a/app/Livewire/Project/Shared/ResourceOperations.php b/app/Livewire/Project/Shared/ResourceOperations.php index c8916bf19..853dbe57a 100644 --- a/app/Livewire/Project/Shared/ResourceOperations.php +++ b/app/Livewire/Project/Shared/ResourceOperations.php @@ -61,7 +61,7 @@ class ResourceOperations extends Component $url = $this->resource->fqdn; if ($server->proxyType() !== 'NONE' && $applicationSettings->is_container_label_readonly_enabled === true) { - $url = generateFqdn($server, $uuid); + $url = generateFqdn(server: $server, random: $uuid, parserVersion: $this->resource->compose_parsing_version); } $new_resource = $this->resource->replicate([ diff --git a/app/Models/Application.php b/app/Models/Application.php index ed97454d2..f74ed89d1 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -111,7 +111,7 @@ class Application extends BaseModel { use HasConfiguration, HasFactory, SoftDeletes; - private static $parserVersion = '4'; + private static $parserVersion = '5'; protected $guarded = []; @@ -1442,7 +1442,21 @@ class Application extends BaseModel $parsedServices = $this->parse(); if ($this->docker_compose_domains) { $json = collect(json_decode($this->docker_compose_domains)); - $names = collect(data_get($parsedServices, 'services'))->keys()->toArray(); + foreach ($json as $key => $value) { + if (str($key)->contains('-')) { + $key = str($key)->replace('-', '_'); + } + $json->put((string) $key, $value); + } + $services = collect(data_get($parsedServices, 'services', [])); + foreach ($services as $name => $service) { + if (str($name)->contains('-')) { + $replacedName = str($name)->replace('-', '_'); + $services->put((string) $replacedName, $service); + $services->forget((string) $name); + } + } + $names = collect($services)->keys()->toArray(); $jsonNames = $json->keys()->toArray(); $diff = array_diff($jsonNames, $names); $json = $json->filter(function ($value, $key) use ($diff) { diff --git a/app/Models/Service.php b/app/Models/Service.php index 4bef46642..ed3241f46 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -42,7 +42,7 @@ class Service extends BaseModel { use HasFactory, SoftDeletes; - private static $parserVersion = '4'; + private static $parserVersion = '5'; protected $guarded = []; @@ -1274,10 +1274,10 @@ class Service extends BaseModel instant_remote_process($commands, $this->server); } - public function parse(bool $isNew = false, bool $isOneClick = false): Collection + public function parse(bool $isNew = false): Collection { if ((int) $this->compose_parsing_version >= 3) { - return serviceParser($this, isOneClick: $isOneClick); + return serviceParser($this); } elseif ($this->docker_compose_raw) { return parseDockerComposeFile($this, $isNew); } else { diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 739f98f22..1737ca714 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -256,12 +256,12 @@ function generateServiceSpecificFqdns(ServiceApplication|Application $resource) if (str($MINIO_BROWSER_REDIRECT_URL->value ?? '')->isEmpty()) { $MINIO_BROWSER_REDIRECT_URL->update([ - 'value' => generateFqdn($server, 'console-'.$uuid, true), + 'value' => generateFqdn(server: $server, random: 'console-'.$uuid, parserVersion: $resource->compose_parsing_version, forceHttps: true), ]); } if (str($MINIO_SERVER_URL->value ?? '')->isEmpty()) { $MINIO_SERVER_URL->update([ - 'value' => generateFqdn($server, 'minio-'.$uuid, true), + 'value' => generateFqdn(server: $server, random: 'minio-'.$uuid, parserVersion: $resource->compose_parsing_version, forceHttps: true), ]); } $payload = collect([ @@ -279,12 +279,12 @@ function generateServiceSpecificFqdns(ServiceApplication|Application $resource) if (str($LOGTO_ENDPOINT->value ?? '')->isEmpty()) { $LOGTO_ENDPOINT->update([ - 'value' => generateFqdn($server, 'logto-'.$uuid), + 'value' => generateFqdn(server: $server, random: 'logto-'.$uuid, parserVersion: $resource->compose_parsing_version), ]); } if (str($LOGTO_ADMIN_ENDPOINT->value ?? '')->isEmpty()) { $LOGTO_ADMIN_ENDPOINT->update([ - 'value' => generateFqdn($server, 'logto-admin-'.$uuid), + 'value' => generateFqdn(server: $server, random: 'logto-admin-'.$uuid, parserVersion: $resource->compose_parsing_version), ]); } $payload = collect([ diff --git a/bootstrap/helpers/parsers.php b/bootstrap/helpers/parsers.php index 649de731d..e5e0cbe86 100644 --- a/bootstrap/helpers/parsers.php +++ b/bootstrap/helpers/parsers.php @@ -16,7 +16,7 @@ use Spatie\Url\Url; use Symfony\Component\Yaml\Yaml; use Visus\Cuid2\Cuid2; -function applicationParser(Application $resource, int $pull_request_id = 0, ?int $preview_id = null, bool $isOneClick = false): Collection +function applicationParser(Application $resource, int $pull_request_id = 0, ?int $preview_id = null): Collection { $uuid = data_get($resource, 'uuid'); $compose = data_get($resource, 'docker_compose_raw'); @@ -100,6 +100,7 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int } } // Get magic environments where we need to preset the FQDN + // for example SERVICE_FQDN_APP_3000 (without a value) if ($key->startsWith('SERVICE_FQDN_')) { // SERVICE_FQDN_APP or SERVICE_FQDN_APP_3000 if (substr_count(str($key)->value(), '_') === 3) { @@ -111,7 +112,7 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int } $fqdn = $resource->fqdn; if (blank($resource->fqdn)) { - $fqdn = generateFqdn($server, "$uuid"); + $fqdn = generateFqdn(server: $server, random: "$uuid", parserVersion: $resource->compose_parsing_version); } if ($value && get_class($value) === \Illuminate\Support\Stringable::class && $value->startsWith('/')) { @@ -160,44 +161,58 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int $allMagicEnvironments = $allMagicEnvironments->merge($magicEnvironments); if ($magicEnvironments->count() > 0) { + // Generate Coolify environment variables foreach ($magicEnvironments as $key => $value) { $key = str($key); $value = replaceVariables($value); $command = parseCommandFromMagicEnvVariable($key); if ($command->value() === 'FQDN') { - if ($isOneClick) { - $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); - if (str($fqdnFor)->contains('_')) { - $fqdnFor = str($fqdnFor)->before('_'); - } - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - $resource->environment_variables()->firstOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, + $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); + if (str($fqdnFor)->contains('-')) { + $fqdnFor = str($fqdnFor)->replace('-', '_'); + } + $fqdn = generateFqdn(server: $server, random: "$fqdnFor-$uuid", parserVersion: $resource->compose_parsing_version); + $url = generateUrl(server: $server, random: "$fqdnFor-$uuid"); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); + if ($resource->build_pack === 'dockercompose') { + $domains = collect(json_decode(data_get($resource, 'docker_compose_domains'))) ?? collect([]); + // Put URL in the domains array instead of FQDN + $domains->put((string) $fqdnFor, [ + 'domain' => $url, ]); + $resource->docker_compose_domains = $domains->toJson(); + $resource->save(); } } elseif ($command->value() === 'URL') { - if ($isOneClick) { - $fqdnFor = $key->after('SERVICE_URL_')->lower()->value(); - if (str($fqdnFor)->contains('_')) { - $fqdnFor = str($fqdnFor)->before('_'); - } - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - $fqdn = str($fqdn)->replace('http://', '')->replace('https://', ''); - $resource->environment_variables()->firstOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, + $urlFor = $key->after('SERVICE_URL_')->lower()->value(); + if (str($urlFor)->contains('-')) { + $urlFor = str($urlFor)->replace('-', '_'); + } + $url = generateUrl(server: $server, random: "$urlFor-$uuid"); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $url, + 'is_build_time' => false, + 'is_preview' => false, + ]); + if ($resource->build_pack === 'dockercompose') { + $domains = collect(json_decode(data_get($resource, 'docker_compose_domains'))) ?? collect([]); + $domains->put((string) $urlFor, [ + 'domain' => $url, ]); + $resource->docker_compose_domains = $domains->toJson(); + $resource->save(); } } else { $value = generateEnvValue($command, $resource); @@ -599,7 +614,6 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int } else { $domains = collect(json_decode($resource->docker_compose_domains)) ?? collect([]); } - ray($domains); $fqdns = data_get($domains, "$serviceName.domain"); // Generate SERVICE_FQDN & SERVICE_URL for dockercompose if ($resource->build_pack === 'dockercompose') { @@ -849,7 +863,7 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int return $topLevel; } -function serviceParser(Service $resource, bool $isOneClick = false): Collection +function serviceParser(Service $resource): Collection { $uuid = data_get($resource, 'uuid'); $compose = data_get($resource, 'docker_compose_raw'); @@ -977,49 +991,86 @@ function serviceParser(Service $resource, bool $isOneClick = false): Collection } } // Get magic environments where we need to preset the FQDN - if ($key->startsWith('SERVICE_FQDN_')) { + if ($key->startsWith('SERVICE_FQDN_') || $key->startsWith('SERVICE_URL_')) { // SERVICE_FQDN_APP or SERVICE_FQDN_APP_3000 if (substr_count(str($key)->value(), '_') === 3) { - $fqdnFor = $key->after('SERVICE_FQDN_')->beforeLast('_')->lower()->value(); + if ($key->startsWith('SERVICE_FQDN_')) { + $urlFor = null; + $fqdnFor = $key->after('SERVICE_FQDN_')->beforeLast('_')->lower()->value(); + } + if ($key->startsWith('SERVICE_URL_')) { + $fqdnFor = null; + $urlFor = $key->after('SERVICE_URL_')->beforeLast('_')->lower()->value(); + } $port = $key->afterLast('_')->value(); } else { - $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); + if ($key->startsWith('SERVICE_FQDN_')) { + $urlFor = null; + $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); + } + if ($key->startsWith('SERVICE_URL_')) { + $fqdnFor = null; + $urlFor = $key->after('SERVICE_URL_')->lower()->value(); + } $port = null; } - if ($isOneClick) { - if (blank($savedService->fqdn)) { - if ($fqdnFor) { - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - } else { - $fqdn = generateFqdn($server, "{$savedService->name}-$uuid"); - } + // if ($isOneClick) { + if (blank($savedService->fqdn)) { + if ($fqdnFor) { + $fqdn = generateFqdn(server: $server, random: "$fqdnFor-$uuid", parserVersion: $resource->compose_parsing_version); } else { - $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); + $fqdn = generateFqdn(server: $server, random: "{$savedService->name}-$uuid", parserVersion: $resource->compose_parsing_version); + } + if ($urlFor) { + $url = generateUrl($server, "$urlFor-$uuid"); + } else { + $url = generateUrl($server, "{$savedService->name}-$uuid"); } - } else { - // For services which are not one-click, if no explicit FQDN is set, leave SERVICE_FQDN_ variables empty - if (blank($savedService->fqdn)) { - $fqdn = ''; - } else { - $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); - } + $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); + $url = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); } + + // } else { + // // For services which are not one-click, if no explicit FQDN is set, leave SERVICE_FQDN_ variables empty + // if (blank($savedService->fqdn)) { + // $fqdn = ''; + // } else { + // $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); + // } + // } if ($value && get_class($value) === \Illuminate\Support\Stringable::class && $value->startsWith('/')) { $path = $value->value(); if ($path !== '/') { $fqdn = "$fqdn$path"; + $url = "$url$path"; } } $fqdnWithPort = $fqdn; - if ($port) { + $urlWithPort = $url; + if ($fqdn && $port) { $fqdnWithPort = "$fqdn:$port"; } + if ($url && $port) { + $urlWithPort = "$url:$port"; + } + ray("urlWithPort: $urlWithPort, fqdnWithPort: $fqdnWithPort", "parserVersion: $resource->compose_parsing_version", 'isVersionGreaterThan4207: '.version_compare('4.0.0-beta.420.7', config('constants.coolify.version'), '>=')); if (is_null($savedService->fqdn)) { - $savedService->fqdn = $fqdnWithPort; + if ((int) $resource->compose_parsing_version >= 5 && version_compare(config('constants.coolify.version'), '4.0.0-beta.420.7', '>=')) { + if ($fqdnFor) { + ray("setting fqdn(fqdnWithPort) to $fqdnWithPort"); + $savedService->fqdn = $fqdnWithPort; + } + if ($urlFor) { + ray("setting fqdn(urlWithPort) to $urlWithPort"); + $savedService->fqdn = $urlWithPort; + } + } else { + ray("setting fqdn(fqdnWithPort) old parser version to $fqdnWithPort"); + $savedService->fqdn = $fqdnWithPort; + } $savedService->save(); } - if (substr_count(str($key)->value(), '_') === 2) { $resource->environment_variables()->updateOrCreate([ 'key' => $key->value(), @@ -1030,6 +1081,15 @@ function serviceParser(Service $resource, bool $isOneClick = false): Collection 'is_build_time' => false, 'is_preview' => false, ]); + $resource->environment_variables()->updateOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $url, + 'is_build_time' => false, + 'is_preview' => false, + ]); } if (substr_count(str($key)->value(), '_') === 3) { $newKey = str($key)->beforeLast('_'); @@ -1042,6 +1102,15 @@ function serviceParser(Service $resource, bool $isOneClick = false): Collection 'is_build_time' => false, 'is_preview' => false, ]); + $resource->environment_variables()->updateOrCreate([ + 'key' => $newKey->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $url, + 'is_build_time' => false, + 'is_preview' => false, + ]); } } } @@ -1053,40 +1122,36 @@ function serviceParser(Service $resource, bool $isOneClick = false): Collection $value = replaceVariables($value); $command = parseCommandFromMagicEnvVariable($key); if ($command->value() === 'FQDN') { - if ($isOneClick) { - $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); - if (str($fqdnFor)->contains('_')) { - $fqdnFor = str($fqdnFor)->before('_'); - } - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - $resource->environment_variables()->firstOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, - ]); + $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); + if (str($fqdnFor)->contains('_')) { + $fqdnFor = str($fqdnFor)->before('_'); } + $fqdn = generateFqdn(server: $server, random: "$fqdnFor-$uuid", parserVersion: $resource->compose_parsing_version); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); } elseif ($command->value() === 'URL') { - if ($isOneClick) { - $fqdnFor = $key->after('SERVICE_URL_')->lower()->value(); - if (str($fqdnFor)->contains('_')) { - $fqdnFor = str($fqdnFor)->before('_'); - } - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - $fqdn = str($fqdn)->replace('http://', '')->replace('https://', ''); - $resource->environment_variables()->firstOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, - ]); + $fqdnFor = $key->after('SERVICE_URL_')->lower()->value(); + if (str($fqdnFor)->contains('_')) { + $fqdnFor = str($fqdnFor)->before('_'); } + $fqdn = generateFqdn(server: $server, random: "$fqdnFor-$uuid", parserVersion: $resource->compose_parsing_version); + $fqdn = str($fqdn)->replace('http://', '')->replace('https://', ''); + $resource->environment_variables()->firstOrCreate([ + 'key' => $key->value(), + 'resourceable_type' => get_class($resource), + 'resourceable_id' => $resource->id, + ], [ + 'value' => $fqdn, + 'is_build_time' => false, + 'is_preview' => false, + ]); } else { $value = generateEnvValue($command, $resource); $resource->environment_variables()->firstOrCreate([ diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 1e9b95288..624e0b0d1 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -402,7 +402,7 @@ function data_get_str($data, $key, $default = null): Stringable return str($str); } -function generateFqdn(Server $server, string $random, bool $forceHttps = false): string +function generateUrl(Server $server, string $random, bool $forceHttps = false): string { $wildcard = data_get($server, 'settings.wildcard_domain'); if (is_null($wildcard) || $wildcard === '') { @@ -418,6 +418,26 @@ function generateFqdn(Server $server, string $random, bool $forceHttps = false): return "$scheme://{$random}.$host$path"; } +function generateFqdn(Server $server, string $random, bool $forceHttps = false, int $parserVersion = 4): string +{ + $wildcard = data_get($server, 'settings.wildcard_domain'); + if (is_null($wildcard) || $wildcard === '') { + $wildcard = sslip($server); + } + $url = Url::fromString($wildcard); + $host = $url->getHost(); + $path = $url->getPath() === '/' ? '' : $url->getPath(); + $scheme = $url->getScheme(); + if ($forceHttps) { + $scheme = 'https'; + } + + if ($parserVersion >= 5 && version_compare(config('constants.coolify.version'), '4.0.0-beta.420.7', '>=')) { + return "{$random}.$host$path"; + } + + return "$scheme://{$random}.$host$path"; +} function sslip(Server $server) { if (isDev() && $server->id === 0) { @@ -2918,1008 +2938,1008 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal } } -function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $preview_id = null, bool $isOneClick = false): Collection -{ - $isApplication = $resource instanceof Application; - $isService = $resource instanceof Service; - if ($isApplication) { - return applicationParser($resource, $pull_request_id, $preview_id); - } - if ($isService) { - return serviceParser($resource, $isOneClick); - } +// function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $preview_id = null): Collection +// { +// $isApplication = $resource instanceof Application; +// $isService = $resource instanceof Service; +// if ($isApplication) { +// return applicationParser($resource, $pull_request_id, $preview_id); +// } +// if ($isService) { +// return serviceParser($resource); +// } - return collect([]); +// return collect([]); - $uuid = data_get($resource, 'uuid'); - $compose = data_get($resource, 'docker_compose_raw'); - if (! $compose) { - return collect([]); - } +// $uuid = data_get($resource, 'uuid'); +// $compose = data_get($resource, 'docker_compose_raw'); +// if (! $compose) { +// return collect([]); +// } - if ($isApplication) { - $pullRequestId = $pull_request_id; - $isPullRequest = $pullRequestId == 0 ? false : true; - $server = data_get($resource, 'destination.server'); - $fileStorages = $resource->fileStorages(); - } elseif ($isService) { - $server = data_get($resource, 'server'); - $allServices = get_service_templates(); - } else { - return collect([]); - } +// if ($isApplication) { +// $pullRequestId = $pull_request_id; +// $isPullRequest = $pullRequestId == 0 ? false : true; +// $server = data_get($resource, 'destination.server'); +// $fileStorages = $resource->fileStorages(); +// } elseif ($isService) { +// $server = data_get($resource, 'server'); +// $allServices = get_service_templates(); +// } else { +// return collect([]); +// } - try { - $yaml = Yaml::parse($compose); - } catch (\Exception) { - return collect([]); - } - $services = data_get($yaml, 'services', collect([])); - $topLevel = collect([ - 'volumes' => collect(data_get($yaml, 'volumes', [])), - 'networks' => collect(data_get($yaml, 'networks', [])), - 'configs' => collect(data_get($yaml, 'configs', [])), - 'secrets' => collect(data_get($yaml, 'secrets', [])), - ]); - // If there are predefined volumes, make sure they are not null - if ($topLevel->get('volumes')->count() > 0) { - $temp = collect([]); - foreach ($topLevel['volumes'] as $volumeName => $volume) { - if (is_null($volume)) { - continue; - } - $temp->put($volumeName, $volume); - } - $topLevel['volumes'] = $temp; - } - // Get the base docker network - $baseNetwork = collect([$uuid]); - if ($isApplication && $isPullRequest) { - $baseNetwork = collect(["{$uuid}-{$pullRequestId}"]); - } +// try { +// $yaml = Yaml::parse($compose); +// } catch (\Exception) { +// return collect([]); +// } +// $services = data_get($yaml, 'services', collect([])); +// $topLevel = collect([ +// 'volumes' => collect(data_get($yaml, 'volumes', [])), +// 'networks' => collect(data_get($yaml, 'networks', [])), +// 'configs' => collect(data_get($yaml, 'configs', [])), +// 'secrets' => collect(data_get($yaml, 'secrets', [])), +// ]); +// // If there are predefined volumes, make sure they are not null +// if ($topLevel->get('volumes')->count() > 0) { +// $temp = collect([]); +// foreach ($topLevel['volumes'] as $volumeName => $volume) { +// if (is_null($volume)) { +// continue; +// } +// $temp->put($volumeName, $volume); +// } +// $topLevel['volumes'] = $temp; +// } +// // Get the base docker network +// $baseNetwork = collect([$uuid]); +// if ($isApplication && $isPullRequest) { +// $baseNetwork = collect(["{$uuid}-{$pullRequestId}"]); +// } - $parsedServices = collect([]); +// $parsedServices = collect([]); - $allMagicEnvironments = collect([]); - foreach ($services as $serviceName => $service) { - $predefinedPort = null; - $magicEnvironments = collect([]); - $image = data_get_str($service, 'image'); - $environment = collect(data_get($service, 'environment', [])); - $buildArgs = collect(data_get($service, 'build.args', [])); - $environment = $environment->merge($buildArgs); - $isDatabase = isDatabaseImage($image, $service); +// $allMagicEnvironments = collect([]); +// foreach ($services as $serviceName => $service) { +// $predefinedPort = null; +// $magicEnvironments = collect([]); +// $image = data_get_str($service, 'image'); +// $environment = collect(data_get($service, 'environment', [])); +// $buildArgs = collect(data_get($service, 'build.args', [])); +// $environment = $environment->merge($buildArgs); +// $isDatabase = isDatabaseImage($image, $service); - if ($isService) { - $containerName = "$serviceName-{$resource->uuid}"; +// if ($isService) { +// $containerName = "$serviceName-{$resource->uuid}"; - if ($serviceName === 'registry') { - $tempServiceName = 'docker-registry'; - } else { - $tempServiceName = $serviceName; - } - if (str(data_get($service, 'image'))->contains('glitchtip')) { - $tempServiceName = 'glitchtip'; - } - if ($serviceName === 'supabase-kong') { - $tempServiceName = 'supabase'; - } - $serviceDefinition = data_get($allServices, $tempServiceName); - $predefinedPort = data_get($serviceDefinition, 'port'); - if ($serviceName === 'plausible') { - $predefinedPort = '8000'; - } - if ($isDatabase) { - $applicationFound = ServiceApplication::where('name', $serviceName)->where('service_id', $resource->id)->first(); - if ($applicationFound) { - $savedService = $applicationFound; - } else { - $savedService = ServiceDatabase::firstOrCreate([ - 'name' => $serviceName, - 'service_id' => $resource->id, - ]); - } - } else { - $savedService = ServiceApplication::firstOrCreate([ - 'name' => $serviceName, - 'service_id' => $resource->id, - ], [ - 'is_gzip_enabled' => true, - ]); - } - // Check if image changed - if ($savedService->image !== $image) { - $savedService->image = $image; - $savedService->save(); - } - // Pocketbase does not need gzip for SSE. - if (str($savedService->image)->contains('pocketbase') && $savedService->is_gzip_enabled) { - $savedService->is_gzip_enabled = false; - $savedService->save(); - } - } +// if ($serviceName === 'registry') { +// $tempServiceName = 'docker-registry'; +// } else { +// $tempServiceName = $serviceName; +// } +// if (str(data_get($service, 'image'))->contains('glitchtip')) { +// $tempServiceName = 'glitchtip'; +// } +// if ($serviceName === 'supabase-kong') { +// $tempServiceName = 'supabase'; +// } +// $serviceDefinition = data_get($allServices, $tempServiceName); +// $predefinedPort = data_get($serviceDefinition, 'port'); +// if ($serviceName === 'plausible') { +// $predefinedPort = '8000'; +// } +// if ($isDatabase) { +// $applicationFound = ServiceApplication::where('name', $serviceName)->where('service_id', $resource->id)->first(); +// if ($applicationFound) { +// $savedService = $applicationFound; +// } else { +// $savedService = ServiceDatabase::firstOrCreate([ +// 'name' => $serviceName, +// 'service_id' => $resource->id, +// ]); +// } +// } else { +// $savedService = ServiceApplication::firstOrCreate([ +// 'name' => $serviceName, +// 'service_id' => $resource->id, +// ], [ +// 'is_gzip_enabled' => true, +// ]); +// } +// // Check if image changed +// if ($savedService->image !== $image) { +// $savedService->image = $image; +// $savedService->save(); +// } +// // Pocketbase does not need gzip for SSE. +// if (str($savedService->image)->contains('pocketbase') && $savedService->is_gzip_enabled) { +// $savedService->is_gzip_enabled = false; +// $savedService->save(); +// } +// } - $environment = collect(data_get($service, 'environment', [])); - $buildArgs = collect(data_get($service, 'build.args', [])); - $environment = $environment->merge($buildArgs); +// $environment = collect(data_get($service, 'environment', [])); +// $buildArgs = collect(data_get($service, 'build.args', [])); +// $environment = $environment->merge($buildArgs); - // convert environment variables to one format - $environment = convertToKeyValueCollection($environment); +// // convert environment variables to one format +// $environment = convertToKeyValueCollection($environment); - // Add Coolify defined environments - $allEnvironments = $resource->environment_variables()->get(['key', 'value']); +// // Add Coolify defined environments +// $allEnvironments = $resource->environment_variables()->get(['key', 'value']); - $allEnvironments = $allEnvironments->mapWithKeys(function ($item) { - return [$item['key'] => $item['value']]; - }); - // filter and add magic environments - foreach ($environment as $key => $value) { - // Get all SERVICE_ variables from keys and values - $key = str($key); - $value = str($value); - $regex = '/\$(\{?([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)\}?)/'; - preg_match_all($regex, $value, $valueMatches); - if (count($valueMatches[1]) > 0) { - foreach ($valueMatches[1] as $match) { - $match = replaceVariables($match); - if ($match->startsWith('SERVICE_')) { - if ($magicEnvironments->has($match->value())) { - continue; - } - $magicEnvironments->put($match->value(), ''); - } - } - } - // Get magic environments where we need to preset the FQDN - if ($key->startsWith('SERVICE_FQDN_')) { - // SERVICE_FQDN_APP or SERVICE_FQDN_APP_3000 - if (substr_count(str($key)->value(), '_') === 3) { - $fqdnFor = $key->after('SERVICE_FQDN_')->beforeLast('_')->lower()->value(); - $port = $key->afterLast('_')->value(); - } else { - $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); - $port = null; - } - if ($isApplication) { - $fqdn = $resource->fqdn; - if (blank($resource->fqdn)) { - $fqdn = generateFqdn($server, "$uuid"); - } - } elseif ($isService) { - if ($isOneClick) { - if (blank($savedService->fqdn)) { - if ($fqdnFor) { - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - } else { - $fqdn = generateFqdn($server, "{$savedService->name}-$uuid"); - } - } else { - $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); - } +// $allEnvironments = $allEnvironments->mapWithKeys(function ($item) { +// return [$item['key'] => $item['value']]; +// }); +// // filter and add magic environments +// foreach ($environment as $key => $value) { +// // Get all SERVICE_ variables from keys and values +// $key = str($key); +// $value = str($value); +// $regex = '/\$(\{?([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)\}?)/'; +// preg_match_all($regex, $value, $valueMatches); +// if (count($valueMatches[1]) > 0) { +// foreach ($valueMatches[1] as $match) { +// $match = replaceVariables($match); +// if ($match->startsWith('SERVICE_')) { +// if ($magicEnvironments->has($match->value())) { +// continue; +// } +// $magicEnvironments->put($match->value(), ''); +// } +// } +// } +// // Get magic environments where we need to preset the FQDN +// if ($key->startsWith('SERVICE_FQDN_')) { +// // SERVICE_FQDN_APP or SERVICE_FQDN_APP_3000 +// if (substr_count(str($key)->value(), '_') === 3) { +// $fqdnFor = $key->after('SERVICE_FQDN_')->beforeLast('_')->lower()->value(); +// $port = $key->afterLast('_')->value(); +// } else { +// $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); +// $port = null; +// } +// if ($isApplication) { +// $fqdn = $resource->fqdn; +// if (blank($resource->fqdn)) { +// $fqdn = generateFqdn($server, "$uuid"); +// } +// } elseif ($isService) { +// if ($isOneClick) { +// if (blank($savedService->fqdn)) { +// if ($fqdnFor) { +// $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); +// } else { +// $fqdn = generateFqdn($server, "{$savedService->name}-$uuid"); +// } +// } else { +// $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); +// } - } else { - // For services which are not one-click, if no explicit FQDN is set, leave SERVICE_FQDN_ variables empty - if (blank($savedService->fqdn)) { - $fqdn = ''; - } else { - $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); - } - ray($fqdn); - } - } +// } else { +// // For services which are not one-click, if no explicit FQDN is set, leave SERVICE_FQDN_ variables empty +// if (blank($savedService->fqdn)) { +// $fqdn = ''; +// } else { +// $fqdn = str($savedService->fqdn)->after('://')->before(':')->prepend(str($savedService->fqdn)->before('://')->append('://'))->value(); +// } +// ray($fqdn); +// } +// } - if ($value && get_class($value) === \Illuminate\Support\Stringable::class && $value->startsWith('/')) { - $path = $value->value(); - if ($path !== '/') { - $fqdn = "$fqdn$path"; - } - } - $fqdnWithPort = $fqdn; - if ($port) { - $fqdnWithPort = "$fqdn:$port"; - } - if ($isApplication && is_null($resource->fqdn)) { - data_forget($resource, 'environment_variables'); - data_forget($resource, 'environment_variables_preview'); - $resource->fqdn = $fqdnWithPort; - $resource->save(); - } elseif ($isService && is_null($savedService->fqdn)) { - $savedService->fqdn = $fqdnWithPort; - $savedService->save(); - } +// if ($value && get_class($value) === \Illuminate\Support\Stringable::class && $value->startsWith('/')) { +// $path = $value->value(); +// if ($path !== '/') { +// $fqdn = "$fqdn$path"; +// } +// } +// $fqdnWithPort = $fqdn; +// if ($port) { +// $fqdnWithPort = "$fqdn:$port"; +// } +// if ($isApplication && is_null($resource->fqdn)) { +// data_forget($resource, 'environment_variables'); +// data_forget($resource, 'environment_variables_preview'); +// $resource->fqdn = $fqdnWithPort; +// $resource->save(); +// } elseif ($isService && is_null($savedService->fqdn)) { +// $savedService->fqdn = $fqdnWithPort; +// $savedService->save(); +// } - if (substr_count(str($key)->value(), '_') === 2) { - $resource->environment_variables()->updateOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, - ]); - } - if (substr_count(str($key)->value(), '_') === 3) { - $newKey = str($key)->beforeLast('_'); - $resource->environment_variables()->updateOrCreate([ - 'key' => $newKey->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, - ]); - } - } - } +// if (substr_count(str($key)->value(), '_') === 2) { +// $resource->environment_variables()->updateOrCreate([ +// 'key' => $key->value(), +// 'resourceable_type' => get_class($resource), +// 'resourceable_id' => $resource->id, +// ], [ +// 'value' => $fqdn, +// 'is_build_time' => false, +// 'is_preview' => false, +// ]); +// } +// if (substr_count(str($key)->value(), '_') === 3) { +// $newKey = str($key)->beforeLast('_'); +// $resource->environment_variables()->updateOrCreate([ +// 'key' => $newKey->value(), +// 'resourceable_type' => get_class($resource), +// 'resourceable_id' => $resource->id, +// ], [ +// 'value' => $fqdn, +// 'is_build_time' => false, +// 'is_preview' => false, +// ]); +// } +// } +// } - $allMagicEnvironments = $allMagicEnvironments->merge($magicEnvironments); - if ($magicEnvironments->count() > 0) { - foreach ($magicEnvironments as $key => $value) { - $key = str($key); - $value = replaceVariables($value); - $command = parseCommandFromMagicEnvVariable($key); - if ($command->value() === 'FQDN') { - if ($isOneClick) { - $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); - if (str($fqdnFor)->contains('_')) { - $fqdnFor = str($fqdnFor)->before('_'); - } - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - $resource->environment_variables()->firstOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, - ]); - } - } elseif ($command->value() === 'URL') { - if ($isOneClick) { - $fqdnFor = $key->after('SERVICE_URL_')->lower()->value(); - if (str($fqdnFor)->contains('_')) { - $fqdnFor = str($fqdnFor)->before('_'); - } - $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); - $fqdn = str($fqdn)->replace('http://', '')->replace('https://', ''); - $resource->environment_variables()->firstOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $fqdn, - 'is_build_time' => false, - 'is_preview' => false, - ]); - } - } else { - $value = generateEnvValue($command, $resource); - $resource->environment_variables()->firstOrCreate([ - 'key' => $key->value(), - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $value, - 'is_build_time' => false, - 'is_preview' => false, - ]); - } - } - } - } +// $allMagicEnvironments = $allMagicEnvironments->merge($magicEnvironments); +// if ($magicEnvironments->count() > 0) { +// foreach ($magicEnvironments as $key => $value) { +// $key = str($key); +// $value = replaceVariables($value); +// $command = parseCommandFromMagicEnvVariable($key); +// if ($command->value() === 'FQDN') { +// if ($isOneClick) { +// $fqdnFor = $key->after('SERVICE_FQDN_')->lower()->value(); +// if (str($fqdnFor)->contains('_')) { +// $fqdnFor = str($fqdnFor)->before('_'); +// } +// $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); +// $resource->environment_variables()->firstOrCreate([ +// 'key' => $key->value(), +// 'resourceable_type' => get_class($resource), +// 'resourceable_id' => $resource->id, +// ], [ +// 'value' => $fqdn, +// 'is_build_time' => false, +// 'is_preview' => false, +// ]); +// } +// } elseif ($command->value() === 'URL') { +// if ($isOneClick) { +// $fqdnFor = $key->after('SERVICE_URL_')->lower()->value(); +// if (str($fqdnFor)->contains('_')) { +// $fqdnFor = str($fqdnFor)->before('_'); +// } +// $fqdn = generateFqdn($server, "$fqdnFor-$uuid"); +// $fqdn = str($fqdn)->replace('http://', '')->replace('https://', ''); +// $resource->environment_variables()->firstOrCreate([ +// 'key' => $key->value(), +// 'resourceable_type' => get_class($resource), +// 'resourceable_id' => $resource->id, +// ], [ +// 'value' => $fqdn, +// 'is_build_time' => false, +// 'is_preview' => false, +// ]); +// } +// } else { +// $value = generateEnvValue($command, $resource); +// $resource->environment_variables()->firstOrCreate([ +// 'key' => $key->value(), +// 'resourceable_type' => get_class($resource), +// 'resourceable_id' => $resource->id, +// ], [ +// 'value' => $value, +// 'is_build_time' => false, +// 'is_preview' => false, +// ]); +// } +// } +// } +// } - $serviceAppsLogDrainEnabledMap = collect([]); - if ($resource instanceof Service) { - $serviceAppsLogDrainEnabledMap = $resource->applications()->get()->keyBy('name')->map(function ($app) { - return $app->isLogDrainEnabled(); - }); - } +// $serviceAppsLogDrainEnabledMap = collect([]); +// if ($resource instanceof Service) { +// $serviceAppsLogDrainEnabledMap = $resource->applications()->get()->keyBy('name')->map(function ($app) { +// return $app->isLogDrainEnabled(); +// }); +// } - // Parse the rest of the services - foreach ($services as $serviceName => $service) { - $image = data_get_str($service, 'image'); - $restart = data_get_str($service, 'restart', RESTART_MODE); - $logging = data_get($service, 'logging'); +// // Parse the rest of the services +// foreach ($services as $serviceName => $service) { +// $image = data_get_str($service, 'image'); +// $restart = data_get_str($service, 'restart', RESTART_MODE); +// $logging = data_get($service, 'logging'); - if ($server->isLogDrainEnabled()) { - if ($resource instanceof Application && $resource->isLogDrainEnabled()) { - $logging = generate_fluentd_configuration(); - } - if ($resource instanceof Service && $serviceAppsLogDrainEnabledMap->get($serviceName)) { - $logging = generate_fluentd_configuration(); - } - } - $volumes = collect(data_get($service, 'volumes', [])); - $networks = collect(data_get($service, 'networks', [])); - $use_network_mode = data_get($service, 'network_mode') !== null; - $depends_on = collect(data_get($service, 'depends_on', [])); - $labels = collect(data_get($service, 'labels', [])); - if ($labels->count() > 0) { - if (isAssociativeArray($labels)) { - $newLabels = collect([]); - $labels->each(function ($value, $key) use ($newLabels) { - $newLabels->push("$key=$value"); - }); - $labels = $newLabels; - } - } - $environment = collect(data_get($service, 'environment', [])); - $ports = collect(data_get($service, 'ports', [])); - $buildArgs = collect(data_get($service, 'build.args', [])); - $environment = $environment->merge($buildArgs); +// if ($server->isLogDrainEnabled()) { +// if ($resource instanceof Application && $resource->isLogDrainEnabled()) { +// $logging = generate_fluentd_configuration(); +// } +// if ($resource instanceof Service && $serviceAppsLogDrainEnabledMap->get($serviceName)) { +// $logging = generate_fluentd_configuration(); +// } +// } +// $volumes = collect(data_get($service, 'volumes', [])); +// $networks = collect(data_get($service, 'networks', [])); +// $use_network_mode = data_get($service, 'network_mode') !== null; +// $depends_on = collect(data_get($service, 'depends_on', [])); +// $labels = collect(data_get($service, 'labels', [])); +// if ($labels->count() > 0) { +// if (isAssociativeArray($labels)) { +// $newLabels = collect([]); +// $labels->each(function ($value, $key) use ($newLabels) { +// $newLabels->push("$key=$value"); +// }); +// $labels = $newLabels; +// } +// } +// $environment = collect(data_get($service, 'environment', [])); +// $ports = collect(data_get($service, 'ports', [])); +// $buildArgs = collect(data_get($service, 'build.args', [])); +// $environment = $environment->merge($buildArgs); - $environment = convertToKeyValueCollection($environment); - $coolifyEnvironments = collect([]); +// $environment = convertToKeyValueCollection($environment); +// $coolifyEnvironments = collect([]); - $isDatabase = isDatabaseImage($image, $service); - $volumesParsed = collect([]); +// $isDatabase = isDatabaseImage($image, $service); +// $volumesParsed = collect([]); - if ($isApplication) { - $baseName = generateApplicationContainerName( - application: $resource, - pull_request_id: $pullRequestId - ); - $containerName = "$serviceName-$baseName"; - $predefinedPort = null; - } elseif ($isService) { - $containerName = "$serviceName-{$resource->uuid}"; +// if ($isApplication) { +// $baseName = generateApplicationContainerName( +// application: $resource, +// pull_request_id: $pullRequestId +// ); +// $containerName = "$serviceName-$baseName"; +// $predefinedPort = null; +// } elseif ($isService) { +// $containerName = "$serviceName-{$resource->uuid}"; - if ($serviceName === 'registry') { - $tempServiceName = 'docker-registry'; - } else { - $tempServiceName = $serviceName; - } - if (str(data_get($service, 'image'))->contains('glitchtip')) { - $tempServiceName = 'glitchtip'; - } - if ($serviceName === 'supabase-kong') { - $tempServiceName = 'supabase'; - } - $serviceDefinition = data_get($allServices, $tempServiceName); - $predefinedPort = data_get($serviceDefinition, 'port'); - if ($serviceName === 'plausible') { - $predefinedPort = '8000'; - } +// if ($serviceName === 'registry') { +// $tempServiceName = 'docker-registry'; +// } else { +// $tempServiceName = $serviceName; +// } +// if (str(data_get($service, 'image'))->contains('glitchtip')) { +// $tempServiceName = 'glitchtip'; +// } +// if ($serviceName === 'supabase-kong') { +// $tempServiceName = 'supabase'; +// } +// $serviceDefinition = data_get($allServices, $tempServiceName); +// $predefinedPort = data_get($serviceDefinition, 'port'); +// if ($serviceName === 'plausible') { +// $predefinedPort = '8000'; +// } - if ($isDatabase) { - $applicationFound = ServiceApplication::where('name', $serviceName)->where('image', $image)->where('service_id', $resource->id)->first(); - if ($applicationFound) { - $savedService = $applicationFound; - } else { - $savedService = ServiceDatabase::firstOrCreate([ - 'name' => $serviceName, - 'image' => $image, - 'service_id' => $resource->id, - ]); - } - } else { - $savedService = ServiceApplication::firstOrCreate([ - 'name' => $serviceName, - 'image' => $image, - 'service_id' => $resource->id, - ]); - } - $fileStorages = $savedService->fileStorages(); - if ($savedService->image !== $image) { - $savedService->image = $image; - $savedService->save(); - } - } +// if ($isDatabase) { +// $applicationFound = ServiceApplication::where('name', $serviceName)->where('image', $image)->where('service_id', $resource->id)->first(); +// if ($applicationFound) { +// $savedService = $applicationFound; +// } else { +// $savedService = ServiceDatabase::firstOrCreate([ +// 'name' => $serviceName, +// 'image' => $image, +// 'service_id' => $resource->id, +// ]); +// } +// } else { +// $savedService = ServiceApplication::firstOrCreate([ +// 'name' => $serviceName, +// 'image' => $image, +// 'service_id' => $resource->id, +// ]); +// } +// $fileStorages = $savedService->fileStorages(); +// if ($savedService->image !== $image) { +// $savedService->image = $image; +// $savedService->save(); +// } +// } - $originalResource = $isApplication ? $resource : $savedService; +// $originalResource = $isApplication ? $resource : $savedService; - if ($volumes->count() > 0) { - foreach ($volumes as $index => $volume) { - $type = null; - $source = null; - $target = null; - $content = null; - $isDirectory = false; - if (is_string($volume)) { - $source = str($volume)->before(':'); - $target = str($volume)->after(':')->beforeLast(':'); - $foundConfig = $fileStorages->whereMountPath($target)->first(); - if (sourceIsLocal($source)) { - $type = str('bind'); - if ($foundConfig) { - $contentNotNull_temp = data_get($foundConfig, 'content'); - if ($contentNotNull_temp) { - $content = $contentNotNull_temp; - } - $isDirectory = data_get($foundConfig, 'is_directory'); - } else { - // By default, we cannot determine if the bind is a directory or not, so we set it to directory - $isDirectory = true; - } - } else { - $type = str('volume'); - } - } elseif (is_array($volume)) { - $type = data_get_str($volume, 'type'); - $source = data_get_str($volume, 'source'); - $target = data_get_str($volume, 'target'); - $content = data_get($volume, 'content'); - $isDirectory = (bool) data_get($volume, 'isDirectory', null) || (bool) data_get($volume, 'is_directory', null); +// if ($volumes->count() > 0) { +// foreach ($volumes as $index => $volume) { +// $type = null; +// $source = null; +// $target = null; +// $content = null; +// $isDirectory = false; +// if (is_string($volume)) { +// $source = str($volume)->before(':'); +// $target = str($volume)->after(':')->beforeLast(':'); +// $foundConfig = $fileStorages->whereMountPath($target)->first(); +// if (sourceIsLocal($source)) { +// $type = str('bind'); +// if ($foundConfig) { +// $contentNotNull_temp = data_get($foundConfig, 'content'); +// if ($contentNotNull_temp) { +// $content = $contentNotNull_temp; +// } +// $isDirectory = data_get($foundConfig, 'is_directory'); +// } else { +// // By default, we cannot determine if the bind is a directory or not, so we set it to directory +// $isDirectory = true; +// } +// } else { +// $type = str('volume'); +// } +// } elseif (is_array($volume)) { +// $type = data_get_str($volume, 'type'); +// $source = data_get_str($volume, 'source'); +// $target = data_get_str($volume, 'target'); +// $content = data_get($volume, 'content'); +// $isDirectory = (bool) data_get($volume, 'isDirectory', null) || (bool) data_get($volume, 'is_directory', null); - $foundConfig = $fileStorages->whereMountPath($target)->first(); - if ($foundConfig) { - $contentNotNull_temp = data_get($foundConfig, 'content'); - if ($contentNotNull_temp) { - $content = $contentNotNull_temp; - } - $isDirectory = data_get($foundConfig, 'is_directory'); - } else { - // if isDirectory is not set (or false) & content is also not set, we assume it is a directory - if ((is_null($isDirectory) || ! $isDirectory) && is_null($content)) { - $isDirectory = true; - } - } - } - if ($type->value() === 'bind') { - if ($source->value() === '/var/run/docker.sock') { - $volume = $source->value().':'.$target->value(); - } elseif ($source->value() === '/tmp' || $source->value() === '/tmp/') { - $volume = $source->value().':'.$target->value(); - } else { - if ((int) $resource->compose_parsing_version >= 4) { - if ($isApplication) { - $mainDirectory = str(base_configuration_dir().'/applications/'.$uuid); - } elseif ($isService) { - $mainDirectory = str(base_configuration_dir().'/services/'.$uuid); - } - } else { - $mainDirectory = str(base_configuration_dir().'/applications/'.$uuid); - } - $source = replaceLocalSource($source, $mainDirectory); - if ($isApplication && $isPullRequest) { - $source = $source."-pr-$pullRequestId"; - } - LocalFileVolume::updateOrCreate( - [ - 'mount_path' => $target, - 'resource_id' => $originalResource->id, - 'resource_type' => get_class($originalResource), - ], - [ - 'fs_path' => $source, - 'mount_path' => $target, - 'content' => $content, - 'is_directory' => $isDirectory, - 'resource_id' => $originalResource->id, - 'resource_type' => get_class($originalResource), - ] - ); - if (isDev()) { - if ((int) $resource->compose_parsing_version >= 4) { - if ($isApplication) { - $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/applications/'.$uuid); - } elseif ($isService) { - $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/services/'.$uuid); - } - } else { - $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/applications/'.$uuid); - } - } - $volume = "$source:$target"; - } - } elseif ($type->value() === 'volume') { - if ($topLevel->get('volumes')->has($source->value())) { - $temp = $topLevel->get('volumes')->get($source->value()); - if (data_get($temp, 'driver_opts.type') === 'cifs') { - continue; - } - if (data_get($temp, 'driver_opts.type') === 'nfs') { - continue; - } - } - $slugWithoutUuid = Str::slug($source, '-'); - $name = "{$uuid}_{$slugWithoutUuid}"; +// $foundConfig = $fileStorages->whereMountPath($target)->first(); +// if ($foundConfig) { +// $contentNotNull_temp = data_get($foundConfig, 'content'); +// if ($contentNotNull_temp) { +// $content = $contentNotNull_temp; +// } +// $isDirectory = data_get($foundConfig, 'is_directory'); +// } else { +// // if isDirectory is not set (or false) & content is also not set, we assume it is a directory +// if ((is_null($isDirectory) || ! $isDirectory) && is_null($content)) { +// $isDirectory = true; +// } +// } +// } +// if ($type->value() === 'bind') { +// if ($source->value() === '/var/run/docker.sock') { +// $volume = $source->value().':'.$target->value(); +// } elseif ($source->value() === '/tmp' || $source->value() === '/tmp/') { +// $volume = $source->value().':'.$target->value(); +// } else { +// if ((int) $resource->compose_parsing_version >= 4) { +// if ($isApplication) { +// $mainDirectory = str(base_configuration_dir().'/applications/'.$uuid); +// } elseif ($isService) { +// $mainDirectory = str(base_configuration_dir().'/services/'.$uuid); +// } +// } else { +// $mainDirectory = str(base_configuration_dir().'/applications/'.$uuid); +// } +// $source = replaceLocalSource($source, $mainDirectory); +// if ($isApplication && $isPullRequest) { +// $source = $source."-pr-$pullRequestId"; +// } +// LocalFileVolume::updateOrCreate( +// [ +// 'mount_path' => $target, +// 'resource_id' => $originalResource->id, +// 'resource_type' => get_class($originalResource), +// ], +// [ +// 'fs_path' => $source, +// 'mount_path' => $target, +// 'content' => $content, +// 'is_directory' => $isDirectory, +// 'resource_id' => $originalResource->id, +// 'resource_type' => get_class($originalResource), +// ] +// ); +// if (isDev()) { +// if ((int) $resource->compose_parsing_version >= 4) { +// if ($isApplication) { +// $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/applications/'.$uuid); +// } elseif ($isService) { +// $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/services/'.$uuid); +// } +// } else { +// $source = $source->replace($mainDirectory, '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/applications/'.$uuid); +// } +// } +// $volume = "$source:$target"; +// } +// } elseif ($type->value() === 'volume') { +// if ($topLevel->get('volumes')->has($source->value())) { +// $temp = $topLevel->get('volumes')->get($source->value()); +// if (data_get($temp, 'driver_opts.type') === 'cifs') { +// continue; +// } +// if (data_get($temp, 'driver_opts.type') === 'nfs') { +// continue; +// } +// } +// $slugWithoutUuid = Str::slug($source, '-'); +// $name = "{$uuid}_{$slugWithoutUuid}"; - if ($isApplication && $isPullRequest) { - $name = "{$name}-pr-$pullRequestId"; - } - if (is_string($volume)) { - $source = str($volume)->before(':'); - $target = str($volume)->after(':')->beforeLast(':'); - $source = $name; - $volume = "$source:$target"; - } elseif (is_array($volume)) { - data_set($volume, 'source', $name); - } - $topLevel->get('volumes')->put($name, [ - 'name' => $name, - ]); - LocalPersistentVolume::updateOrCreate( - [ - 'name' => $name, - 'resource_id' => $originalResource->id, - 'resource_type' => get_class($originalResource), - ], - [ - 'name' => $name, - 'mount_path' => $target, - 'resource_id' => $originalResource->id, - 'resource_type' => get_class($originalResource), - ] - ); - } - dispatch(new ServerFilesFromServerJob($originalResource)); - $volumesParsed->put($index, $volume); - } - } +// if ($isApplication && $isPullRequest) { +// $name = "{$name}-pr-$pullRequestId"; +// } +// if (is_string($volume)) { +// $source = str($volume)->before(':'); +// $target = str($volume)->after(':')->beforeLast(':'); +// $source = $name; +// $volume = "$source:$target"; +// } elseif (is_array($volume)) { +// data_set($volume, 'source', $name); +// } +// $topLevel->get('volumes')->put($name, [ +// 'name' => $name, +// ]); +// LocalPersistentVolume::updateOrCreate( +// [ +// 'name' => $name, +// 'resource_id' => $originalResource->id, +// 'resource_type' => get_class($originalResource), +// ], +// [ +// 'name' => $name, +// 'mount_path' => $target, +// 'resource_id' => $originalResource->id, +// 'resource_type' => get_class($originalResource), +// ] +// ); +// } +// dispatch(new ServerFilesFromServerJob($originalResource)); +// $volumesParsed->put($index, $volume); +// } +// } - if ($depends_on?->count() > 0) { - if ($isApplication && $isPullRequest) { - $newDependsOn = collect([]); - $depends_on->each(function ($dependency, $condition) use ($pullRequestId, $newDependsOn) { - if (is_numeric($condition)) { - $dependency = "$dependency-pr-$pullRequestId"; +// if ($depends_on?->count() > 0) { +// if ($isApplication && $isPullRequest) { +// $newDependsOn = collect([]); +// $depends_on->each(function ($dependency, $condition) use ($pullRequestId, $newDependsOn) { +// if (is_numeric($condition)) { +// $dependency = "$dependency-pr-$pullRequestId"; - $newDependsOn->put($condition, $dependency); - } else { - $condition = "$condition-pr-$pullRequestId"; - $newDependsOn->put($condition, $dependency); - } - }); - $depends_on = $newDependsOn; - } - } - if (! $use_network_mode) { - if ($topLevel->get('networks')?->count() > 0) { - foreach ($topLevel->get('networks') as $networkName => $network) { - if ($networkName === 'default') { - continue; - } - // ignore aliases - if ($network['aliases'] ?? false) { - continue; - } - $networkExists = $networks->contains(function ($value, $key) use ($networkName) { - return $value == $networkName || $key == $networkName; - }); - if (! $networkExists) { - $networks->put($networkName, null); - } - } - } - $baseNetworkExists = $networks->contains(function ($value, $_) use ($baseNetwork) { - return $value == $baseNetwork; - }); - if (! $baseNetworkExists) { - foreach ($baseNetwork as $network) { - $topLevel->get('networks')->put($network, [ - 'name' => $network, - 'external' => true, - ]); - } - } - } +// $newDependsOn->put($condition, $dependency); +// } else { +// $condition = "$condition-pr-$pullRequestId"; +// $newDependsOn->put($condition, $dependency); +// } +// }); +// $depends_on = $newDependsOn; +// } +// } +// if (! $use_network_mode) { +// if ($topLevel->get('networks')?->count() > 0) { +// foreach ($topLevel->get('networks') as $networkName => $network) { +// if ($networkName === 'default') { +// continue; +// } +// // ignore aliases +// if ($network['aliases'] ?? false) { +// continue; +// } +// $networkExists = $networks->contains(function ($value, $key) use ($networkName) { +// return $value == $networkName || $key == $networkName; +// }); +// if (! $networkExists) { +// $networks->put($networkName, null); +// } +// } +// } +// $baseNetworkExists = $networks->contains(function ($value, $_) use ($baseNetwork) { +// return $value == $baseNetwork; +// }); +// if (! $baseNetworkExists) { +// foreach ($baseNetwork as $network) { +// $topLevel->get('networks')->put($network, [ +// 'name' => $network, +// 'external' => true, +// ]); +// } +// } +// } - // Collect/create/update ports - $collectedPorts = collect([]); - if ($ports->count() > 0) { - foreach ($ports as $sport) { - if (is_string($sport) || is_numeric($sport)) { - $collectedPorts->push($sport); - } - if (is_array($sport)) { - $target = data_get($sport, 'target'); - $published = data_get($sport, 'published'); - $protocol = data_get($sport, 'protocol'); - $collectedPorts->push("$target:$published/$protocol"); - } - } - } - if ($isService) { - $originalResource->ports = $collectedPorts->implode(','); - $originalResource->save(); - } +// // Collect/create/update ports +// $collectedPorts = collect([]); +// if ($ports->count() > 0) { +// foreach ($ports as $sport) { +// if (is_string($sport) || is_numeric($sport)) { +// $collectedPorts->push($sport); +// } +// if (is_array($sport)) { +// $target = data_get($sport, 'target'); +// $published = data_get($sport, 'published'); +// $protocol = data_get($sport, 'protocol'); +// $collectedPorts->push("$target:$published/$protocol"); +// } +// } +// } +// if ($isService) { +// $originalResource->ports = $collectedPorts->implode(','); +// $originalResource->save(); +// } - $networks_temp = collect(); +// $networks_temp = collect(); - if (! $use_network_mode) { - foreach ($networks as $key => $network) { - if (gettype($network) === 'string') { - // networks: - // - appwrite - $networks_temp->put($network, null); - } elseif (gettype($network) === 'array') { - // networks: - // default: - // ipv4_address: 192.168.203.254 - $networks_temp->put($key, $network); - } - } - foreach ($baseNetwork as $key => $network) { - $networks_temp->put($network, null); - } +// if (! $use_network_mode) { +// foreach ($networks as $key => $network) { +// if (gettype($network) === 'string') { +// // networks: +// // - appwrite +// $networks_temp->put($network, null); +// } elseif (gettype($network) === 'array') { +// // networks: +// // default: +// // ipv4_address: 192.168.203.254 +// $networks_temp->put($key, $network); +// } +// } +// foreach ($baseNetwork as $key => $network) { +// $networks_temp->put($network, null); +// } - if ($isApplication) { - if (data_get($resource, 'settings.connect_to_docker_network')) { - $network = $resource->destination->network; - $networks_temp->put($network, null); - $topLevel->get('networks')->put($network, [ - 'name' => $network, - 'external' => true, - ]); - } - } - } +// if ($isApplication) { +// if (data_get($resource, 'settings.connect_to_docker_network')) { +// $network = $resource->destination->network; +// $networks_temp->put($network, null); +// $topLevel->get('networks')->put($network, [ +// 'name' => $network, +// 'external' => true, +// ]); +// } +// } +// } - $normalEnvironments = $environment->diffKeys($allMagicEnvironments); - $normalEnvironments = $normalEnvironments->filter(function ($value, $key) { - return ! str($value)->startsWith('SERVICE_'); - }); - foreach ($normalEnvironments as $key => $value) { - $key = str($key); - $value = str($value); - $originalValue = $value; - $parsedValue = replaceVariables($value); - if ($value->startsWith('$SERVICE_')) { - $resource->environment_variables()->firstOrCreate([ - 'key' => $key, - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $value, - 'is_build_time' => false, - 'is_preview' => false, - ]); +// $normalEnvironments = $environment->diffKeys($allMagicEnvironments); +// $normalEnvironments = $normalEnvironments->filter(function ($value, $key) { +// return ! str($value)->startsWith('SERVICE_'); +// }); +// foreach ($normalEnvironments as $key => $value) { +// $key = str($key); +// $value = str($value); +// $originalValue = $value; +// $parsedValue = replaceVariables($value); +// if ($value->startsWith('$SERVICE_')) { +// $resource->environment_variables()->firstOrCreate([ +// 'key' => $key, +// 'resourceable_type' => get_class($resource), +// 'resourceable_id' => $resource->id, +// ], [ +// 'value' => $value, +// 'is_build_time' => false, +// 'is_preview' => false, +// ]); - continue; - } - if (! $value->startsWith('$')) { - continue; - } - if ($key->value() === $parsedValue->value()) { - $value = null; - $resource->environment_variables()->firstOrCreate([ - 'key' => $key, - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $value, - 'is_build_time' => false, - 'is_preview' => false, - ]); - } else { - if ($value->startsWith('$')) { - $isRequired = false; - if ($value->contains(':-')) { - $value = replaceVariables($value); - $key = $value->before(':'); - $value = $value->after(':-'); - } elseif ($value->contains('-')) { - $value = replaceVariables($value); +// continue; +// } +// if (! $value->startsWith('$')) { +// continue; +// } +// if ($key->value() === $parsedValue->value()) { +// $value = null; +// $resource->environment_variables()->firstOrCreate([ +// 'key' => $key, +// 'resourceable_type' => get_class($resource), +// 'resourceable_id' => $resource->id, +// ], [ +// 'value' => $value, +// 'is_build_time' => false, +// 'is_preview' => false, +// ]); +// } else { +// if ($value->startsWith('$')) { +// $isRequired = false; +// if ($value->contains(':-')) { +// $value = replaceVariables($value); +// $key = $value->before(':'); +// $value = $value->after(':-'); +// } elseif ($value->contains('-')) { +// $value = replaceVariables($value); - $key = $value->before('-'); - $value = $value->after('-'); - } elseif ($value->contains(':?')) { - $value = replaceVariables($value); +// $key = $value->before('-'); +// $value = $value->after('-'); +// } elseif ($value->contains(':?')) { +// $value = replaceVariables($value); - $key = $value->before(':'); - $value = $value->after(':?'); - $isRequired = true; - } elseif ($value->contains('?')) { - $value = replaceVariables($value); +// $key = $value->before(':'); +// $value = $value->after(':?'); +// $isRequired = true; +// } elseif ($value->contains('?')) { +// $value = replaceVariables($value); - $key = $value->before('?'); - $value = $value->after('?'); - $isRequired = true; - } - if ($originalValue->value() === $value->value()) { - // This means the variable does not have a default value, so it needs to be created in Coolify - $parsedKeyValue = replaceVariables($value); - $resource->environment_variables()->firstOrCreate([ - 'key' => $parsedKeyValue, - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'is_build_time' => false, - 'is_preview' => false, - 'is_required' => $isRequired, - ]); - // Add the variable to the environment so it will be shown in the deployable compose file - // $environment[$parsedKeyValue->value()] = $resource->environment_variables()->where('key', $parsedKeyValue)->where('resourceable_type', get_class($resource))->where('resourceable_id', $resource->id)->first()->real_value; - $environment[$parsedKeyValue->value()] = $value; +// $key = $value->before('?'); +// $value = $value->after('?'); +// $isRequired = true; +// } +// if ($originalValue->value() === $value->value()) { +// // This means the variable does not have a default value, so it needs to be created in Coolify +// $parsedKeyValue = replaceVariables($value); +// $resource->environment_variables()->firstOrCreate([ +// 'key' => $parsedKeyValue, +// 'resourceable_type' => get_class($resource), +// 'resourceable_id' => $resource->id, +// ], [ +// 'is_build_time' => false, +// 'is_preview' => false, +// 'is_required' => $isRequired, +// ]); +// // Add the variable to the environment so it will be shown in the deployable compose file +// // $environment[$parsedKeyValue->value()] = $resource->environment_variables()->where('key', $parsedKeyValue)->where('resourceable_type', get_class($resource))->where('resourceable_id', $resource->id)->first()->real_value; +// $environment[$parsedKeyValue->value()] = $value; - continue; - } - $resource->environment_variables()->firstOrCreate([ - 'key' => $key, - 'resourceable_type' => get_class($resource), - 'resourceable_id' => $resource->id, - ], [ - 'value' => $value, - 'is_build_time' => false, - 'is_preview' => false, - 'is_required' => $isRequired, - ]); - } - } - } - if ($isApplication) { - $branch = $originalResource->git_branch; - if ($pullRequestId !== 0) { - $branch = "pull/{$pullRequestId}/head"; - } - if ($originalResource->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) { - $coolifyEnvironments->put('COOLIFY_BRANCH', "\"{$branch}\""); - } - } +// continue; +// } +// $resource->environment_variables()->firstOrCreate([ +// 'key' => $key, +// 'resourceable_type' => get_class($resource), +// 'resourceable_id' => $resource->id, +// ], [ +// 'value' => $value, +// 'is_build_time' => false, +// 'is_preview' => false, +// 'is_required' => $isRequired, +// ]); +// } +// } +// } +// if ($isApplication) { +// $branch = $originalResource->git_branch; +// if ($pullRequestId !== 0) { +// $branch = "pull/{$pullRequestId}/head"; +// } +// if ($originalResource->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) { +// $coolifyEnvironments->put('COOLIFY_BRANCH', "\"{$branch}\""); +// } +// } - // Add COOLIFY_RESOURCE_UUID to environment - if ($resource->environment_variables->where('key', 'COOLIFY_RESOURCE_UUID')->isEmpty()) { - $coolifyEnvironments->put('COOLIFY_RESOURCE_UUID', "{$resource->uuid}"); - } +// // Add COOLIFY_RESOURCE_UUID to environment +// if ($resource->environment_variables->where('key', 'COOLIFY_RESOURCE_UUID')->isEmpty()) { +// $coolifyEnvironments->put('COOLIFY_RESOURCE_UUID', "{$resource->uuid}"); +// } - // Add COOLIFY_CONTAINER_NAME to environment - if ($resource->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) { - $coolifyEnvironments->put('COOLIFY_CONTAINER_NAME', "{$containerName}"); - } +// // Add COOLIFY_CONTAINER_NAME to environment +// if ($resource->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) { +// $coolifyEnvironments->put('COOLIFY_CONTAINER_NAME', "{$containerName}"); +// } - if ($isApplication) { - if ($isPullRequest) { - $preview = $resource->previews()->find($preview_id); - $domains = collect(json_decode(data_get($preview, 'docker_compose_domains'))) ?? collect([]); - } else { - $domains = collect(json_decode($resource->docker_compose_domains)) ?? collect([]); - } - $fqdns = data_get($domains, "$serviceName.domain"); - // Generate SERVICE_FQDN & SERVICE_URL for dockercompose - if ($resource->build_pack === 'dockercompose') { +// if ($isApplication) { +// if ($isPullRequest) { +// $preview = $resource->previews()->find($preview_id); +// $domains = collect(json_decode(data_get($preview, 'docker_compose_domains'))) ?? collect([]); +// } else { +// $domains = collect(json_decode($resource->docker_compose_domains)) ?? collect([]); +// } +// $fqdns = data_get($domains, "$serviceName.domain"); +// // Generate SERVICE_FQDN & SERVICE_URL for dockercompose +// if ($resource->build_pack === 'dockercompose') { - foreach ($domains as $forServiceName => $domain) { - $parsedDomain = data_get($domain, 'domain'); - if (filled($parsedDomain)) { - $parsedDomain = str($parsedDomain)->explode(',')->first(); - $coolifyUrl = Url::fromString($parsedDomain); - $coolifyScheme = $coolifyUrl->getScheme(); - $coolifyFqdn = $coolifyUrl->getHost(); - $coolifyUrl = $coolifyUrl->withScheme($coolifyScheme)->withHost($coolifyFqdn)->withPort(null); - $coolifyEnvironments->put('SERVICE_URL_'.str($forServiceName)->upper()->replace('-', '_'), $coolifyUrl->__toString()); - $coolifyEnvironments->put('SERVICE_FQDN_'.str($forServiceName)->upper()->replace('-', '_'), $coolifyFqdn); - } - } - } - // If the domain is set, we need to generate the FQDNs for the preview - if (filled($fqdns)) { - $fqdns = str($fqdns)->explode(','); - if ($isPullRequest) { - $preview = $resource->previews()->find($preview_id); - $docker_compose_domains = collect(json_decode(data_get($preview, 'docker_compose_domains'))); - if ($docker_compose_domains->count() > 0) { - $found_fqdn = data_get($docker_compose_domains, "$serviceName.domain"); - if ($found_fqdn) { - $fqdns = collect($found_fqdn); - } else { - $fqdns = collect([]); - } - } else { - $fqdns = $fqdns->map(function ($fqdn) use ($pullRequestId, $resource) { - $preview = ApplicationPreview::findPreviewByApplicationAndPullId($resource->id, $pullRequestId); - $url = Url::fromString($fqdn); - $template = $resource->preview_url_template; - $host = $url->getHost(); - $schema = $url->getScheme(); - $random = new Cuid2; - $preview_fqdn = str_replace('{{random}}', $random, $template); - $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn); - $preview_fqdn = str_replace('{{pr_id}}', $pullRequestId, $preview_fqdn); - $preview_fqdn = "$schema://$preview_fqdn"; - $preview->fqdn = $preview_fqdn; - $preview->save(); +// foreach ($domains as $forServiceName => $domain) { +// $parsedDomain = data_get($domain, 'domain'); +// if (filled($parsedDomain)) { +// $parsedDomain = str($parsedDomain)->explode(',')->first(); +// $coolifyUrl = Url::fromString($parsedDomain); +// $coolifyScheme = $coolifyUrl->getScheme(); +// $coolifyFqdn = $coolifyUrl->getHost(); +// $coolifyUrl = $coolifyUrl->withScheme($coolifyScheme)->withHost($coolifyFqdn)->withPort(null); +// $coolifyEnvironments->put('SERVICE_URL_'.str($forServiceName)->upper()->replace('-', '_'), $coolifyUrl->__toString()); +// $coolifyEnvironments->put('SERVICE_FQDN_'.str($forServiceName)->upper()->replace('-', '_'), $coolifyFqdn); +// } +// } +// } +// // If the domain is set, we need to generate the FQDNs for the preview +// if (filled($fqdns)) { +// $fqdns = str($fqdns)->explode(','); +// if ($isPullRequest) { +// $preview = $resource->previews()->find($preview_id); +// $docker_compose_domains = collect(json_decode(data_get($preview, 'docker_compose_domains'))); +// if ($docker_compose_domains->count() > 0) { +// $found_fqdn = data_get($docker_compose_domains, "$serviceName.domain"); +// if ($found_fqdn) { +// $fqdns = collect($found_fqdn); +// } else { +// $fqdns = collect([]); +// } +// } else { +// $fqdns = $fqdns->map(function ($fqdn) use ($pullRequestId, $resource) { +// $preview = ApplicationPreview::findPreviewByApplicationAndPullId($resource->id, $pullRequestId); +// $url = Url::fromString($fqdn); +// $template = $resource->preview_url_template; +// $host = $url->getHost(); +// $schema = $url->getScheme(); +// $random = new Cuid2; +// $preview_fqdn = str_replace('{{random}}', $random, $template); +// $preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn); +// $preview_fqdn = str_replace('{{pr_id}}', $pullRequestId, $preview_fqdn); +// $preview_fqdn = "$schema://$preview_fqdn"; +// $preview->fqdn = $preview_fqdn; +// $preview->save(); - return $preview_fqdn; - }); - } - } - } - $defaultLabels = defaultLabels( - id: $resource->id, - name: $containerName, - projectName: $resource->project()->name, - resourceName: $resource->name, - pull_request_id: $pullRequestId, - type: 'application', - environment: $resource->environment->name, - ); +// return $preview_fqdn; +// }); +// } +// } +// } +// $defaultLabels = defaultLabels( +// id: $resource->id, +// name: $containerName, +// projectName: $resource->project()->name, +// resourceName: $resource->name, +// pull_request_id: $pullRequestId, +// type: 'application', +// environment: $resource->environment->name, +// ); - } elseif ($isService) { - if ($savedService->serviceType()) { - $fqdns = generateServiceSpecificFqdns($savedService); - } else { - $fqdns = collect(data_get($savedService, 'fqdns'))->filter(); - } - $defaultLabels = defaultLabels( - id: $resource->id, - name: $containerName, - projectName: $resource->project()->name, - resourceName: $resource->name, - type: 'service', - subType: $isDatabase ? 'database' : 'application', - subId: $savedService->id, - subName: $savedService->human_name ?? $savedService->name, - environment: $resource->environment->name, - ); - } - // Add COOLIFY_FQDN & COOLIFY_URL to environment - if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) { - $fqdnsWithoutPort = $fqdns->map(function ($fqdn) { - return str($fqdn)->after('://')->before(':')->prepend(str($fqdn)->before('://')->append('://')); - }); - $coolifyEnvironments->put('COOLIFY_URL', $fqdnsWithoutPort->implode(',')); +// } elseif ($isService) { +// if ($savedService->serviceType()) { +// $fqdns = generateServiceSpecificFqdns($savedService); +// } else { +// $fqdns = collect(data_get($savedService, 'fqdns'))->filter(); +// } +// $defaultLabels = defaultLabels( +// id: $resource->id, +// name: $containerName, +// projectName: $resource->project()->name, +// resourceName: $resource->name, +// type: 'service', +// subType: $isDatabase ? 'database' : 'application', +// subId: $savedService->id, +// subName: $savedService->human_name ?? $savedService->name, +// environment: $resource->environment->name, +// ); +// } +// // Add COOLIFY_FQDN & COOLIFY_URL to environment +// if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) { +// $fqdnsWithoutPort = $fqdns->map(function ($fqdn) { +// return str($fqdn)->after('://')->before(':')->prepend(str($fqdn)->before('://')->append('://')); +// }); +// $coolifyEnvironments->put('COOLIFY_URL', $fqdnsWithoutPort->implode(',')); - $urls = $fqdns->map(function ($fqdn) { - return str($fqdn)->replace('http://', '')->replace('https://', '')->before(':'); - }); - $coolifyEnvironments->put('COOLIFY_FQDN', $urls->implode(',')); - } - add_coolify_default_environment_variables($resource, $coolifyEnvironments, $resource->environment_variables); - if ($environment->count() > 0) { - $environment = $environment->filter(function ($value, $key) { - return ! str($key)->startsWith('SERVICE_FQDN_'); - })->map(function ($value, $key) use ($resource) { - // if value is empty, set it to null so if you set the environment variable in the .env file (Coolify's UI), it will used - if (str($value)->isEmpty()) { - if ($resource->environment_variables()->where('key', $key)->exists()) { - $value = $resource->environment_variables()->where('key', $key)->first()->value; - } else { - $value = null; - } - } +// $urls = $fqdns->map(function ($fqdn) { +// return str($fqdn)->replace('http://', '')->replace('https://', '')->before(':'); +// }); +// $coolifyEnvironments->put('COOLIFY_FQDN', $urls->implode(',')); +// } +// add_coolify_default_environment_variables($resource, $coolifyEnvironments, $resource->environment_variables); +// if ($environment->count() > 0) { +// $environment = $environment->filter(function ($value, $key) { +// return ! str($key)->startsWith('SERVICE_FQDN_'); +// })->map(function ($value, $key) use ($resource) { +// // if value is empty, set it to null so if you set the environment variable in the .env file (Coolify's UI), it will used +// if (str($value)->isEmpty()) { +// if ($resource->environment_variables()->where('key', $key)->exists()) { +// $value = $resource->environment_variables()->where('key', $key)->first()->value; +// } else { +// $value = null; +// } +// } - return $value; - }); - } - $serviceLabels = $labels->merge($defaultLabels); - if ($serviceLabels->count() > 0) { - if ($isApplication) { - $isContainerLabelEscapeEnabled = data_get($resource, 'settings.is_container_label_escape_enabled'); - } else { - $isContainerLabelEscapeEnabled = data_get($resource, 'is_container_label_escape_enabled'); - } - if ($isContainerLabelEscapeEnabled) { - $serviceLabels = $serviceLabels->map(function ($value, $key) { - return escapeDollarSign($value); - }); - } - } - if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) { - if ($isApplication) { - $shouldGenerateLabelsExactly = $resource->destination->server->settings->generate_exact_labels; - $uuid = $resource->uuid; - $network = data_get($resource, 'destination.network'); - if ($isPullRequest) { - $uuid = "{$resource->uuid}-{$pullRequestId}"; - } - if ($isPullRequest) { - $network = "{$resource->destination->network}-{$pullRequestId}"; - } - } else { - $shouldGenerateLabelsExactly = $resource->server->settings->generate_exact_labels; - $uuid = $resource->uuid; - $network = data_get($resource, 'destination.network'); - } - if ($shouldGenerateLabelsExactly) { - switch ($server->proxyType()) { - case ProxyTypes::TRAEFIK->value: - $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik( - uuid: $uuid, - domains: $fqdns, - is_force_https_enabled: true, - serviceLabels: $serviceLabels, - is_gzip_enabled: $originalResource->isGzipEnabled(), - is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), - service_name: $serviceName, - image: $image - )); - break; - case ProxyTypes::CADDY->value: - $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy( - network: $network, - uuid: $uuid, - domains: $fqdns, - is_force_https_enabled: true, - serviceLabels: $serviceLabels, - is_gzip_enabled: $originalResource->isGzipEnabled(), - is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), - service_name: $serviceName, - image: $image, - predefinedPort: $predefinedPort - )); - break; - } - } else { - $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik( - uuid: $uuid, - domains: $fqdns, - is_force_https_enabled: true, - serviceLabels: $serviceLabels, - is_gzip_enabled: $originalResource->isGzipEnabled(), - is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), - service_name: $serviceName, - image: $image - )); - $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy( - network: $network, - uuid: $uuid, - domains: $fqdns, - is_force_https_enabled: true, - serviceLabels: $serviceLabels, - is_gzip_enabled: $originalResource->isGzipEnabled(), - is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), - service_name: $serviceName, - image: $image, - predefinedPort: $predefinedPort - )); - } - } - if ($isService) { - if (data_get($service, 'restart') === 'no' || data_get($service, 'exclude_from_hc')) { - $savedService->update(['exclude_from_status' => true]); - } - } - data_forget($service, 'volumes.*.content'); - data_forget($service, 'volumes.*.isDirectory'); - data_forget($service, 'volumes.*.is_directory'); - data_forget($service, 'exclude_from_hc'); +// return $value; +// }); +// } +// $serviceLabels = $labels->merge($defaultLabels); +// if ($serviceLabels->count() > 0) { +// if ($isApplication) { +// $isContainerLabelEscapeEnabled = data_get($resource, 'settings.is_container_label_escape_enabled'); +// } else { +// $isContainerLabelEscapeEnabled = data_get($resource, 'is_container_label_escape_enabled'); +// } +// if ($isContainerLabelEscapeEnabled) { +// $serviceLabels = $serviceLabels->map(function ($value, $key) { +// return escapeDollarSign($value); +// }); +// } +// } +// if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) { +// if ($isApplication) { +// $shouldGenerateLabelsExactly = $resource->destination->server->settings->generate_exact_labels; +// $uuid = $resource->uuid; +// $network = data_get($resource, 'destination.network'); +// if ($isPullRequest) { +// $uuid = "{$resource->uuid}-{$pullRequestId}"; +// } +// if ($isPullRequest) { +// $network = "{$resource->destination->network}-{$pullRequestId}"; +// } +// } else { +// $shouldGenerateLabelsExactly = $resource->server->settings->generate_exact_labels; +// $uuid = $resource->uuid; +// $network = data_get($resource, 'destination.network'); +// } +// if ($shouldGenerateLabelsExactly) { +// switch ($server->proxyType()) { +// case ProxyTypes::TRAEFIK->value: +// $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik( +// uuid: $uuid, +// domains: $fqdns, +// is_force_https_enabled: true, +// serviceLabels: $serviceLabels, +// is_gzip_enabled: $originalResource->isGzipEnabled(), +// is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), +// service_name: $serviceName, +// image: $image +// )); +// break; +// case ProxyTypes::CADDY->value: +// $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy( +// network: $network, +// uuid: $uuid, +// domains: $fqdns, +// is_force_https_enabled: true, +// serviceLabels: $serviceLabels, +// is_gzip_enabled: $originalResource->isGzipEnabled(), +// is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), +// service_name: $serviceName, +// image: $image, +// predefinedPort: $predefinedPort +// )); +// break; +// } +// } else { +// $serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik( +// uuid: $uuid, +// domains: $fqdns, +// is_force_https_enabled: true, +// serviceLabels: $serviceLabels, +// is_gzip_enabled: $originalResource->isGzipEnabled(), +// is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), +// service_name: $serviceName, +// image: $image +// )); +// $serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy( +// network: $network, +// uuid: $uuid, +// domains: $fqdns, +// is_force_https_enabled: true, +// serviceLabels: $serviceLabels, +// is_gzip_enabled: $originalResource->isGzipEnabled(), +// is_stripprefix_enabled: $originalResource->isStripprefixEnabled(), +// service_name: $serviceName, +// image: $image, +// predefinedPort: $predefinedPort +// )); +// } +// } +// if ($isService) { +// if (data_get($service, 'restart') === 'no' || data_get($service, 'exclude_from_hc')) { +// $savedService->update(['exclude_from_status' => true]); +// } +// } +// data_forget($service, 'volumes.*.content'); +// data_forget($service, 'volumes.*.isDirectory'); +// data_forget($service, 'volumes.*.is_directory'); +// data_forget($service, 'exclude_from_hc'); - $volumesParsed = $volumesParsed->map(function ($volume) { - data_forget($volume, 'content'); - data_forget($volume, 'is_directory'); - data_forget($volume, 'isDirectory'); +// $volumesParsed = $volumesParsed->map(function ($volume) { +// data_forget($volume, 'content'); +// data_forget($volume, 'is_directory'); +// data_forget($volume, 'isDirectory'); - return $volume; - }); +// return $volume; +// }); - $payload = collect($service)->merge([ - 'container_name' => $containerName, - 'restart' => $restart->value(), - 'labels' => $serviceLabels, - ]); - if (! $use_network_mode) { - $payload['networks'] = $networks_temp; - } - if ($ports->count() > 0) { - $payload['ports'] = $ports; - } - if ($volumesParsed->count() > 0) { - $payload['volumes'] = $volumesParsed; - } - if ($environment->count() > 0 || $coolifyEnvironments->count() > 0) { - $payload['environment'] = $environment->merge($coolifyEnvironments); - } - if ($logging) { - $payload['logging'] = $logging; - } - if ($depends_on->count() > 0) { - $payload['depends_on'] = $depends_on; - } - if ($isApplication && $isPullRequest) { - $serviceName = "{$serviceName}-pr-{$pullRequestId}"; - } +// $payload = collect($service)->merge([ +// 'container_name' => $containerName, +// 'restart' => $restart->value(), +// 'labels' => $serviceLabels, +// ]); +// if (! $use_network_mode) { +// $payload['networks'] = $networks_temp; +// } +// if ($ports->count() > 0) { +// $payload['ports'] = $ports; +// } +// if ($volumesParsed->count() > 0) { +// $payload['volumes'] = $volumesParsed; +// } +// if ($environment->count() > 0 || $coolifyEnvironments->count() > 0) { +// $payload['environment'] = $environment->merge($coolifyEnvironments); +// } +// if ($logging) { +// $payload['logging'] = $logging; +// } +// if ($depends_on->count() > 0) { +// $payload['depends_on'] = $depends_on; +// } +// if ($isApplication && $isPullRequest) { +// $serviceName = "{$serviceName}-pr-{$pullRequestId}"; +// } - $parsedServices->put($serviceName, $payload); - } - $topLevel->put('services', $parsedServices); +// $parsedServices->put($serviceName, $payload); +// } +// $topLevel->put('services', $parsedServices); - $customOrder = ['services', 'volumes', 'networks', 'configs', 'secrets']; +// $customOrder = ['services', 'volumes', 'networks', 'configs', 'secrets']; - $topLevel = $topLevel->sortBy(function ($value, $key) use ($customOrder) { - return array_search($key, $customOrder); - }); +// $topLevel = $topLevel->sortBy(function ($value, $key) use ($customOrder) { +// return array_search($key, $customOrder); +// }); - $resource->docker_compose = Yaml::dump(convertToArray($topLevel), 10, 2); - data_forget($resource, 'environment_variables'); - data_forget($resource, 'environment_variables_preview'); - $resource->save(); +// $resource->docker_compose = Yaml::dump(convertToArray($topLevel), 10, 2); +// data_forget($resource, 'environment_variables'); +// data_forget($resource, 'environment_variables_preview'); +// $resource->save(); - return $topLevel; -} +// return $topLevel; +// } function generate_fluentd_configuration(): array { From 0e7cc988a6d7b091be0c903b700c245b120cce43 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Thu, 7 Aug 2025 21:57:00 +0200 Subject: [PATCH 21/51] feat(user): add changelog read tracking and unread count method --- app/Console/Commands/InitChangelog.php | 98 ++++++ app/Livewire/SettingsDropdown.php | 52 ++++ app/Models/User.php | 10 + app/Models/UserChangelogRead.php | 48 +++ app/Services/ChangelogService.php | 294 ++++++++++++++++++ config/services.php | 2 +- ...2403_create_user_changelog_reads_table.php | 34 ++ docker/production/Dockerfile | 1 + resources/views/components/navbar.blade.php | 187 +++++------ .../livewire/settings-dropdown.blade.php | 271 ++++++++++++++++ 10 files changed, 887 insertions(+), 110 deletions(-) create mode 100644 app/Console/Commands/InitChangelog.php create mode 100644 app/Livewire/SettingsDropdown.php create mode 100644 app/Models/UserChangelogRead.php create mode 100644 app/Services/ChangelogService.php create mode 100644 database/migrations/2025_08_07_142403_create_user_changelog_reads_table.php create mode 100644 resources/views/livewire/settings-dropdown.blade.php diff --git a/app/Console/Commands/InitChangelog.php b/app/Console/Commands/InitChangelog.php new file mode 100644 index 000000000..f9eb12f04 --- /dev/null +++ b/app/Console/Commands/InitChangelog.php @@ -0,0 +1,98 @@ +argument('month') ?: Carbon::now()->format('Y-m'); + + // Validate month format + if (! preg_match('/^\d{4}-(0[1-9]|1[0-2])$/', $month)) { + $this->error('Invalid month format. Use YYYY-MM format with valid months 01-12 (e.g., 2025-08)'); + + return self::FAILURE; + } + + $changelogsDir = base_path('changelogs'); + $filePath = $changelogsDir."/{$month}.json"; + + // Create changelogs directory if it doesn't exist + if (! is_dir($changelogsDir)) { + mkdir($changelogsDir, 0755, true); + $this->info("Created changelogs directory: {$changelogsDir}"); + } + + // Check if file already exists + if (file_exists($filePath)) { + if (! $this->confirm("File {$month}.json already exists. Overwrite?")) { + $this->info('Operation cancelled'); + + return self::SUCCESS; + } + } + + // Parse the month for example data + $carbonMonth = Carbon::createFromFormat('Y-m', $month); + $monthName = $carbonMonth->format('F Y'); + $sampleDate = $carbonMonth->addDays(14)->toISOString(); // Mid-month + + // Get version from config + $version = 'v'.config('constants.coolify.version'); + + // Create example changelog structure + $exampleData = [ + 'entries' => [ + [ + 'version' => $version, + 'title' => 'Example Feature Release', + 'content' => "This is an example changelog entry for {$monthName}. Replace this with your actual release notes. Include details about new features, improvements, bug fixes, and any breaking changes.", + 'published_at' => $sampleDate, + ], + ], + ]; + + // Write the file + $jsonContent = json_encode($exampleData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + + if (file_put_contents($filePath, $jsonContent) === false) { + $this->error("Failed to create changelog file: {$filePath}"); + + return self::FAILURE; + } + + $this->info("✅ Created changelog file: changelogs/{$month}.json"); + $this->line(" Example entry created for {$monthName}"); + $this->line(' Edit the file to add your actual changelog entries'); + + // Show the file contents + if ($this->option('verbose')) { + $this->newLine(); + $this->line('File contents:'); + $this->line($jsonContent); + } + + return self::SUCCESS; + } +} diff --git a/app/Livewire/SettingsDropdown.php b/app/Livewire/SettingsDropdown.php new file mode 100644 index 000000000..5bb3e37a4 --- /dev/null +++ b/app/Livewire/SettingsDropdown.php @@ -0,0 +1,52 @@ +getUnreadChangelogCount(); + } + + public function getEntriesProperty() + { + $user = Auth::user(); + + return app(ChangelogService::class)->getEntriesForUser($user); + } + + public function openWhatsNewModal() + { + $this->showWhatsNewModal = true; + } + + public function closeWhatsNewModal() + { + $this->showWhatsNewModal = false; + } + + public function markAsRead($identifier) + { + app(ChangelogService::class)->markAsReadForUser($identifier, Auth::user()); + } + + public function markAllAsRead() + { + app(ChangelogService::class)->markAllAsReadForUser(Auth::user()); + } + + public function render() + { + return view('livewire.settings-dropdown', [ + 'entries' => $this->entries, + 'unreadCount' => $this->unreadCount, + ]); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 6cd1b66db..3c5a220f8 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -203,6 +203,16 @@ class User extends Authenticatable implements SendsEmail return $this->belongsToMany(Team::class)->withPivot('role'); } + public function changelogReads() + { + return $this->hasMany(UserChangelogRead::class); + } + + public function getUnreadChangelogCount(): int + { + return app(\App\Services\ChangelogService::class)->getUnreadCountForUser($this); + } + public function getRecipients(): array { return [$this->email]; diff --git a/app/Models/UserChangelogRead.php b/app/Models/UserChangelogRead.php new file mode 100644 index 000000000..28c384cb5 --- /dev/null +++ b/app/Models/UserChangelogRead.php @@ -0,0 +1,48 @@ + 'datetime', + ]; + + public function user(): BelongsTo + { + return $this->belongsTo(User::class); + } + + public static function markAsRead(int $userId, string $identifier): void + { + self::firstOrCreate([ + 'user_id' => $userId, + 'changelog_identifier' => $identifier, + ], [ + 'read_at' => now(), + ]); + } + + public static function isReadByUser(int $userId, string $identifier): bool + { + return self::where('user_id', $userId) + ->where('changelog_identifier', $identifier) + ->exists(); + } + + public static function getReadIdentifiersForUser(int $userId): array + { + return self::where('user_id', $userId) + ->pluck('changelog_identifier') + ->toArray(); + } +} diff --git a/app/Services/ChangelogService.php b/app/Services/ChangelogService.php new file mode 100644 index 000000000..c6f4c8752 --- /dev/null +++ b/app/Services/ChangelogService.php @@ -0,0 +1,294 @@ +fetchChangelogData(); + + if (! $data || ! isset($data['entries'])) { + return collect(); + } + + return collect($data['entries']) + ->filter(fn ($entry) => $this->validateEntryData($entry)) + ->map(function ($entry) { + $entry['published_at'] = Carbon::parse($entry['published_at']); + $entry['content_html'] = $this->parseMarkdown($entry['content']); + + return (object) $entry; + }) + ->filter(fn ($entry) => $entry->published_at <= now()) + ->sortBy('published_at') + ->reverse() + ->values(); + } + + // Load entries from recent months for performance + $availableMonths = $this->getAvailableMonths(); + $monthsToLoad = $availableMonths->take($recentMonths); + + return $monthsToLoad + ->flatMap(fn ($month) => $this->getEntriesForMonth($month)) + ->sortBy('published_at') + ->reverse() + ->values(); + } + + public function getAllEntries(): Collection + { + $availableMonths = $this->getAvailableMonths(); + + return $availableMonths + ->flatMap(fn ($month) => $this->getEntriesForMonth($month)) + ->sortBy('published_at') + ->reverse() + ->values(); + } + + public function getEntriesForUser(User $user): Collection + { + $entries = $this->getEntries(); + $readIdentifiers = UserChangelogRead::getReadIdentifiersForUser($user->id); + + return $entries->map(function ($entry) use ($readIdentifiers) { + $entry->is_read = in_array($entry->version, $readIdentifiers); + + return $entry; + })->sortBy([ + ['is_read', 'asc'], // unread first + ['published_at', 'desc'], // then by date + ])->values(); + } + + public function getUnreadCountForUser(User $user): int + { + if (isDev()) { + $entries = $this->getEntries(); + $readIdentifiers = UserChangelogRead::getReadIdentifiersForUser($user->id); + + return $entries->reject(fn ($entry) => in_array($entry->version, $readIdentifiers))->count(); + } else { + return Cache::remember( + 'user_unread_changelog_count_'.$user->id, + now()->addHour(), + function () use ($user) { + $entries = $this->getEntries(); + $readIdentifiers = UserChangelogRead::getReadIdentifiersForUser($user->id); + + return $entries->reject(fn ($entry) => in_array($entry->version, $readIdentifiers))->count(); + } + ); + } + } + + public function getAvailableMonths(): Collection + { + $pattern = base_path('changelogs/*.json'); + $files = glob($pattern); + + if ($files === false) { + return collect(); + } + + return collect($files) + ->map(fn ($file) => basename($file, '.json')) + ->filter(fn ($name) => preg_match('/^\d{4}-\d{2}$/', $name)) + ->sort() + ->reverse() + ->values(); + } + + public function getEntriesForMonth(string $month): Collection + { + $path = base_path("changelogs/{$month}.json"); + + if (! file_exists($path)) { + return collect(); + } + + $content = file_get_contents($path); + + if ($content === false) { + Log::error("Failed to read changelog file: {$month}.json"); + + return collect(); + } + + $data = json_decode($content, true); + + if (json_last_error() !== JSON_ERROR_NONE) { + Log::error("Invalid JSON in {$month}.json: ".json_last_error_msg()); + + return collect(); + } + + if (! isset($data['entries']) || ! is_array($data['entries'])) { + return collect(); + } + + return collect($data['entries']) + ->filter(fn ($entry) => $this->validateEntryData($entry)) + ->map(function ($entry) { + $entry['published_at'] = Carbon::parse($entry['published_at']); + $entry['content_html'] = $this->parseMarkdown($entry['content']); + + return (object) $entry; + }) + ->filter(fn ($entry) => $entry->published_at <= now()) + ->sortBy('published_at') + ->reverse() + ->values(); + } + + private function fetchChangelogData(): ?array + { + // Legacy support for old changelog.json + $path = base_path('changelog.json'); + + if (file_exists($path)) { + $content = file_get_contents($path); + + if ($content === false) { + Log::error('Failed to read changelog.json file'); + + return null; + } + + $data = json_decode($content, true); + + if (json_last_error() !== JSON_ERROR_NONE) { + Log::error('Invalid JSON in changelog.json: '.json_last_error_msg()); + + return null; + } + + return $data; + } + + // New monthly structure - combine all months + $allEntries = []; + foreach ($this->getAvailableMonths() as $month) { + $monthEntries = $this->getEntriesForMonth($month); + foreach ($monthEntries as $entry) { + $allEntries[] = (array) $entry; + } + } + + return ['entries' => $allEntries]; + } + + public function markAsReadForUser(string $version, User $user): void + { + UserChangelogRead::markAsRead($user->id, $version); + Cache::forget('user_unread_changelog_count_'.$user->id); + } + + public function markAllAsReadForUser(User $user): void + { + $entries = $this->getEntries(); + + foreach ($entries as $entry) { + UserChangelogRead::markAsRead($user->id, $entry->version); + } + + Cache::forget('user_unread_changelog_count_'.$user->id); + } + + private function validateEntryData(array $data): bool + { + $required = ['version', 'title', 'content', 'published_at']; + + foreach ($required as $field) { + if (! isset($data[$field]) || empty($data[$field])) { + return false; + } + } + + return true; + } + + public function clearAllReadStatus(): array + { + try { + $count = UserChangelogRead::count(); + UserChangelogRead::truncate(); + + // Clear all user caches + $this->clearAllUserCaches(); + + return [ + 'success' => true, + 'message' => "Successfully cleared {$count} read status records", + ]; + } catch (\Exception $e) { + Log::error('Failed to clear read status: '.$e->getMessage()); + + return [ + 'success' => false, + 'message' => 'Failed to clear read status: '.$e->getMessage(), + ]; + } + } + + private function clearAllUserCaches(): void + { + $users = User::select('id')->get(); + + foreach ($users as $user) { + Cache::forget('user_unread_changelog_count_'.$user->id); + } + } + + private function parseMarkdown(string $content): string + { + // Convert markdown to HTML using simple regex patterns + $html = $content; + + // Headers + $html = preg_replace('/^### (.*?)$/m', '

$1

', $html); + $html = preg_replace('/^## (.*?)$/m', '

$1

', $html); + $html = preg_replace('/^# (.*?)$/m', '

$1

', $html); + + // Bold text + $html = preg_replace('/\*\*(.*?)\*\*/', '$1', $html); + $html = preg_replace('/__(.*?)__/', '$1', $html); + + // Italic text + $html = preg_replace('/\*(.*?)\*/', '$1', $html); + $html = preg_replace('/_(.*?)_/', '$1', $html); + + // Code blocks + $html = preg_replace('/```(.*?)```/s', '
$1
', $html); + + // Inline code + $html = preg_replace('/`([^`]+)`/', '$1', $html); + + // Links + $html = preg_replace('/\[([^\]]+)\]\(([^)]+)\)/', '$1', $html); + + // Line breaks (convert double newlines to paragraphs) + $paragraphs = preg_split('/\n\s*\n/', trim($html)); + $html = '

'.implode('

', $paragraphs).'

'; + + // Single line breaks + $html = preg_replace('/\n/', '
', $html); + + // Unordered lists + $html = preg_replace('/^\- (.*)$/m', '
  • • $1
  • ', $html); + $html = preg_replace('/(
  • .*<\/li>)/s', '
      $1
    ', $html); + + return $html; + } +} diff --git a/config/services.php b/config/services.php index 7add50a5c..6a21cda18 100644 --- a/config/services.php +++ b/config/services.php @@ -65,6 +65,6 @@ return [ 'client_secret' => env('ZITADEL_CLIENT_SECRET'), 'redirect' => env('ZITADEL_REDIRECT_URI'), 'base_url' => env('ZITADEL_BASE_URL'), - ] + ], ]; diff --git a/database/migrations/2025_08_07_142403_create_user_changelog_reads_table.php b/database/migrations/2025_08_07_142403_create_user_changelog_reads_table.php new file mode 100644 index 000000000..4c340d106 --- /dev/null +++ b/database/migrations/2025_08_07_142403_create_user_changelog_reads_table.php @@ -0,0 +1,34 @@ +id(); + $table->foreignId('user_id')->constrained()->onDelete('cascade'); + $table->string('changelog_identifier'); + $table->timestamp('read_at'); + $table->timestamps(); + + $table->unique(['user_id', 'changelog_identifier']); + $table->index('user_id'); + $table->index('changelog_identifier'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('user_changelog_reads'); + } +}; diff --git a/docker/production/Dockerfile b/docker/production/Dockerfile index a2a4b5fa3..6c9628a81 100644 --- a/docker/production/Dockerfile +++ b/docker/production/Dockerfile @@ -120,6 +120,7 @@ COPY --chown=www-data:www-data templates ./templates COPY --chown=www-data:www-data resources/views ./resources/views COPY --chown=www-data:www-data artisan artisan COPY --chown=www-data:www-data openapi.yaml ./openapi.yaml +COPY --chown=www-data:www-data changelogs/ ./changelogs/ RUN composer dump-autoload diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index be26d55ca..1a145aa4b 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -1,119 +1,88 @@ -