mirror of
https://github.com/LukeHagar/dokploy.git
synced 2025-12-10 12:27:49 +00:00
Merge pull request #1983 from TorstenDittmann/fix-railpack-env-vars
fix[railpack]: env parsing and update railpack to v0.0.66
This commit is contained in:
@@ -2,7 +2,10 @@ import { createHash } from "node:crypto";
|
|||||||
import type { WriteStream } from "node:fs";
|
import type { WriteStream } from "node:fs";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
import type { ApplicationNested } from ".";
|
import type { ApplicationNested } from ".";
|
||||||
import { prepareEnvironmentVariables } from "../docker/utils";
|
import {
|
||||||
|
parseEnvironmentKeyValuePair,
|
||||||
|
prepareEnvironmentVariables,
|
||||||
|
} from "../docker/utils";
|
||||||
import { getBuildAppDirectory } from "../filesystem/directory";
|
import { getBuildAppDirectory } from "../filesystem/directory";
|
||||||
import { execAsync } from "../process/execAsync";
|
import { execAsync } from "../process/execAsync";
|
||||||
import { spawnAsync } from "../process/spawnAsync";
|
import { spawnAsync } from "../process/spawnAsync";
|
||||||
@@ -81,10 +84,10 @@ export const buildRailpack = async (
|
|||||||
|
|
||||||
// Add secrets properly formatted
|
// Add secrets properly formatted
|
||||||
const env: { [key: string]: string } = {};
|
const env: { [key: string]: string } = {};
|
||||||
for (const envVar of envVariables) {
|
for (const pair of envVariables) {
|
||||||
const [key, value] = envVar.split("=");
|
const [key, value] = parseEnvironmentKeyValuePair(pair);
|
||||||
if (key && value) {
|
if (key && value) {
|
||||||
buildArgs.push("--secret", `id=${key},env='${key}'`);
|
buildArgs.push("--secret", `id=${key},env=${key}`);
|
||||||
env[key] = value;
|
env[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,11 +164,11 @@ export const getRailpackCommand = (
|
|||||||
|
|
||||||
// Add secrets properly formatted
|
// Add secrets properly formatted
|
||||||
const exportEnvs = [];
|
const exportEnvs = [];
|
||||||
for (const envVar of envVariables) {
|
for (const pair of envVariables) {
|
||||||
const [key, value] = envVar.split("=");
|
const [key, value] = parseEnvironmentKeyValuePair(pair);
|
||||||
if (key && value) {
|
if (key && value) {
|
||||||
buildArgs.push("--secret", `id=${key},env='${key}'`);
|
buildArgs.push("--secret", `id=${key},env=${key}`);
|
||||||
exportEnvs.push(`export ${key}=${value}`);
|
exportEnvs.push(`export ${key}='${value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -279,6 +279,17 @@ export const prepareEnvironmentVariables = (
|
|||||||
return resolvedVars;
|
return resolvedVars;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const parseEnvironmentKeyValuePair = (
|
||||||
|
pair: string,
|
||||||
|
): [string, string] => {
|
||||||
|
const [key, ...valueParts] = pair.split("=");
|
||||||
|
if (!key || !valueParts.length) {
|
||||||
|
throw new Error(`Invalid environment variable pair: ${pair}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [key, valueParts.join("")];
|
||||||
|
};
|
||||||
|
|
||||||
export const getEnviromentVariablesObject = (
|
export const getEnviromentVariablesObject = (
|
||||||
input: string | null,
|
input: string | null,
|
||||||
projectEnv?: string | null,
|
projectEnv?: string | null,
|
||||||
@@ -288,7 +299,7 @@ export const getEnviromentVariablesObject = (
|
|||||||
const jsonObject: Record<string, string> = {};
|
const jsonObject: Record<string, string> = {};
|
||||||
|
|
||||||
for (const pair of envs) {
|
for (const pair of envs) {
|
||||||
const [key, value] = pair.split("=");
|
const [key, value] = parseEnvironmentKeyValuePair(pair);
|
||||||
if (key && value) {
|
if (key && value) {
|
||||||
jsonObject[key] = value;
|
jsonObject[key] = value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user