fix: export envreuse download environment (#1132)

This commit is contained in:
Lyon
2026-06-13 17:20:44 +08:00
committed by GitHub
parent ea3b26b895
commit b8e92f669a
+4 -4
View File
@@ -867,7 +867,7 @@ function dockerfile(baseImage, port, labels = []) {
function envReuseDockerfile(baseImage, labels = [], recipe, service = null) { function envReuseDockerfile(baseImage, labels = [], recipe, service = null) {
const normalizedRecipe = normalizeEnvReuseRecipe(recipe); const normalizedRecipe = normalizeEnvReuseRecipe(recipe);
const runtimeRoot = normalizedRecipe.runtimeNodeModulesPath.replace(/\/node_modules$/u, ""); const runtimeRoot = normalizedRecipe.runtimeNodeModulesPath.replace(/\/node_modules$/u, "");
const downloadEnvPrefix = shellEnvPrefix(downloadEnvPairs(normalizedRecipe.downloadStack)); const downloadEnvPrefix = shellExportPrefix(downloadEnvPairs(normalizedRecipe.downloadStack));
const npmConfigScript = npmDownloadConfigScript(normalizedRecipe.downloadStack); const npmConfigScript = npmDownloadConfigScript(normalizedRecipe.downloadStack);
const goService = service?.runtimeKind === "go-service" || service?.artifactKind === "go-service"; const goService = service?.runtimeKind === "go-service" || service?.artifactKind === "go-service";
const goCacheEnabled = Boolean(goService && normalizedRecipe.runtimeGoModCachePath && normalizedRecipe.runtimeGoBuildCachePath); const goCacheEnabled = Boolean(goService && normalizedRecipe.runtimeGoModCachePath && normalizedRecipe.runtimeGoBuildCachePath);
@@ -878,7 +878,7 @@ function envReuseDockerfile(baseImage, labels = [], recipe, service = null) {
`ENV GOPROXY=${goProxy}`, `ENV GOPROXY=${goProxy}`,
`ENV GOTOOLCHAIN=${normalizedRecipe.goToolchain || "local"}` `ENV GOTOOLCHAIN=${normalizedRecipe.goToolchain || "local"}`
] : []; ] : [];
const goBuildEnvPrefix = goCacheEnabled ? shellEnvPrefix([ const goBuildEnvPrefix = goCacheEnabled ? shellExportPrefix([
["GOMODCACHE", normalizedRecipe.runtimeGoModCachePath], ["GOMODCACHE", normalizedRecipe.runtimeGoModCachePath],
["GOCACHE", normalizedRecipe.runtimeGoBuildCachePath], ["GOCACHE", normalizedRecipe.runtimeGoBuildCachePath],
["GOPROXY", goProxy], ["GOPROXY", goProxy],
@@ -1019,8 +1019,8 @@ function downloadEnvPairs(stack) {
].filter(([, value]) => value); ].filter(([, value]) => value);
} }
function shellEnvPrefix(pairs) { function shellExportPrefix(pairs) {
return pairs.length === 0 ? "" : `${pairs.map(([name, value]) => `${name}=${shellQuote(value)}`).join(" ")} `; return pairs.length === 0 ? "" : `export ${pairs.map(([name, value]) => `${name}=${shellQuote(value)}`).join(" ")}; `;
} }
function npmDownloadConfigScript(stack) { function npmDownloadConfigScript(stack) {