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();
|
||||
$oneClickService = data_get($services, "$oneClickServiceName.compose");
|
||||
$oneClickDotEnvs = data_get($services, "$oneClickServiceName.envs", null);
|
||||
$oneClickRequiredFqdn = data_get($services, "$oneClickServiceName.generateFqdn", []);
|
||||
$oneClickRequiredFqdn = collect($oneClickRequiredFqdn);
|
||||
$oneClickConfiguration = data_get($services, "$oneClickServiceName.configuration.proxy", []);
|
||||
$oneClickConfiguration = collect($oneClickConfiguration);
|
||||
if ($oneClickDotEnvs) {
|
||||
$oneClickDotEnvs = Str::of(base64_decode($oneClickDotEnvs))->split('/\r\n|\r|\n/');
|
||||
}
|
||||
@ -94,6 +94,9 @@ public function new()
|
||||
if ($value->contains('SERVICE_PASSWORD')) {
|
||||
$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')) {
|
||||
$length = Str::of($value)->after('SERVICE_BASE64_')->beforeLast('_')->value();
|
||||
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', [
|
||||
'service_uuid' => $service->uuid,
|
||||
|
@ -57,7 +57,6 @@ public function saveVariables($isPreview)
|
||||
$this->resource->environment_variables()->delete();
|
||||
}
|
||||
foreach ($variables as $key => $variable) {
|
||||
ray($key, $variable);
|
||||
$found = $existingVariables->where('key', $key)->first();
|
||||
if ($found) {
|
||||
$found->value = $variable;
|
||||
|
@ -115,7 +115,7 @@ private function sslip(Server $server)
|
||||
}
|
||||
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
|
||||
$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')) {
|
||||
$defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$sslip}";
|
||||
}
|
||||
if ($requiredFqdns->count() > 0) {
|
||||
foreach ($requiredFqdns as $requiredFqdn) {
|
||||
if ($configuration->count() > 0) {
|
||||
foreach ($configuration as $requiredFqdn) {
|
||||
$requiredFqdn = (array)$requiredFqdn;
|
||||
$name = data_get($requiredFqdn, 'name');
|
||||
$path = data_get($requiredFqdn, 'path');
|
||||
@ -139,10 +139,10 @@ private function generateFqdn($serviceVariables, $serviceName, Collection $requi
|
||||
}
|
||||
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) {
|
||||
$requiredFqdns = collect([]);
|
||||
if (!$configuration) {
|
||||
$configuration = collect([]);
|
||||
}
|
||||
if ($this->docker_compose_raw) {
|
||||
try {
|
||||
@ -161,7 +161,7 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
||||
$envs = 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}";
|
||||
$isDatabase = false;
|
||||
$serviceVariables = collect(data_get($service, 'environment', []));
|
||||
@ -207,14 +207,13 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
||||
} else {
|
||||
$savedService = ServiceApplication::create([
|
||||
'name' => $serviceName,
|
||||
'fqdn' => $this->generateFqdn($serviceVariables, $serviceName, $requiredFqdns),
|
||||
'fqdn' => $this->generateFqdn($serviceVariables, $serviceName, $configuration),
|
||||
'image' => $image,
|
||||
'service_id' => $this->id
|
||||
]);
|
||||
}
|
||||
if ($requiredFqdns->count() > 0) {
|
||||
$found = false;
|
||||
foreach ($requiredFqdns as $requiredFqdn) {
|
||||
if ($configuration->count() > 0) {
|
||||
foreach ($configuration as $requiredFqdn) {
|
||||
$requiredFqdn = (array)$requiredFqdn;
|
||||
$name = data_get($requiredFqdn, 'name');
|
||||
if ($serviceName === $name) {
|
||||
@ -232,7 +231,7 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
||||
if (data_get($savedService, 'fqdn')) {
|
||||
$defaultUsableFqdn = data_get($savedService, 'fqdn', null);
|
||||
} else {
|
||||
$defaultUsableFqdn = $this->generateFqdn($serviceVariables, $serviceName, $requiredFqdns);
|
||||
$defaultUsableFqdn = $this->generateFqdn($serviceVariables, $serviceName, $configuration);
|
||||
}
|
||||
$savedService->fqdn = $defaultUsableFqdn;
|
||||
$savedService->save();
|
||||
@ -389,9 +388,22 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
||||
data_set($service, 'networks', $networks);
|
||||
|
||||
|
||||
|
||||
// Get variables from the service
|
||||
foreach ($serviceVariables as $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, '$')) {
|
||||
$value = Str::of(replaceVariables(Str::of($value)));
|
||||
$nakedName = $nakedValue = null;
|
||||
@ -468,7 +480,11 @@ public function parse(bool $isNew = false, ?Collection $requiredFqdns = null): C
|
||||
} else if ($variableName->startsWith('SERVICE_PASSWORD')) {
|
||||
$variableDefined = EnvironmentVariable::whereServiceId($this->id)->where('key', $variableName->value())->first();
|
||||
if (!$variableDefined) {
|
||||
if ($variableName->startsWith('SERVICE_PASSWORD64')) {
|
||||
$generatedValue = Str::password(length: 64, symbols: false);
|
||||
} else {
|
||||
$generatedValue = Str::password(symbols: false);
|
||||
}
|
||||
} else {
|
||||
$generatedValue = $variableDefined->value;
|
||||
}
|
||||
|
@ -1,14 +1,8 @@
|
||||
services:
|
||||
ghost:
|
||||
documentation: https://ghost.org/docs/config
|
||||
image: ghost:5
|
||||
volumes:
|
||||
- ghost-content-data:/var/lib/ghost/content
|
||||
- type: volume
|
||||
source: /data/g
|
||||
target: /data
|
||||
volume:
|
||||
nocopy: true
|
||||
environment:
|
||||
- url=$SERVICE_FQDN_GHOST
|
||||
- database__client=mysql
|
||||
@ -16,24 +10,9 @@ services:
|
||||
- database__connection__user=$SERVICE_USER_MYSQL
|
||||
- database__connection__password=$SERVICE_PASSWORD_MYSQL
|
||||
- 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:
|
||||
- mysql
|
||||
mysql:
|
||||
documentation: https://hub.docker.com/_/mysql
|
||||
image: mysql:8.0
|
||||
volumes:
|
||||
- ghost-mysql-data:/var/lib/mysql
|
||||
@ -42,10 +21,3 @@ services:
|
||||
- MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL}
|
||||
- MYSQL_DATABASE=${MYSQL_DATABASE}
|
||||
- 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