fix: $ in env variable
feat: multiline envs
This commit is contained in:
		@@ -1359,23 +1359,31 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
 | 
				
			|||||||
        $environment_variables = collect();
 | 
					        $environment_variables = collect();
 | 
				
			||||||
        if ($this->pull_request_id === 0) {
 | 
					        if ($this->pull_request_id === 0) {
 | 
				
			||||||
            foreach ($this->application->runtime_environment_variables as $env) {
 | 
					            foreach ($this->application->runtime_environment_variables as $env) {
 | 
				
			||||||
                $environment_variables->push("$env->key=$env->real_value");
 | 
					                $real_value = escapeEnvVariables($env->real_value);
 | 
				
			||||||
 | 
					                $environment_variables->push("$env->key=$real_value");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            foreach ($this->application->nixpacks_environment_variables as $env) {
 | 
					            foreach ($this->application->nixpacks_environment_variables as $env) {
 | 
				
			||||||
                $environment_variables->push("$env->key=$env->real_value");
 | 
					                $real_value = escapeEnvVariables($env->real_value);
 | 
				
			||||||
 | 
					                $environment_variables->push("$env->key=$real_value");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            foreach ($this->application->runtime_environment_variables_preview as $env) {
 | 
					            foreach ($this->application->runtime_environment_variables_preview as $env) {
 | 
				
			||||||
                $environment_variables->push("$env->key=$env->real_value");
 | 
					                $real_value = escapeEnvVariables($env->real_value);
 | 
				
			||||||
 | 
					                $environment_variables->push("$env->key=$real_value");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            foreach ($this->application->nixpacks_environment_variables_preview as $env) {
 | 
					            foreach ($this->application->nixpacks_environment_variables_preview as $env) {
 | 
				
			||||||
                $environment_variables->push("$env->key=$env->real_value");
 | 
					                $real_value = escapeEnvVariables($env->real_value);
 | 
				
			||||||
 | 
					                $environment_variables->push("$env->key=$real_value");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // Add PORT if not exists, use the first port as default
 | 
					        // Add PORT if not exists, use the first port as default
 | 
				
			||||||
        if ($environment_variables->filter(fn ($env) => Str::of($env)->startsWith('PORT'))->isEmpty()) {
 | 
					        if ($environment_variables->filter(fn ($env) => Str::of($env)->startsWith('PORT'))->isEmpty()) {
 | 
				
			||||||
            $environment_variables->push("PORT={$ports[0]}");
 | 
					            $environment_variables->push("PORT={$ports[0]}");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        // Add HOST if not exists
 | 
				
			||||||
 | 
					        if ($environment_variables->filter(fn ($env) => Str::of($env)->startsWith('HOST'))->isEmpty()) {
 | 
				
			||||||
 | 
					            $environment_variables->push("HOST=0.0.0.0");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if ($environment_variables->filter(fn ($env) => Str::of($env)->startsWith('SOURCE_COMMIT'))->isEmpty()) {
 | 
					        if ($environment_variables->filter(fn ($env) => Str::of($env)->startsWith('SOURCE_COMMIT'))->isEmpty()) {
 | 
				
			||||||
            if (!is_null($this->commit)) {
 | 
					            if (!is_null($this->commit)) {
 | 
				
			||||||
                $environment_variables->push("SOURCE_COMMIT={$this->commit}");
 | 
					                $environment_variables->push("SOURCE_COMMIT={$this->commit}");
 | 
				
			||||||
@@ -1383,6 +1391,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
 | 
				
			|||||||
                $environment_variables->push("SOURCE_COMMIT=unknown");
 | 
					                $environment_variables->push("SOURCE_COMMIT=unknown");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        ray($environment_variables->all());
 | 
				
			||||||
        return $environment_variables->all();
 | 
					        return $environment_variables->all();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@ class Show extends Component
 | 
				
			|||||||
        'env.key' => 'required|string',
 | 
					        'env.key' => 'required|string',
 | 
				
			||||||
        'env.value' => 'nullable',
 | 
					        'env.value' => 'nullable',
 | 
				
			||||||
        'env.is_build_time' => 'required|boolean',
 | 
					        'env.is_build_time' => 'required|boolean',
 | 
				
			||||||
 | 
					        'env.is_multiline' => 'required|boolean',
 | 
				
			||||||
        'env.is_shown_once' => 'required|boolean',
 | 
					        'env.is_shown_once' => 'required|boolean',
 | 
				
			||||||
        'env.real_value' => 'nullable',
 | 
					        'env.real_value' => 'nullable',
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
@@ -28,6 +29,7 @@ class Show extends Component
 | 
				
			|||||||
        'env.key' => 'Key',
 | 
					        'env.key' => 'Key',
 | 
				
			||||||
        'env.value' => 'Value',
 | 
					        'env.value' => 'Value',
 | 
				
			||||||
        'env.is_build_time' => 'Build Time',
 | 
					        'env.is_build_time' => 'Build Time',
 | 
				
			||||||
 | 
					        'env.is_multiline' => 'Multiline',
 | 
				
			||||||
        'env.is_shown_once' => 'Shown Once',
 | 
					        'env.is_shown_once' => 'Shown Once',
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -557,7 +557,8 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null
 | 
				
			|||||||
    return $compose_options->toArray();
 | 
					    return $compose_options->toArray();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function validateComposeFile(string $compose, int $server_id): string|Throwable {
 | 
					function validateComposeFile(string $compose, int $server_id): string|Throwable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
    return 'OK';
 | 
					    return 'OK';
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        $uuid = Str::random(10);
 | 
					        $uuid = Str::random(10);
 | 
				
			||||||
@@ -578,3 +579,10 @@ function validateComposeFile(string $compose, int $server_id): string|Throwable
 | 
				
			|||||||
        ], $server);
 | 
					        ], $server);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function escapeEnvVariables($value)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    $search = array("\\", "\r", "\t", "\x0", '"', "'", "$");
 | 
				
			||||||
 | 
					    $replace = array("\\\\", "\\r", "\\t", "\\0", '\"', "\'", "$$");
 | 
				
			||||||
 | 
					    return str_replace($search, $replace, $value);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@ return [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // The release version of your application
 | 
					    // The release version of your application
 | 
				
			||||||
    // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
 | 
					    // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
 | 
				
			||||||
    'release' => '4.0.0-beta.239',
 | 
					    'release' => '4.0.0-beta.240',
 | 
				
			||||||
    // When left empty or `null` the Laravel environment will be used
 | 
					    // When left empty or `null` the Laravel environment will be used
 | 
				
			||||||
    'environment' => config('app.env'),
 | 
					    'environment' => config('app.env'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,3 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return '4.0.0-beta.239';
 | 
					return '4.0.0-beta.240';
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										28
									
								
								database/migrations/2024_03_14_214402_add_multiline_envs.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								database/migrations/2024_03_14_214402_add_multiline_envs.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Illuminate\Database\Migrations\Migration;
 | 
				
			||||||
 | 
					use Illuminate\Database\Schema\Blueprint;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Schema;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					return new class extends Migration
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Run the migrations.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function up(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Schema::table('environment_variables', function (Blueprint $table) {
 | 
				
			||||||
 | 
					            $table->boolean('is_multiline')->default(false);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Reverse the migrations.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function down(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Schema::table('environment_variables', function (Blueprint $table) {
 | 
				
			||||||
 | 
					            $table->dropColumn('is_multiline');
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@@ -19,12 +19,19 @@
 | 
				
			|||||||
                @if ($type !== 'service' && !$isSharedVariable)
 | 
					                @if ($type !== 'service' && !$isSharedVariable)
 | 
				
			||||||
                    <x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
 | 
					                    <x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
 | 
				
			||||||
                @endif
 | 
					                @endif
 | 
				
			||||||
 | 
					            @else
 | 
				
			||||||
 | 
					                @if ($env->is_multiline)
 | 
				
			||||||
 | 
					                    <x-forms.input class="h-12" id="env.key" />
 | 
				
			||||||
 | 
					                    <textarea wire:model.lazy="env.value" rows="1" id="env.value"
 | 
				
			||||||
 | 
					                        class="w-full leading-normal text-white rounded textarea bg-coolgray-100 scrollbar disabled:bg-coolgray-200/50 disabled:border-none placeholder:text-coolgray-500 read-only:text-neutral-500 read-only:bg-coolgray-200/50"></textarea>
 | 
				
			||||||
                @else
 | 
					                @else
 | 
				
			||||||
                    <x-forms.input id="env.key" />
 | 
					                    <x-forms.input id="env.key" />
 | 
				
			||||||
                    <x-forms.input type="password" id="env.value" />
 | 
					                    <x-forms.input type="password" id="env.value" />
 | 
				
			||||||
 | 
					                @endif
 | 
				
			||||||
                @if ($env->is_shared)
 | 
					                @if ($env->is_shared)
 | 
				
			||||||
                    <x-forms.input disabled type="password" id="env.real_value" />
 | 
					                    <x-forms.input disabled type="password" id="env.real_value" />
 | 
				
			||||||
                @endif
 | 
					                @endif
 | 
				
			||||||
 | 
					                <x-forms.checkbox instantSave id="env.is_multiline" label="Is Multiline?" />
 | 
				
			||||||
                @if ($type !== 'service' && !$isSharedVariable)
 | 
					                @if ($type !== 'service' && !$isSharedVariable)
 | 
				
			||||||
                    <x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
 | 
					                    <x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
 | 
				
			||||||
                @endif
 | 
					                @endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@ services:
 | 
				
			|||||||
  uptime-kuma:
 | 
					  uptime-kuma:
 | 
				
			||||||
    image: louislam/uptime-kuma:1
 | 
					    image: louislam/uptime-kuma:1
 | 
				
			||||||
    environment:
 | 
					    environment:
 | 
				
			||||||
      - SERVICE_FQDN_3001
 | 
					      - SERVICE_FQDN_UPTIME-KUMA_3001
 | 
				
			||||||
    volumes:
 | 
					    volumes:
 | 
				
			||||||
      - uptime-kuma:/app/data
 | 
					      - uptime-kuma:/app/data
 | 
				
			||||||
    healthcheck:
 | 
					    healthcheck:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -772,7 +772,7 @@
 | 
				
			|||||||
    "uptime-kuma": {
 | 
					    "uptime-kuma": {
 | 
				
			||||||
        "documentation": "https:\/\/github.com\/louislam\/uptime-kuma?tab=readme-ov-file",
 | 
					        "documentation": "https:\/\/github.com\/louislam\/uptime-kuma?tab=readme-ov-file",
 | 
				
			||||||
        "slogan": "Uptime Kuma is a monitoring tool for tracking the status and performance of your applications in real-time.",
 | 
					        "slogan": "Uptime Kuma is a monitoring tool for tracking the status and performance of your applications in real-time.",
 | 
				
			||||||
        "compose": "c2VydmljZXM6CiAgdXB0aW1lLWt1bWE6CiAgICBpbWFnZTogJ2xvdWlzbGFtL3VwdGltZS1rdW1hOjEnCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fMzAwMQogICAgdm9sdW1lczoKICAgICAgLSAndXB0aW1lLWt1bWE6L2FwcC9kYXRhJwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQtU0hFTEwKICAgICAgICAtIGV4dHJhL2hlYWx0aGNoZWNrCiAgICAgIGludGVydmFsOiAycwogICAgICB0aW1lb3V0OiAxMHMKICAgICAgcmV0cmllczogMTUK",
 | 
					        "compose": "c2VydmljZXM6CiAgdXB0aW1lLWt1bWE6CiAgICBpbWFnZTogJ2xvdWlzbGFtL3VwdGltZS1rdW1hOjEnCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fVVBUSU1FLUtVTUFfMzAwMQogICAgdm9sdW1lczoKICAgICAgLSAndXB0aW1lLWt1bWE6L2FwcC9kYXRhJwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQtU0hFTEwKICAgICAgICAtIGV4dHJhL2hlYWx0aGNoZWNrCiAgICAgIGludGVydmFsOiAycwogICAgICB0aW1lb3V0OiAxMHMKICAgICAgcmV0cmllczogMTUK",
 | 
				
			||||||
        "tags": [
 | 
					        "tags": [
 | 
				
			||||||
            "monitoring",
 | 
					            "monitoring",
 | 
				
			||||||
            "status",
 | 
					            "status",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@
 | 
				
			|||||||
            "version": "3.12.36"
 | 
					            "version": "3.12.36"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        "v4": {
 | 
					        "v4": {
 | 
				
			||||||
            "version": "4.0.0-beta.239"
 | 
					            "version": "4.0.0-beta.240"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user