fix: no variables in template

feat: hostPort proxy conf from template
This commit is contained in:
Andras Bacsai
2022-11-18 14:28:05 +01:00
parent ca05828b68
commit aac6981304
10 changed files with 220 additions and 102 deletions

View File

@@ -11,7 +11,7 @@ import { promises as dns } from 'dns';
import { PrismaClient } from '@prisma/client';
import os from 'os';
import sshConfig from 'ssh-config';
import jsonwebtoken from 'jsonwebtoken';
import { checkContainer, removeContainer } from './docker';
import { day } from './dayjs';
import { saveBuildLog } from './buildPacks/common';
@@ -722,6 +722,11 @@ export async function listSettings(): Promise<any> {
return settings;
}
export function generateToken() {
return jsonwebtoken.sign({
nbf: Math.floor(Date.now() / 1000) - 30,
}, process.env['COOLIFY_SECRET_KEY'])
}
export function generatePassword({
length = 24,
symbols = false,
@@ -1614,7 +1619,7 @@ export function persistentVolumes(id, persistentStorage, config) {
for (const [key, value] of Object.entries(config)) {
if (value.volumes) {
for (const volume of value.volumes) {
if (!volume.startsWith('/var/run/docker.sock')) {
if (!volume.startsWith('/')) {
volumeSet.add(volume);
}
}

View File

@@ -103,9 +103,19 @@ export async function startService(request: FastifyRequest<ServiceStartStop>, fa
}
}
}
let port = null
if (template.services[s].ports?.length > 0) {
port = template.services[s].ports[0]
let ports = []
if (template.services[s].proxy?.length > 0) {
for (const proxy of template.services[s].proxy) {
if (proxy.hostPort) {
ports.push(`${proxy.hostPort}:${proxy.port}`)
}
}
} else {
if (template.services[s].ports?.length === 1) {
for (const port of template.services[s].ports) {
ports.push(`${exposePort}:${exposePort}`)
}
}
}
let image = template.services[s].image
if (arm && template.services[s].imageArm) {
@@ -118,7 +128,7 @@ export async function startService(request: FastifyRequest<ServiceStartStop>, fa
entrypoint: template.services[s]?.entrypoint,
image,
expose: template.services[s].ports,
...(exposePort && port ? { ports: [`${exposePort}:${port}`] } : {}),
ports,
volumes: Array.from(volumes),
environment: newEnvironments,
depends_on: template.services[s]?.depends_on,
@@ -128,7 +138,6 @@ export async function startService(request: FastifyRequest<ServiceStartStop>, fa
labels: makeLabelForServices(type),
...defaultComposeConfiguration(network),
}
// Generate files for builds
if (template.services[s]?.files?.length > 0) {
if (!config[s].build) {
@@ -182,7 +191,6 @@ export async function startService(request: FastifyRequest<ServiceStartStop>, fa
`docker container ls -a --filter 'name=${id}-' --format {{.ID}}|xargs -r -n 1 docker container rm -f`
});
} catch (error) { }
}
return {}
} catch ({ status, message }) {