feat: COOLIFY_CONTAINER_NAME predefined variable
This commit is contained in:
parent
b17be37aee
commit
1ecd0307ed
@ -828,6 +828,9 @@ private function save_environment_variables()
|
|||||||
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
||||||
$envs->push("COOLIFY_BRANCH={$local_branch}");
|
$envs->push("COOLIFY_BRANCH={$local_branch}");
|
||||||
}
|
}
|
||||||
|
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
|
||||||
|
$envs->push("COOLIFY_CONTAINER_NAME={$this->container_name}");
|
||||||
|
}
|
||||||
foreach ($sorted_environment_variables_preview as $env) {
|
foreach ($sorted_environment_variables_preview as $env) {
|
||||||
$real_value = $env->real_value;
|
$real_value = $env->real_value;
|
||||||
if ($env->version === '4.0.0-beta.239') {
|
if ($env->version === '4.0.0-beta.239') {
|
||||||
@ -869,6 +872,9 @@ private function save_environment_variables()
|
|||||||
if ($this->application->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
if ($this->application->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
|
||||||
$envs->push("COOLIFY_BRANCH={$local_branch}");
|
$envs->push("COOLIFY_BRANCH={$local_branch}");
|
||||||
}
|
}
|
||||||
|
if ($this->application->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
|
||||||
|
$envs->push("COOLIFY_CONTAINER_NAME={$this->container_name}");
|
||||||
|
}
|
||||||
foreach ($sorted_environment_variables as $env) {
|
foreach ($sorted_environment_variables as $env) {
|
||||||
$real_value = $env->real_value;
|
$real_value = $env->real_value;
|
||||||
if ($env->version === '4.0.0-beta.239') {
|
if ($env->version === '4.0.0-beta.239') {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
class Service extends BaseModel
|
class Service extends BaseModel
|
||||||
{
|
{
|
||||||
@ -837,6 +838,13 @@ public function saveComposeConfigs()
|
|||||||
$commands[] = "mkdir -p $workdir";
|
$commands[] = "mkdir -p $workdir";
|
||||||
$commands[] = "cd $workdir";
|
$commands[] = "cd $workdir";
|
||||||
|
|
||||||
|
$json = Yaml::parse($this->docker_compose);
|
||||||
|
foreach($json['services'] as $service => $config) {
|
||||||
|
$envs = collect($config['environment']);
|
||||||
|
$envs->push("COOLIFY_CONTAINER_NAME=$service-{$this->uuid}");
|
||||||
|
data_set($json, "services.$service.environment", $envs->toArray());
|
||||||
|
}
|
||||||
|
$this->docker_compose = Yaml::dump($json);
|
||||||
$docker_compose_base64 = base64_encode($this->docker_compose);
|
$docker_compose_base64 = base64_encode($this->docker_compose);
|
||||||
$commands[] = "echo $docker_compose_base64 | base64 -d | tee docker-compose.yml > /dev/null";
|
$commands[] = "echo $docker_compose_base64 | base64 -d | tee docker-compose.yml > /dev/null";
|
||||||
$envs = $this->environment_variables()->get();
|
$envs = $this->environment_variables()->get();
|
||||||
|
Loading…
Reference in New Issue
Block a user