perf(platform-infra): compress local Compose artifact

This commit is contained in:
Codex
2026-07-13 15:37:04 +02:00
parent 41356493d6
commit 773dea7eb8
+11 -4
View File
@@ -328,7 +328,7 @@ async function apply(config: UniDeskConfig, options: OpsApplyOptions): Promise<R
try {
const remoteScript = applyRemoteScript(nginx, target, compose, {
image: `${distribution.publicBaseUrl}/${fileName(distributedImage)}`,
composePlugin: `${distribution.publicBaseUrl}/${fileName(distributedPlugin)}`,
composePlugin: `${distribution.publicBaseUrl}/${fileName(distributedPlugin)}.gz`,
});
const start = await capture(
config,
@@ -416,7 +416,11 @@ async function startLocalArtifactSource(
rmSync(distribution.workDir, { recursive: true, force: true });
mkdirSync(distribution.workDir, { recursive: true, mode: 0o755 });
symlinkSync(config.artifacts.image.localPath, imageLink);
symlinkSync(config.artifacts.composePlugin.localPath, pluginLink);
writeFileSync(
`${pluginLink}.gz`,
gzipSync(readFileSync(config.artifacts.composePlugin.localPath), { level: 1 }),
{ mode: 0o644 },
);
const child = spawn(
"python3",
[
@@ -570,6 +574,7 @@ function applyRemoteScript(
return `set -eu
image_artifact=${shQuote(config.artifacts.image.remotePath)}
plugin=${shQuote(config.artifacts.composePlugin.remotePath)}
plugin_archive="$plugin.gz"
env_file=${shQuote(target.runtime.envPath)}
compose_file=${shQuote(target.runtime.composePath)}
log_file=${shQuote(`${target.runtime.logDir}/requests.jsonl`)}
@@ -590,9 +595,11 @@ if [ "$image_sha" != ${shQuote(config.artifacts.image.sha256)} ]; then
curl -fsSL --retry 2 --connect-timeout 5 --max-time 3600 \
${shQuote(artifactUrls.image)} -o "$image_artifact"
fi
rm -f "$plugin"
rm -f "$plugin" "$plugin_archive"
curl -fsSL --retry 2 --connect-timeout 5 --max-time 3600 \
${shQuote(artifactUrls.composePlugin)} -o "$plugin"
${shQuote(artifactUrls.composePlugin)} -o "$plugin_archive"
gzip -dc "$plugin_archive" > "$plugin"
rm -f "$plugin_archive"
[ "$(sha256sum "$image_artifact" | awk '{print $1}')" = ${shQuote(config.artifacts.image.sha256)} ]
[ "$(sha256sum "$plugin" | awk '{print $1}')" = ${shQuote(config.artifacts.composePlugin.sha256)} ]
chmod 0755 "$plugin"