From 611f70d79f580b9c655ba12861154726ca98ae76 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 4 Oct 2024 12:08:06 +0200 Subject: [PATCH 1/3] chore: Remove commented code for shared variable type validation --- app/Livewire/Project/Shared/EnvironmentVariable/Add.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Add.php b/app/Livewire/Project/Shared/EnvironmentVariable/Add.php index a859c90b0..0dbf0f957 100644 --- a/app/Livewire/Project/Shared/EnvironmentVariable/Add.php +++ b/app/Livewire/Project/Shared/EnvironmentVariable/Add.php @@ -48,14 +48,6 @@ class Add extends Component public function submit() { $this->validate(); - // if (str($this->value)->startsWith('{{') && str($this->value)->endsWith('}}')) { - // $type = str($this->value)->after('{{')->before('.')->value; - // if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) { - // $this->dispatch('error', 'Invalid shared variable type.', 'Valid types are: team, project, environment.'); - - // return; - // } - // } $this->dispatch('saveKey', [ 'key' => $this->key, 'value' => $this->value, From c2c0afa0bab498705fb1661b96373064890516ae Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 4 Oct 2024 12:08:57 +0200 Subject: [PATCH 2/3] fix: service env orders, application env orders --- .../Shared/EnvironmentVariable/All.php | 32 ++++++------------- app/Models/Service.php | 4 +-- .../shared/environment-variable/all.blade.php | 6 ++-- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/All.php b/app/Livewire/Project/Shared/EnvironmentVariable/All.php index 055788b57..5a711259b 100644 --- a/app/Livewire/Project/Shared/EnvironmentVariable/All.php +++ b/app/Livewire/Project/Shared/EnvironmentVariable/All.php @@ -53,30 +53,16 @@ class All extends Component public function sortEnvironmentVariables() { - if ($this->resource->type() === 'application') { - $this->resource->load(['environment_variables', 'environment_variables_preview']); - } else { - $this->resource->load(['environment_variables']); + if (! data_get($this->resource, 'settings.is_env_sorting_enabled')) { + if ($this->resource->environment_variables) { + $this->resource->environment_variables = $this->resource->environment_variables->sortBy('order')->values(); + } + + if ($this->resource->environment_variables_preview) { + $this->resource->environment_variables_preview = $this->resource->environment_variables_preview->sortBy('order')->values(); + } } - $sortBy = data_get($this->resource, 'settings.is_env_sorting_enabled') ? 'key' : 'order'; - - $sortFunction = function ($variables) use ($sortBy) { - if (! $variables) { - return $variables; - } - if ($sortBy === 'key') { - return $variables->sortBy(function ($item) { - return strtolower($item->key); - }, SORT_NATURAL | SORT_FLAG_CASE)->values(); - } else { - return $variables->sortBy('order')->values(); - } - }; - - $this->resource->environment_variables = $sortFunction($this->resource->environment_variables); - $this->resource->environment_variables_preview = $sortFunction($this->resource->environment_variables_preview); - $this->getDevView(); } @@ -121,6 +107,8 @@ class All extends Component $this->sortEnvironmentVariables(); } catch (\Throwable $e) { return handleError($e, $this); + } finally { + $this->refreshEnvs(); } } diff --git a/app/Models/Service.php b/app/Models/Service.php index 632934524..1c5979644 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -1076,12 +1076,12 @@ class Service extends BaseModel public function environment_variables(): HasMany { - return $this->hasMany(EnvironmentVariable::class)->orderByRaw("key LIKE 'SERVICE%' DESC, value ASC"); + return $this->hasMany(EnvironmentVariable::class)->orderByRaw("LOWER(key) LIKE LOWER('SERVICE%') DESC, LOWER(key) ASC"); } public function environment_variables_preview(): HasMany { - return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->orderBy('key', 'asc'); + return $this->hasMany(EnvironmentVariable::class)->where('is_preview', true)->orderByRaw("LOWER(key) LIKE LOWER('SERVICE%') DESC, LOWER(key) ASC"); } public function workdir() diff --git a/resources/views/livewire/project/shared/environment-variable/all.blade.php b/resources/views/livewire/project/shared/environment-variable/all.blade.php index bd6f31551..5e8aa7d63 100644 --- a/resources/views/livewire/project/shared/environment-variable/all.blade.php +++ b/resources/views/livewire/project/shared/environment-variable/all.blade.php @@ -56,13 +56,13 @@ @else
- + @if ($showPreview) @endif - + Save All Environment Variables
@endif - \ No newline at end of file + From be9041d59252a779c6a05835c1fcccdd4f630424 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 4 Oct 2024 12:20:35 +0200 Subject: [PATCH 3/3] chore: Update MariaDB image to version 11 and fix service environment variable orders --- templates/compose/invoice-ninja.yaml | 58 ++++++++++++---------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/templates/compose/invoice-ninja.yaml b/templates/compose/invoice-ninja.yaml index 55a78b4c7..bac08c862 100644 --- a/templates/compose/invoice-ninja.yaml +++ b/templates/compose/invoice-ninja.yaml @@ -2,28 +2,29 @@ # documentation: https://invoiceninja.github.io/selfhost.html # slogan: The leading open-source invoicing platform # tags: invoicing, billing, accounting, finance, self-hosted +# port: 9000 services: invoice-ninja: image: invoiceninja/invoiceninja:5 environment: - SERVICE_FQDN_INVOICENINJA - - APP_ENV=production + - APP_ENV=${APP_ENV:-production} - APP_URL=${SERVICE_FQDN_INVOICENINJA} - - APP_KEY=${SERVICE_BASE64_INVOICENINJA} - - APP_DEBUG=false - - REQUIRE_HTTPS=false - - PHANTOMJS_PDF_GENERATION=false - - PDF_GENERATOR=snappdf - - TRUSTED_PROXIES=* - - QUEUE_CONNECTION=database - - DB_HOST=mysql - - DB_PORT=3306 - - DB_DATABASE=${MYSQL_DATABASE:-invoice_ninja} - - DB_USERNAME=${SERVICE_USER_MYSQL} - - DB_PASSWORD=${SERVICE_PASSWORD_MYSQL} + - APP_KEY=${SERVICE_REALBASE64_INVOICENINJA} + - APP_DEBUG=${APP_DEBUG:-false} + - REQUIRE_HTTPS=${REQUIRE_HTTPS:-false} + - PHANTOMJS_PDF_GENERATION=${PHANTOMJS_PDF_GENERATION:-false} + - PDF_GENERATOR=${PDF_GENERATOR:-snappdf} + - TRUSTED_PROXIES=${TRUSTED_PROXIES:-*} + - QUEUE_CONNECTION=${QUEUE_CONNECTION:-database} + - DB_HOST=${DB_HOST:-mariadb} + - DB_PORT=${DB_PORT:-3306} + - DB_DATABASE=${DB_DATABASE:-invoiceninja} + - DB_USERNAME=$SERVICE_USER_INVOICENINJA + - DB_PASSWORD=$SERVICE_PASSWORD_INVOICENINJA healthcheck: - test: ['CMD', 'curl', '-f', 'http://127.0.0.1:9000'] + test: ['CMD', 'echo', 'ok'] interval: 5s timeout: 20s retries: 10 @@ -78,28 +79,19 @@ services: post_max_size = 60M upload_max_filesize = 50M depends_on: - mysql: + mariadb: condition: service_healthy - mysql: - image: mariadb:lts + mariadb: + image: mariadb:11 + volumes: + - mariadb-data:/var/lib/mysql environment: - - MYSQL_USER=${SERVICE_USER_MYSQL} - - MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL} - - MYSQL_DATABASE=${MYSQL_DATABASE:-invoice_ninja} - - MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQLROOT} + - MYSQL_ROOT_PASSWORD=$SERVICE_PASSWORD_ROOT + - MYSQL_DATABASE=${DB_DATABASE:-invoiceninja} + - MYSQL_USER=$SERVICE_USER_INVOICENINJA + - MYSQL_PASSWORD=$SERVICE_PASSWORD_INVOICENINJA healthcheck: - test: - [ - "CMD", - "mysqladmin", - "ping", - "-h", - "127.0.0.1", - "-uroot", - "-p${SERVICE_PASSWORD_MYSQLROOT}", - ] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] interval: 5s timeout: 20s retries: 10 - volumes: - - invoice-ninja-mysql-data:/var/lib/mysql