Merge pull request #112 from pa-sowa/traefik
Support traefik labels for URL configuration
This commit is contained in:
commit
85ee5da025
1 changed files with 27 additions and 1 deletions
|
@ -96,7 +96,33 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
|
||||||
containers = containers.filter((e) => Object.keys(e.Labels).length !== 0);
|
containers = containers.filter((e) => Object.keys(e.Labels).length !== 0);
|
||||||
const dockerApps = [];
|
const dockerApps = [];
|
||||||
for (const container of containers) {
|
for (const container of containers) {
|
||||||
const labels = container.Labels;
|
let labels = container.Labels;
|
||||||
|
|
||||||
|
if (!('flame.url' in labels)) {
|
||||||
|
for (const label of Object.keys(labels)) {
|
||||||
|
if (/^traefik.*.frontend.rule/.test(label)) {
|
||||||
|
// Traefik 1.x
|
||||||
|
let value = labels[label];
|
||||||
|
if (value.indexOf('Host') !== -1) {
|
||||||
|
value = value.split('Host:')[1];
|
||||||
|
labels['flame.url'] = 'https://' + value.split(',').join(';https://');
|
||||||
|
}
|
||||||
|
} else if (/^traefik.*?\.rule/.test(label)) {
|
||||||
|
// Traefik 2.x
|
||||||
|
const value = labels[label];
|
||||||
|
if (value.indexOf('Host') !== -1) {
|
||||||
|
const regex = /\`([a-zA-Z0-9\.\-]+)\`/g;
|
||||||
|
const domains = []
|
||||||
|
while ((match = regex.exec(value)) != null) {
|
||||||
|
domains.push('http://' + match[1]);
|
||||||
|
}
|
||||||
|
if (domains.length > 0) {
|
||||||
|
labels['flame.url'] = domains.join(';');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
'flame.name' in labels &&
|
'flame.name' in labels &&
|
||||||
|
|
Loading…
Reference in a new issue