Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: $ in env variable feat: multiline envs

Andras Bacsaia336dae84c3d
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index f96a68582e..ca0efd2c3c 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -1359,23 +1359,31 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
$environment_variables = collect();
if ($this->pull_request_id === 0) {
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) {
- $environment_variables->push("$env->key=$env->real_value");
+ $real_value = escapeEnvVariables($env->real_value);
+ $environment_variables->push("$env->key=$real_value");
}
} else {
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) {
- $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
if ($environment_variables->filter(fn ($env) => Str::of($env)->startsWith('PORT'))->isEmpty()) {
$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 (!is_null($this->commit)) {
$environment_variables->push("SOURCE_COMMIT={$this->commit}");
@@ -1383,6 +1391,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
$environment_variables->push("SOURCE_COMMIT=unknown");
}
}
+ ray($environment_variables->all());
return $environment_variables->all();
}
diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
index 9252c44f89..7903e8e516 100644
--- a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
+++ b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php
@@ -21,6 +21,7 @@ class Show extends Component
'env.key' => 'required|string',
'env.value' => 'nullable',
'env.is_build_time' => 'required|boolean',
+ 'env.is_multiline' => 'required|boolean',
'env.is_shown_once' => 'required|boolean',
'env.real_value' => 'nullable',
];
@@ -28,6 +29,7 @@ class Show extends Component
'env.key' => 'Key',
'env.value' => 'Value',
'env.is_build_time' => 'Build Time',
+ 'env.is_multiline' => 'Multiline',
'env.is_shown_once' => 'Shown Once',
];
diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php
index 898789adfa..aed77a7bb9 100644
--- a/bootstrap/helpers/docker.php
+++ b/bootstrap/helpers/docker.php
@@ -557,7 +557,8 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null
return $compose_options->toArray();
}
-function validateComposeFile(string $compose, int $server_id): string|Throwable {
+function validateComposeFile(string $compose, int $server_id): string|Throwable
+{
return 'OK';
try {
$uuid = Str::random(10);
@@ -578,3 +579,10 @@ function validateComposeFile(string $compose, int $server_id): string|Throwable
], $server);
}
}
+
+function escapeEnvVariables($value)
+{
+ $search = array("\\", "\r", "\t", "\x0", '"', "'", "$");
+ $replace = array("\\\\", "\\r", "\\t", "\\0", '\"', "\'", "$$");
+ return str_replace($search, $replace, $value);
+}
diff --git a/config/sentry.php b/config/sentry.php
index 1fe45fcc9f..5d46ba7f3a 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -7,7 +7,7 @@ return [
// The release version of your application
// 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
'environment' => config('app.env'),
diff --git a/config/version.php b/config/version.php
index cf8c3ba8b1..c7e1008fca 100644
--- a/config/version.php
+++ b/config/version.php
@@ -1,3 +1,3 @@
<?php
-return '4.0.0-beta.239';
+return '4.0.0-beta.240';
diff --git a/database/migrations/2024_03_14_214402_add_multiline_envs.php b/database/migrations/2024_03_14_214402_add_multiline_envs.php
new file mode 100644
index 0000000000..c8d8099271
--- /dev/null
+++ b/database/migrations/2024_03_14_214402_add_multiline_envs.php
@@ -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');
+ });
+ }
+};
diff --git a/resources/views/livewire/project/shared/environment-variable/show.blade.php b/resources/views/livewire/project/shared/environment-variable/show.blade.php
index 5b2c953730..d644906052 100644
--- a/resources/views/livewire/project/shared/environment-variable/show.blade.php
+++ b/resources/views/livewire/project/shared/environment-variable/show.blade.php
@@ -20,11 +20,18 @@
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
@endif
@else
- <x-forms.input id="env.key" />
- <x-forms.input type="password" id="env.value" />
+ @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
+ <x-forms.input id="env.key" />
+ <x-forms.input type="password" id="env.value" />
+ @endif
@if ($env->is_shared)
<x-forms.input disabled type="password" id="env.real_value" />
@endif
+ <x-forms.checkbox instantSave id="env.is_multiline" label="Is Multiline?" />
@if ($type !== 'service' && !$isSharedVariable)
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
@endif
diff --git a/templates/compose/uptime-kuma.yaml b/templates/compose/uptime-kuma.yaml
index d5c07684d9..cd20d60cbf 100644
--- a/templates/compose/uptime-kuma.yaml
+++ b/templates/compose/uptime-kuma.yaml
@@ -8,7 +8,7 @@ services:
uptime-kuma:
image: louislam/uptime-kuma:1
environment:
- - SERVICE_FQDN_3001
+ - SERVICE_FQDN_UPTIME-KUMA_3001
volumes:
- uptime-kuma:/app/data
healthcheck:
diff --git a/templates/service-templates.json b/templates/service-templates.json
index c7a4d91db0..76bdf2bd84 100644
--- a/templates/service-templates.json
+++ b/templates/service-templates.json
@@ -772,7 +772,7 @@
"uptime-kuma": {
"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.",
- "compose": "c2VydmljZXM6CiAgdXB0aW1lLWt1bWE6CiAgICBpbWFnZTogJ2xvdWlzbGFtL3VwdGltZS1rdW1hOjEnCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fMzAwMQogICAgdm9sdW1lczoKICAgICAgLSAndXB0aW1lLWt1bWE6L2FwcC9kYXRhJwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQtU0hFTEwKICAgICAgICAtIGV4dHJhL2hlYWx0aGNoZWNrCiAgICAgIGludGVydmFsOiAycwogICAgICB0aW1lb3V0OiAxMHMKICAgICAgcmV0cmllczogMTUK",
+ "compose": "c2VydmljZXM6CiAgdXB0aW1lLWt1bWE6CiAgICBpbWFnZTogJ2xvdWlzbGFtL3VwdGltZS1rdW1hOjEnCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fVVBUSU1FLUtVTUFfMzAwMQogICAgdm9sdW1lczoKICAgICAgLSAndXB0aW1lLWt1bWE6L2FwcC9kYXRhJwogICAgaGVhbHRoY2hlY2s6CiAgICAgIHRlc3Q6CiAgICAgICAgLSBDTUQtU0hFTEwKICAgICAgICAtIGV4dHJhL2hlYWx0aGNoZWNrCiAgICAgIGludGVydmFsOiAycwogICAgICB0aW1lb3V0OiAxMHMKICAgICAgcmV0cmllczogMTUK",
"tags": [
"monitoring",
"status",
diff --git a/versions.json b/versions.json
index 8f30ba88c2..ba197ca84f 100644
--- a/versions.json
+++ b/versions.json
@@ -4,7 +4,7 @@
"version": "3.12.36"
},
"v4": {
- "version": "4.0.0-beta.239"
+ "version": "4.0.0-beta.240"
}
}
}