update templates
This commit is contained in:
parent
3eb628b773
commit
8f54b51ecd
@ -70,8 +70,8 @@ public function new()
|
|||||||
$oneClickServiceName = $type->after('one-click-service-')->value();
|
$oneClickServiceName = $type->after('one-click-service-')->value();
|
||||||
$oneClickService = data_get($services, "$oneClickServiceName.compose");
|
$oneClickService = data_get($services, "$oneClickServiceName.compose");
|
||||||
$oneClickDotEnvs = data_get($services, "$oneClickServiceName.envs", null);
|
$oneClickDotEnvs = data_get($services, "$oneClickServiceName.envs", null);
|
||||||
$oneClickRequiredFqdn = data_get($services, "$oneClickServiceName.generateFqdn", []);
|
$oneClickConfiguration = data_get($services, "$oneClickServiceName.configuration.proxy", []);
|
||||||
$oneClickRequiredFqdn = collect($oneClickRequiredFqdn);
|
$oneClickConfiguration = collect($oneClickConfiguration);
|
||||||
if ($oneClickDotEnvs) {
|
if ($oneClickDotEnvs) {
|
||||||
$oneClickDotEnvs = Str::of(base64_decode($oneClickDotEnvs))->split('/\r\n|\r|\n/');
|
$oneClickDotEnvs = Str::of(base64_decode($oneClickDotEnvs))->split('/\r\n|\r|\n/');
|
||||||
}
|
}
|
||||||
@ -94,6 +94,9 @@ public function new()
|
|||||||
if ($value->contains('SERVICE_PASSWORD')) {
|
if ($value->contains('SERVICE_PASSWORD')) {
|
||||||
$value = Str::of(Str::password(symbols: false));
|
$value = Str::of(Str::password(symbols: false));
|
||||||
}
|
}
|
||||||
|
if ($value->contains('SERVICE_PASSWORD64')) {
|
||||||
|
$value = Str::of(Str::password(length: 64, symbols: false));
|
||||||
|
}
|
||||||
if ($value->contains('SERVICE_BASE64')) {
|
if ($value->contains('SERVICE_BASE64')) {
|
||||||
$length = Str::of($value)->after('SERVICE_BASE64_')->beforeLast('_')->value();
|
$length = Str::of($value)->after('SERVICE_BASE64_')->beforeLast('_')->value();
|
||||||
if (is_numeric($length)) {
|
if (is_numeric($length)) {
|
||||||
@ -112,7 +115,7 @@ public function new()
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$service->parse(isNew: true, requiredFqdns: $oneClickRequiredFqdn);
|
$service->parse(isNew: true, configuration: $oneClickConfiguration);
|
||||||
|
|
||||||
return redirect()->route('project.service', [
|
return redirect()->route('project.service', [
|
||||||
'service_uuid' => $service->uuid,
|
'service_uuid' => $service->uuid,
|
||||||
|
@ -57,7 +57,6 @@ public function saveVariables($isPreview)
|
|||||||
$this->resource->environment_variables()->delete();
|
$this->resource->environment_variables()->delete();
|
||||||
}
|
}
|
||||||
foreach ($variables as $key => $variable) {
|
foreach ($variables as $key => $variable) {
|
||||||
ray($key, $variable);
|
|
||||||
$found = $existingVariables->where('key', $key)->first();
|
$found = $existingVariables->where('key', $key)->first();
|
||||||
if ($found) {
|
if ($found) {
|
||||||
$found->value = $variable;
|
$found->value = $variable;
|
||||||
|
@ -115,7 +115,7 @@ private function sslip(Server $server)
|
|||||||
}
|
}
|
||||||
return "{$server->ip}.sslip.io";
|
return "{$server->ip}.sslip.io";
|
||||||
}
|
}
|
||||||
private function generateFqdn($serviceVariables, $serviceName, Collection $requiredFqdns)
|
private function generateFqdn($serviceVariables, $serviceName, Collection $configuration)
|
||||||
{
|
{
|
||||||
// Add sslip.io to the service
|
// Add sslip.io to the service
|
||||||
$defaultUsableFqdn = null;
|
$defaultUsableFqdn = null;
|
||||||
@ -123,8 +123,8 @@ private function generateFqdn($serviceVariables, $serviceName, Collection $requi
|
|||||||
if (Str::of($serviceVariables)->contains('SERVICE_FQDN') || Str::of($serviceVariables)->contains('SERVICE_URL')) {
|
if (Str::of($serviceVariables)->contains('SERVICE_FQDN') || Str::of($serviceVariables)->contains('SERVICE_URL')) {
|
||||||
$defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$sslip}";
|
$defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$sslip}";
|
||||||
}
|
}
|
||||||
if ($requiredFqdns->count() > 0) {
|
if ($configuration->count() > 0) {
|
||||||
foreach ($requiredFqdns as $requiredFqdn) {
|
foreach ($configuration as $requiredFqdn) {
|
||||||
$requiredFqdn = (array)$requiredFqdn;
|
$requiredFqdn = (array)$requiredFqdn;
|
||||||
$name = data_get($requiredFqdn, 'name');
|
$name = data_get($requiredFqdn, 'name');
|
||||||
$path = data_get($requiredFqdn, 'path');
|
$path = data_get($requiredFqdn, 'path');
|
||||||
@ -139,10 +139,10 @@ private function generateFqdn($serviceVariables, $serviceName, Collection $requi
|
|||||||
}
|
}
|
||||||
return $defaultUsableFqdn ?? null;
|
return $defaultUsableFqdn ?? null;
|
||||||
}
|
}
|
||||||
public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): Collection
|
public function parse(bool $isNew = false, ?Collection $configuration = null): Collection
|
||||||
{
|
{
|
||||||
if (!$requiredFqdns) {
|
if (!$configuration) {
|
||||||
$requiredFqdns = collect([]);
|
$configuration = collect([]);
|
||||||
}
|
}
|
||||||
if ($this->docker_compose_raw) {
|
if ($this->docker_compose_raw) {
|
||||||
try {
|
try {
|
||||||
@ -161,7 +161,7 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
|||||||
$envs = collect([]);
|
$envs = collect([]);
|
||||||
$ports = collect([]);
|
$ports = collect([]);
|
||||||
|
|
||||||
$services = collect($services)->map(function ($service, $serviceName) use ($composeVolumes, $composeNetworks, $definedNetwork, $envs, $volumes, $ports, $isNew, $requiredFqdns) {
|
$services = collect($services)->map(function ($service, $serviceName) use ($composeVolumes, $composeNetworks, $definedNetwork, $envs, $volumes, $ports, $isNew, $configuration) {
|
||||||
$container_name = "$serviceName-{$this->uuid}";
|
$container_name = "$serviceName-{$this->uuid}";
|
||||||
$isDatabase = false;
|
$isDatabase = false;
|
||||||
$serviceVariables = collect(data_get($service, 'environment', []));
|
$serviceVariables = collect(data_get($service, 'environment', []));
|
||||||
@ -207,14 +207,13 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
|||||||
} else {
|
} else {
|
||||||
$savedService = ServiceApplication::create([
|
$savedService = ServiceApplication::create([
|
||||||
'name' => $serviceName,
|
'name' => $serviceName,
|
||||||
'fqdn' => $this->generateFqdn($serviceVariables, $serviceName, $requiredFqdns),
|
'fqdn' => $this->generateFqdn($serviceVariables, $serviceName, $configuration),
|
||||||
'image' => $image,
|
'image' => $image,
|
||||||
'service_id' => $this->id
|
'service_id' => $this->id
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
if ($requiredFqdns->count() > 0) {
|
if ($configuration->count() > 0) {
|
||||||
$found = false;
|
foreach ($configuration as $requiredFqdn) {
|
||||||
foreach ($requiredFqdns as $requiredFqdn) {
|
|
||||||
$requiredFqdn = (array)$requiredFqdn;
|
$requiredFqdn = (array)$requiredFqdn;
|
||||||
$name = data_get($requiredFqdn, 'name');
|
$name = data_get($requiredFqdn, 'name');
|
||||||
if ($serviceName === $name) {
|
if ($serviceName === $name) {
|
||||||
@ -232,7 +231,7 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
|||||||
if (data_get($savedService, 'fqdn')) {
|
if (data_get($savedService, 'fqdn')) {
|
||||||
$defaultUsableFqdn = data_get($savedService, 'fqdn', null);
|
$defaultUsableFqdn = data_get($savedService, 'fqdn', null);
|
||||||
} else {
|
} else {
|
||||||
$defaultUsableFqdn = $this->generateFqdn($serviceVariables, $serviceName, $requiredFqdns);
|
$defaultUsableFqdn = $this->generateFqdn($serviceVariables, $serviceName, $configuration);
|
||||||
}
|
}
|
||||||
$savedService->fqdn = $defaultUsableFqdn;
|
$savedService->fqdn = $defaultUsableFqdn;
|
||||||
$savedService->save();
|
$savedService->save();
|
||||||
@ -389,9 +388,22 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
|||||||
data_set($service, 'networks', $networks);
|
data_set($service, 'networks', $networks);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get variables from the service
|
// Get variables from the service
|
||||||
foreach ($serviceVariables as $variable) {
|
foreach ($serviceVariables as $variable) {
|
||||||
$value = Str::after($variable, '=');
|
$value = Str::after($variable, '=');
|
||||||
|
// if (!Str::of($val)->contains($value)) {
|
||||||
|
// EnvironmentVariable::updateOrCreate([
|
||||||
|
// 'key' => $variable,
|
||||||
|
// 'service_id' => $this->id,
|
||||||
|
// ], [
|
||||||
|
// 'value' => $val,
|
||||||
|
// 'is_build_time' => false,
|
||||||
|
// 'service_id' => $this->id,
|
||||||
|
// 'is_preview' => false,
|
||||||
|
// ]);
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
if (!Str::startsWith($value, '$SERVICE_') && !Str::startsWith($value, '${SERVICE_') && Str::startsWith($value, '$')) {
|
if (!Str::startsWith($value, '$SERVICE_') && !Str::startsWith($value, '${SERVICE_') && Str::startsWith($value, '$')) {
|
||||||
$value = Str::of(replaceVariables(Str::of($value)));
|
$value = Str::of(replaceVariables(Str::of($value)));
|
||||||
$nakedName = $nakedValue = null;
|
$nakedName = $nakedValue = null;
|
||||||
@ -468,7 +480,11 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
|||||||
} else if ($variableName->startsWith('SERVICE_PASSWORD')) {
|
} else if ($variableName->startsWith('SERVICE_PASSWORD')) {
|
||||||
$variableDefined = EnvironmentVariable::whereServiceId($this->id)->where('key', $variableName->value())->first();
|
$variableDefined = EnvironmentVariable::whereServiceId($this->id)->where('key', $variableName->value())->first();
|
||||||
if (!$variableDefined) {
|
if (!$variableDefined) {
|
||||||
|
if ($variableName->startsWith('SERVICE_PASSWORD64')) {
|
||||||
|
$generatedValue = Str::password(length: 64, symbols: false);
|
||||||
|
} else {
|
||||||
$generatedValue = Str::password(symbols: false);
|
$generatedValue = Str::password(symbols: false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$generatedValue = $variableDefined->value;
|
$generatedValue = $variableDefined->value;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
ghost:
|
ghost:
|
||||||
documentation: https://ghost.org/docs/config
|
|
||||||
image: ghost:5
|
image: ghost:5
|
||||||
volumes:
|
volumes:
|
||||||
- ghost-content-data:/var/lib/ghost/content
|
- ghost-content-data:/var/lib/ghost/content
|
||||||
- type: volume
|
|
||||||
source: /data/g
|
|
||||||
target: /data
|
|
||||||
volume:
|
|
||||||
nocopy: true
|
|
||||||
environment:
|
environment:
|
||||||
- url=$SERVICE_FQDN_GHOST
|
- url=$SERVICE_FQDN_GHOST
|
||||||
- database__client=mysql
|
- database__client=mysql
|
||||||
@ -16,24 +10,9 @@ services:
|
|||||||
- database__connection__user=$SERVICE_USER_MYSQL
|
- database__connection__user=$SERVICE_USER_MYSQL
|
||||||
- database__connection__password=$SERVICE_PASSWORD_MYSQL
|
- database__connection__password=$SERVICE_PASSWORD_MYSQL
|
||||||
- database__connection__database=${MYSQL_DATABASE-ghost}
|
- database__connection__database=${MYSQL_DATABASE-ghost}
|
||||||
networks:
|
|
||||||
default:
|
|
||||||
aliases:
|
|
||||||
- alias1
|
|
||||||
- alias3
|
|
||||||
ipv4_address: 172.16.238.10
|
|
||||||
ipv6_address: 2001:3984:3989::10
|
|
||||||
ports:
|
|
||||||
- "2368"
|
|
||||||
- 1234:2368
|
|
||||||
- target: 2368
|
|
||||||
published: 1234
|
|
||||||
protocol: tcp
|
|
||||||
mode: host
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql
|
- mysql
|
||||||
mysql:
|
mysql:
|
||||||
documentation: https://hub.docker.com/_/mysql
|
|
||||||
image: mysql:8.0
|
image: mysql:8.0
|
||||||
volumes:
|
volumes:
|
||||||
- ghost-mysql-data:/var/lib/mysql
|
- ghost-mysql-data:/var/lib/mysql
|
||||||
@ -42,10 +21,3 @@ services:
|
|||||||
- MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL}
|
- MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL}
|
||||||
- MYSQL_DATABASE=${MYSQL_DATABASE}
|
- MYSQL_DATABASE=${MYSQL_DATABASE}
|
||||||
- MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQL_ROOT}
|
- MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQL_ROOT}
|
||||||
networks:
|
|
||||||
default:
|
|
||||||
ipam:
|
|
||||||
driver: default
|
|
||||||
config:
|
|
||||||
- subnet: "172.16.238.0/24"
|
|
||||||
- subnet: "2001:3984:3989::/64"
|
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user