perf: reuse selfmedia build environment
This commit is contained in:
@@ -33,6 +33,12 @@ export interface SelfMediaDeliveryTarget {
|
||||
readonly dockerfile: string;
|
||||
readonly imageRepository: string;
|
||||
readonly networkMode: string;
|
||||
readonly envReuse: {
|
||||
readonly enabled: true;
|
||||
readonly mode: "buildkit-state-host-path";
|
||||
readonly statePath: string;
|
||||
readonly identityFiles: readonly string[];
|
||||
};
|
||||
readonly proxy: Record<string, unknown>;
|
||||
};
|
||||
readonly gitops: Record<string, unknown> & {
|
||||
@@ -144,6 +150,7 @@ function parseDeliveryTarget(id: string, value: Record<string, unknown>): SelfMe
|
||||
const ci = record(value.ci, `${path}.ci`);
|
||||
const source = record(value.source, `${path}.source`);
|
||||
const build = record(value.build, `${path}.build`);
|
||||
const envReuse = record(build.envReuse, `${path}.build.envReuse`);
|
||||
const proxy = record(build.proxy, `${path}.build.proxy`);
|
||||
const gitops = record(value.gitops, `${path}.gitops`);
|
||||
const deployment = record(value.deployment, `${path}.deployment`);
|
||||
@@ -161,6 +168,12 @@ function parseDeliveryTarget(id: string, value: Record<string, unknown>): SelfMe
|
||||
validateAccessSecret(deployment, `${path}.deployment`);
|
||||
const gitopsWriteUrl = text(gitops.writeUrl, `${path}.gitops.writeUrl`);
|
||||
if (!gitopsWriteUrl.startsWith("http://gitea-http.")) throw new Error(`${path}.gitops.writeUrl must use internal Gitea authority`);
|
||||
if (boolean(envReuse.enabled, `${path}.build.envReuse.enabled`) !== true) throw new Error(`${path}.build.envReuse.enabled must be true`);
|
||||
const envReuseMode = text(envReuse.mode, `${path}.build.envReuse.mode`);
|
||||
if (envReuseMode !== "buildkit-state-host-path") throw new Error(`${path}.build.envReuse.mode must be buildkit-state-host-path`);
|
||||
const identityFiles = stringArray(envReuse.identityFiles, `${path}.build.envReuse.identityFiles`)
|
||||
.map((item, index) => relativePath(item, `${path}.build.envReuse.identityFiles[${index}]`));
|
||||
if (identityFiles.length === 0 || new Set(identityFiles).size !== identityFiles.length) throw new Error(`${path}.build.envReuse.identityFiles must be non-empty and unique`);
|
||||
return {
|
||||
id,
|
||||
node: id,
|
||||
@@ -190,6 +203,12 @@ function parseDeliveryTarget(id: string, value: Record<string, unknown>): SelfMe
|
||||
dockerfile: relativePath(build.dockerfile, `${path}.build.dockerfile`),
|
||||
imageRepository: text(build.imageRepository, `${path}.build.imageRepository`),
|
||||
networkMode: text(build.networkMode, `${path}.build.networkMode`),
|
||||
envReuse: {
|
||||
enabled: true,
|
||||
mode: "buildkit-state-host-path",
|
||||
statePath: absolutePath(envReuse.statePath, `${path}.build.envReuse.statePath`),
|
||||
identityFiles,
|
||||
},
|
||||
proxy: structuredClone(proxy),
|
||||
},
|
||||
gitops: {
|
||||
|
||||
Reference in New Issue
Block a user