This commit is contained in:
Andras Bacsai
2022-10-21 22:05:05 +02:00
parent 221dcefd6c
commit 35625b22f5
2 changed files with 6 additions and 6 deletions

View File

@@ -13,7 +13,6 @@ export async function migrateServicesToNewTemplate(templates: any) {
} }
let template = templates.find(t => t.name.toLowerCase() === service.type.toLowerCase()); let template = templates.find(t => t.name.toLowerCase() === service.type.toLowerCase());
if (template) { if (template) {
console.log(template.variables.find(v => v.name === "_APP_REDIS_HOST"))
template = JSON.parse(JSON.stringify(template).replaceAll('$$id', service.id)) template = JSON.parse(JSON.stringify(template).replaceAll('$$id', service.id))
if (service.type === 'plausibleanalytics' && service.plausibleAnalytics) await plausibleAnalytics(service, template) if (service.type === 'plausibleanalytics' && service.plausibleAnalytics) await plausibleAnalytics(service, template)
if (service.type === 'fider' && service.fider) await fider(service, template) if (service.type === 'fider' && service.fider) await fider(service, template)

View File

@@ -700,11 +700,11 @@ export async function startService(request: FastifyRequest<ServiceStartStop>) {
const network = destinationDockerId && destinationDocker.network; const network = destinationDockerId && destinationDocker.network;
const config = {}; const config = {};
for (const service in template.services) { for (const service in template.services) {
let newEnviroments = [] let newEnvironments = []
for (const environment of template.services[service].environment) { for (const environment of template.services[service].environment) {
const [env, value] = environment.split("="); const [env, value] = environment.split("=");
if (!value.startsWith('$$secret') && value !== '') { if (!value.startsWith('$$secret') && value !== '') {
newEnviroments.push(`${env}=${value}`) newEnvironments.push(`${env}=${value}`)
} }
} }
@@ -712,8 +712,8 @@ export async function startService(request: FastifyRequest<ServiceStartStop>) {
for (const secret of secrets) { for (const secret of secrets) {
const { name, value } = secret const { name, value } = secret
if (value) { if (value) {
if (template.services[service].environment.find(env => env.startsWith(`${name}=`)) && !newEnviroments.find(env => env.startsWith(`${name}=`))) { if (template.services[service].environment.find(env => env.startsWith(`${name}=`)) && !newEnvironments.find(env => env.startsWith(`${name}=`))) {
newEnviroments.push(`${name}=${decrypt(value)}`) newEnvironments.push(`${name}=${decrypt(value)}`)
} }
} }
} }
@@ -726,7 +726,7 @@ export async function startService(request: FastifyRequest<ServiceStartStop>) {
expose: template.services[service].ports, expose: template.services[service].ports,
// ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), // ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
volumes: template.services[service].volumes, volumes: template.services[service].volumes,
environment: newEnviroments, environment: newEnvironments,
depends_on: template.services[service]?.depends_on, depends_on: template.services[service]?.depends_on,
ulimits: template.services[service]?.ulimits, ulimits: template.services[service]?.ulimits,
cap_drop: template.services[service]?.cap_drop, cap_drop: template.services[service]?.cap_drop,
@@ -766,6 +766,7 @@ export async function startService(request: FastifyRequest<ServiceStartStop>) {
volumes: volumeMounts volumes: volumeMounts
} }
const composeFileDestination = `${workdir}/docker-compose.yaml`; const composeFileDestination = `${workdir}/docker-compose.yaml`;
console.log(composeFileDestination)
await fs.writeFile(composeFileDestination, yaml.dump(composeFile)); await fs.writeFile(composeFileDestination, yaml.dump(composeFile));
await startServiceContainers(destinationDocker.id, composeFileDestination) await startServiceContainers(destinationDocker.id, composeFileDestination)
return {} return {}