This commit is contained in:
Andras Bacsai
2022-10-25 22:43:31 +02:00
parent b0fcd23ca6
commit 111bd29cc8
3 changed files with 12 additions and 13 deletions

View File

@@ -1892,8 +1892,8 @@
- '9001' - '9001'
proxy: proxy:
- port: '9000' - port: '9000'
- port: '9001'
domain: $$coolify_fqdn_minio_console domain: $$coolify_fqdn_minio_console
- port: '9001'
variables: variables:
- id: $$coolify_fqdn_minio_console - id: $$coolify_fqdn_minio_console
name: MINIO_SERVER_URL name: MINIO_SERVER_URL

View File

@@ -41,10 +41,14 @@ export async function cleanupManually(request: FastifyRequest) {
export async function refreshTemplates() { export async function refreshTemplates() {
try { try {
const { default: got } = await import('got') const { default: got } = await import('got')
let templates = {}
try { try {
if (isDev) {
const response = await fs.readFile('./devTemplates.yaml', 'utf8')
await fs.writeFile('./template.json', JSON.stringify(yaml.load(response), null, 2))
} else {
const response = await got.get('https://get.coollabs.io/coolify/service-templates.yaml').text() const response = await got.get('https://get.coollabs.io/coolify/service-templates.yaml').text()
templates = yaml.load(response) await fs.writeFile('/app/template.json', JSON.stringify(yaml.load(response), null, 2))
}
} catch (error) { } catch (error) {
throw { throw {
status: 500, status: 500,
@@ -52,11 +56,6 @@ export async function refreshTemplates() {
}; };
} }
if (isDev) {
await fs.writeFile('./template.json', JSON.stringify(templates, null, 2))
} else {
await fs.writeFile('/app/template.json', JSON.stringify(templates, null, 2))
}
return {}; return {};
} catch ({ status, message }) { } catch ({ status, message }) {
return errorHandler({ status, message }); return errorHandler({ status, message });

View File

@@ -20,7 +20,7 @@ function generateLoadBalancerService(id, port) {
function generateHttpRouter(id, nakedDomain, pathPrefix) { function generateHttpRouter(id, nakedDomain, pathPrefix) {
return { return {
entrypoints: ['web'], entrypoints: ['web'],
rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`)) && PathPrefix(\`${pathPrefix}\`)`, rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`))${pathPrefix ? `&& PathPrefix(\`${pathPrefix}\`)` : ''}`,
service: `${id}`, service: `${id}`,
middlewares: [] middlewares: []
} }
@@ -29,7 +29,7 @@ function generateProtocolRedirectRouter(id, nakedDomain, pathPrefix, fromTo) {
if (fromTo === 'https-to-http') { if (fromTo === 'https-to-http') {
return { return {
entrypoints: ['websecure'], entrypoints: ['websecure'],
rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`)) && PathPrefix(\`${pathPrefix}\`)`, rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`))${pathPrefix ? `&& PathPrefix(\`${pathPrefix}\`)` : ''}`,
service: `${id}`, service: `${id}`,
tls: { tls: {
domains: { domains: {
@@ -41,7 +41,7 @@ function generateProtocolRedirectRouter(id, nakedDomain, pathPrefix, fromTo) {
} else if (fromTo === 'http-to-https') { } else if (fromTo === 'http-to-https') {
return { return {
entrypoints: ['web'], entrypoints: ['web'],
rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`)) && PathPrefix(\`${pathPrefix}\`)`, rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`))${pathPrefix ? `&& PathPrefix(\`${pathPrefix}\`)` : ''}`,
service: `${id}`, service: `${id}`,
middlewares: ['redirect-to-https'] middlewares: ['redirect-to-https']
}; };
@@ -409,7 +409,7 @@ export async function traefikConfiguration(request, reply) {
} }
} }
for (const service of data.services) { for (const service of data.services) {
let { id, fqdn, dualCerts, configuration: { port, pathPrefix = '/', domain: customDomain }, isCustomSSL = false } = service let { id, fqdn, dualCerts, configuration: { port, pathPrefix, domain: customDomain }, isCustomSSL = false } = service
if (customDomain) { if (customDomain) {
fqdn = customDomain fqdn = customDomain
} }