perf(platform-infra): compress local Compose artifact
This commit is contained in:
@@ -328,7 +328,7 @@ async function apply(config: UniDeskConfig, options: OpsApplyOptions): Promise<R
|
|||||||
try {
|
try {
|
||||||
const remoteScript = applyRemoteScript(nginx, target, compose, {
|
const remoteScript = applyRemoteScript(nginx, target, compose, {
|
||||||
image: `${distribution.publicBaseUrl}/${fileName(distributedImage)}`,
|
image: `${distribution.publicBaseUrl}/${fileName(distributedImage)}`,
|
||||||
composePlugin: `${distribution.publicBaseUrl}/${fileName(distributedPlugin)}`,
|
composePlugin: `${distribution.publicBaseUrl}/${fileName(distributedPlugin)}.gz`,
|
||||||
});
|
});
|
||||||
const start = await capture(
|
const start = await capture(
|
||||||
config,
|
config,
|
||||||
@@ -416,7 +416,11 @@ async function startLocalArtifactSource(
|
|||||||
rmSync(distribution.workDir, { recursive: true, force: true });
|
rmSync(distribution.workDir, { recursive: true, force: true });
|
||||||
mkdirSync(distribution.workDir, { recursive: true, mode: 0o755 });
|
mkdirSync(distribution.workDir, { recursive: true, mode: 0o755 });
|
||||||
symlinkSync(config.artifacts.image.localPath, imageLink);
|
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(
|
const child = spawn(
|
||||||
"python3",
|
"python3",
|
||||||
[
|
[
|
||||||
@@ -570,6 +574,7 @@ function applyRemoteScript(
|
|||||||
return `set -eu
|
return `set -eu
|
||||||
image_artifact=${shQuote(config.artifacts.image.remotePath)}
|
image_artifact=${shQuote(config.artifacts.image.remotePath)}
|
||||||
plugin=${shQuote(config.artifacts.composePlugin.remotePath)}
|
plugin=${shQuote(config.artifacts.composePlugin.remotePath)}
|
||||||
|
plugin_archive="$plugin.gz"
|
||||||
env_file=${shQuote(target.runtime.envPath)}
|
env_file=${shQuote(target.runtime.envPath)}
|
||||||
compose_file=${shQuote(target.runtime.composePath)}
|
compose_file=${shQuote(target.runtime.composePath)}
|
||||||
log_file=${shQuote(`${target.runtime.logDir}/requests.jsonl`)}
|
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 \
|
curl -fsSL --retry 2 --connect-timeout 5 --max-time 3600 \
|
||||||
${shQuote(artifactUrls.image)} -o "$image_artifact"
|
${shQuote(artifactUrls.image)} -o "$image_artifact"
|
||||||
fi
|
fi
|
||||||
rm -f "$plugin"
|
rm -f "$plugin" "$plugin_archive"
|
||||||
curl -fsSL --retry 2 --connect-timeout 5 --max-time 3600 \
|
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 "$image_artifact" | awk '{print $1}')" = ${shQuote(config.artifacts.image.sha256)} ]
|
||||||
[ "$(sha256sum "$plugin" | awk '{print $1}')" = ${shQuote(config.artifacts.composePlugin.sha256)} ]
|
[ "$(sha256sum "$plugin" | awk '{print $1}')" = ${shQuote(config.artifacts.composePlugin.sha256)} ]
|
||||||
chmod 0755 "$plugin"
|
chmod 0755 "$plugin"
|
||||||
|
|||||||
Reference in New Issue
Block a user