fix: env variables in compose deplyoments

This commit is contained in:
Andras Bacsai
2023-07-27 12:40:58 +02:00
parent 807a3c9d66
commit 1c8c567791

View File

@@ -52,29 +52,36 @@ export default async function (data) {
} }
let environment = typeof value['environment'] === 'undefined' ? [] : value['environment']; let environment = typeof value['environment'] === 'undefined' ? [] : value['environment'];
let finalEnvs = [...envs];
if (Object.keys(environment).length > 0) { if (Object.keys(environment).length > 0) {
environment = Object.entries(environment).map(([key, value]) => `${key}=${value}`); for (const arg of Object.keys(environment)) {
const [key, _] = arg.split('=');
if (finalEnvs.filter((env) => env.startsWith(key)).length === 0) {
finalEnvs.push(arg);
} }
value['environment'] = [...environment, ...envs]; }
// environment = Object.entries(environment).map(([key, value]) => `${key}=${value}`);
}
value['environment'] = [...finalEnvs];
let build = typeof value['build'] === 'undefined' ? [] : value['build']; let build = typeof value['build'] === 'undefined' ? [] : value['build'];
if (typeof build === 'string') { if (typeof build === 'string') {
build = { context: build }; build = { context: build };
} }
const buildArgs = typeof build['args'] === 'undefined' ? [] : build['args']; const buildArgs = typeof build['args'] === 'undefined' ? [] : build['args'];
let finalArgs = [...buildEnvs]; let finalBuildArgs = [...buildEnvs];
if (Object.keys(buildArgs).length > 0) { if (Object.keys(buildArgs).length > 0) {
for (const arg of Object.keys(buildArgs)) { for (const arg of Object.keys(buildArgs)) {
const [key, _] = arg.split('='); const [key, _] = arg.split('=');
if (finalArgs.filter((env) => env.startsWith(key)).length === 0) { if (finalBuildArgs.filter((env) => env.startsWith(key)).length === 0) {
finalArgs.push(arg); finalBuildArgs.push(arg);
} }
} }
} }
if (build.length > 0 || buildArgs.length > 0) { if (build.length > 0 || buildArgs.length > 0) {
value['build'] = { value['build'] = {
...build, ...build,
args: finalArgs args: finalBuildArgs
}; };
} }
@@ -121,7 +128,6 @@ export default async function (data) {
.replace(/^\./, `~`) .replace(/^\./, `~`)
.replace(/^\.\./, '~') .replace(/^\.\./, '~')
.replace(/^\$PWD/, '~'); .replace(/^\$PWD/, '~');
console.log({ source });
} else { } else {
if (!target) { if (!target) {
target = source; target = source;