@catladder/pipeline 1.111.5 → 1.112.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/base/createAppBuildJob.d.ts +8 -0
- package/dist/build/base/{createBuildJob.js → createAppBuildJob.js} +3 -3
- package/dist/build/base/index.d.ts +8 -0
- package/dist/build/base/index.js +57 -0
- package/dist/build/custom/buildJob.js +19 -22
- package/dist/build/docker.d.ts +2 -4
- package/dist/build/docker.js +4 -39
- package/dist/build/node/buildJob.js +30 -32
- package/dist/build/node/meteor.js +19 -21
- package/dist/build/rails/build.js +12 -19
- package/dist/build/types.d.ts +4 -3
- package/dist/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/deploy/base/deploy.d.ts +3 -2
- package/dist/deploy/base/deploy.js +9 -4
- package/dist/deploy/base/index.d.ts +10 -3
- package/dist/deploy/base/index.js +37 -16
- package/dist/deploy/base/rollback.d.ts +3 -2
- package/dist/deploy/base/rollback.js +8 -6
- package/dist/deploy/base/stop.d.ts +3 -2
- package/dist/deploy/base/stop.js +8 -6
- package/dist/deploy/cloudRun/deployJob.js +28 -26
- package/dist/deploy/custom/deployJob.js +14 -11
- package/dist/deploy/dockerTag/deployJob.js +15 -5
- package/dist/deploy/kubernetes/deployJob.js +14 -14
- package/dist/deploy/kubernetes/mongodb.d.ts +1 -1
- package/dist/deploy/kubernetes/mongodb.js +8 -7
- package/dist/deploy/types/index.d.ts +1 -1
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +1 -0
- package/dist/pipeline/gitlab/createGitlabJobs.js +4 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/gitlab-ci-yml.d.ts +769 -0
- package/dist/types/gitlab-ci-yml.js +9 -0
- package/dist/types/gitlab-types.d.ts +12 -82
- package/dist/types/jobs.d.ts +3 -3
- package/package.json +4 -2
- package/scripts/generate-gitlab-ci-types.ts +51 -0
- package/src/build/base/{createBuildJob.ts → createAppBuildJob.ts} +3 -2
- package/src/build/base/index.ts +35 -0
- package/src/build/custom/buildJob.ts +32 -45
- package/src/build/docker.ts +14 -17
- package/src/build/node/buildJob.ts +50 -61
- package/src/build/node/meteor.ts +31 -36
- package/src/build/rails/build.ts +8 -10
- package/src/build/types.ts +4 -8
- package/src/deploy/base/deploy.ts +16 -2
- package/src/deploy/base/index.ts +22 -3
- package/src/deploy/base/rollback.ts +13 -2
- package/src/deploy/base/stop.ts +13 -4
- package/src/deploy/cloudRun/deployJob.ts +13 -15
- package/src/deploy/custom/deployJob.ts +17 -20
- package/src/deploy/dockerTag/deployJob.ts +6 -7
- package/src/deploy/kubernetes/deployJob.ts +17 -23
- package/src/deploy/kubernetes/mongodb.ts +3 -2
- package/src/pipeline/gitlab/createGitlabJobs.ts +3 -0
- package/src/types/gitlab-ci-yml.ts +892 -0
- package/src/types/gitlab-types.ts +49 -83
- package/src/types/jobs.ts +3 -4
- package/dist/build/base/createBuildJob.d.ts +0 -7
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
6
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
7
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
8
|
+
*/
|
|
9
|
+
exports.__esModule = true;
|
|
@@ -1,98 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Artifacts as GitlabCiArtifacts, JobTemplate, Cache, Rules } from "./gitlab-ci-yml";
|
|
2
|
+
export { Retry, Image as GitlabJobImage } from "./gitlab-ci-yml";
|
|
3
|
+
export interface Artifacts extends Omit<GitlabCiArtifacts, "paths"> {
|
|
2
4
|
paths: string[];
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
path: string;
|
|
10
|
-
};
|
|
11
|
-
codequality?: string | string[];
|
|
12
|
-
cyclonedx?: string | string[];
|
|
13
|
-
dotenv?: string | string[];
|
|
14
|
-
junit?: string | string[];
|
|
15
|
-
sast?: string;
|
|
16
|
-
secret_detection?: string;
|
|
17
|
-
terraform?: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export declare type GitlabJobCache = {
|
|
21
|
-
key: GitlabJobCacheKey;
|
|
22
|
-
policy?: string;
|
|
23
|
-
paths: string[];
|
|
24
|
-
};
|
|
25
|
-
export declare type GitlabJobCacheKey = string | {
|
|
26
|
-
files: string[];
|
|
27
|
-
prefix?: string;
|
|
28
|
-
};
|
|
29
|
-
export declare type GitlabRule = {
|
|
30
|
-
if?: string;
|
|
31
|
-
when?: "always" | "on_success" | "manual" | "never";
|
|
32
|
-
allow_failure?: boolean;
|
|
33
|
-
};
|
|
34
|
-
export declare type Retry = {
|
|
35
|
-
max: number;
|
|
36
|
-
when: string[];
|
|
37
|
-
};
|
|
38
|
-
export declare type GitlabJobService = {
|
|
39
|
-
name: string;
|
|
40
|
-
command?: string[];
|
|
41
|
-
entrypoint?: string[];
|
|
42
|
-
alias?: string;
|
|
43
|
-
};
|
|
44
|
-
export declare type GitlabJobImage = string | {
|
|
45
|
-
name: string;
|
|
46
|
-
entrypoint?: string[];
|
|
47
|
-
};
|
|
48
|
-
export declare type GitlabEnvironment = {
|
|
49
|
-
url: string;
|
|
50
|
-
name: string;
|
|
51
|
-
action?: "stop" | "start" | "prepare" | "access";
|
|
52
|
-
on_stop?: string;
|
|
53
|
-
auto_stop_in?: string;
|
|
54
|
-
};
|
|
55
|
-
export declare type GitlabJobDef = {
|
|
56
|
-
stage: string;
|
|
57
|
-
before_script?: string[];
|
|
58
|
-
script: (string | undefined)[];
|
|
59
|
-
interruptible?: boolean;
|
|
60
|
-
needs?: Array<string | {
|
|
61
|
-
job: string;
|
|
62
|
-
artifacts: boolean;
|
|
63
|
-
}>;
|
|
5
|
+
}
|
|
6
|
+
export declare type GitlabJobCache = Cache;
|
|
7
|
+
export declare type GitlabRule = Exclude<Rules, null>[number];
|
|
8
|
+
export declare type GitlabEnvironment = Omit<Exclude<JobTemplate["environment"], undefined | string>, "deployment_tier">;
|
|
9
|
+
export interface GitlabJobDef extends Pick<JobTemplate, "after_script" | "allow_failure" | "artifacts" | "before_script" | "coverage" | "dependencies" | "environment" | "except" | "hooks" | "image" | "interruptible" | "needs" | "only" | "parallel" | "release" | "resource_group" | "retry" | "rules" | "script" | "services" | "stage" | "tags" | "trigger" | "variables"> {
|
|
10
|
+
stage: JobTemplate["stage"];
|
|
64
11
|
rules?: GitlabRule[];
|
|
65
12
|
cache?: GitlabJobCache | GitlabJobCache[];
|
|
66
13
|
artifacts?: Artifacts;
|
|
67
|
-
retry?: Retry;
|
|
68
|
-
services?: GitlabJobService[];
|
|
69
|
-
image?: GitlabJobImage;
|
|
70
|
-
variables?: GitlabVariables;
|
|
71
|
-
dependencies?: string[];
|
|
72
|
-
environment?: GitlabEnvironment;
|
|
73
|
-
allow_failure?: boolean;
|
|
74
|
-
parallel?: number;
|
|
75
14
|
tags?: string[];
|
|
76
|
-
|
|
77
|
-
strategy: "depend";
|
|
78
|
-
include: Array<{
|
|
79
|
-
artifact: string;
|
|
80
|
-
job: string;
|
|
81
|
-
}>;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
export declare type GitlabVariables = Record<string, string | undefined>;
|
|
15
|
+
}
|
|
85
16
|
/**
|
|
86
17
|
* this is not precicily the type of a gitlab-pipeline
|
|
87
18
|
* the jobs nee to be merge into the object.
|
|
88
19
|
* Problem is, that this type cannot be represented properly with typescript, see https://github.com/microsoft/TypeScript/issues/17867
|
|
89
20
|
*/
|
|
90
|
-
export
|
|
21
|
+
export interface GitlabPipeline extends Pick<JobTemplate, "variables"> {
|
|
91
22
|
image: string;
|
|
92
|
-
variables: GitlabVariables;
|
|
93
23
|
workflow?: {
|
|
94
24
|
rules: GitlabRule[];
|
|
95
25
|
};
|
|
96
26
|
stages: string[];
|
|
97
27
|
jobs: Record<string, GitlabJobDef>;
|
|
98
|
-
}
|
|
28
|
+
}
|
package/dist/types/jobs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Artifacts, GitlabEnvironment, GitlabJobCache, GitlabRule,
|
|
1
|
+
import type { Artifacts, GitlabEnvironment, GitlabJobCache, GitlabRule, GitlabJobImage, GitlabJobDef } from "./gitlab-types";
|
|
2
2
|
export declare const BASE_STAGES: readonly ["setup", "test", "build", "deploy", "verify", "rollback", "stop"];
|
|
3
3
|
export declare type BaseStage = typeof BASE_STAGES[number];
|
|
4
4
|
export declare type CatladderJobNeed = string | {
|
|
@@ -59,7 +59,7 @@ export declare type CatladderJob<S = BaseStage> = {
|
|
|
59
59
|
/**
|
|
60
60
|
* additional services, mainly used for docker
|
|
61
61
|
*/
|
|
62
|
-
services?:
|
|
62
|
+
services?: GitlabJobDef["services"];
|
|
63
63
|
/**
|
|
64
64
|
* image to use
|
|
65
65
|
*/
|
|
@@ -67,7 +67,7 @@ export declare type CatladderJob<S = BaseStage> = {
|
|
|
67
67
|
/**
|
|
68
68
|
* variables to pass
|
|
69
69
|
*/
|
|
70
|
-
variables:
|
|
70
|
+
variables: GitlabJobDef["variables"];
|
|
71
71
|
/**
|
|
72
72
|
* whether failures are allowed
|
|
73
73
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catladder/pipeline",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.112.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build:tsc": "yarn tsc",
|
|
6
6
|
"build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"build:inline-variables": "yarn babel --keep-file-extension --extensions \".ts,.js\" --config-file ./babel-inline.json dist --out-dir dist",
|
|
10
10
|
"build:watch": "yarn tsc -w",
|
|
11
11
|
"lint": "eslint \"src/**/*.ts\"",
|
|
12
|
-
"lint:fix": "eslint \"src/**/*.ts\" --fix"
|
|
12
|
+
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
13
|
+
"generate:gitlab-ci-yml-types": "ts-node ./scripts/generate-gitlab-ci-types.ts"
|
|
13
14
|
},
|
|
14
15
|
"types": "dist/index.d.ts",
|
|
15
16
|
"main": "dist/index.js",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"child-process-promise": "^2.2.1",
|
|
32
33
|
"eslint": "^8.7.0",
|
|
33
34
|
"js-yaml": "^4.1.0",
|
|
35
|
+
"json-schema-to-typescript": "^13.0.2",
|
|
34
36
|
"lodash": "^4.17.21",
|
|
35
37
|
"memoizee": "^0.4.15",
|
|
36
38
|
"path-equal": "1.1.3",
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { compile } from "json-schema-to-typescript";
|
|
2
|
+
import { resolve, join } from "path";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { rm, writeFile } from "fs/promises";
|
|
5
|
+
|
|
6
|
+
const rootPath = resolve(__dirname, "..");
|
|
7
|
+
const typeOutputPath = join(rootPath, "src/types/gitlab-ci-yml.ts");
|
|
8
|
+
|
|
9
|
+
export const generateFromCurrentSchema = async () => {
|
|
10
|
+
const response = await fetch(
|
|
11
|
+
"https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"
|
|
12
|
+
);
|
|
13
|
+
const gitLabCiJsonSchema = await response.json();
|
|
14
|
+
const schema = await compile(gitLabCiJsonSchema, "GitlabCiYml", {
|
|
15
|
+
additionalProperties: true,
|
|
16
|
+
enableConstEnums: true,
|
|
17
|
+
declareExternallyReferenced: true,
|
|
18
|
+
unreachableDefinitions: true,
|
|
19
|
+
strictIndexSignatures: true,
|
|
20
|
+
unknownAny: false,
|
|
21
|
+
ignoreMinAndMaxItems: true,
|
|
22
|
+
format: true,
|
|
23
|
+
style: {
|
|
24
|
+
bracketSpacing: true,
|
|
25
|
+
printWidth: 100,
|
|
26
|
+
semi: true,
|
|
27
|
+
tabWidth: 2,
|
|
28
|
+
useTabs: false,
|
|
29
|
+
trailingComma: "es5",
|
|
30
|
+
endOfLine: "lf",
|
|
31
|
+
},
|
|
32
|
+
cwd: rootPath,
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Remove part that failes with tsc error
|
|
36
|
+
* ```
|
|
37
|
+
* error TS2411: Property '$schema' of type 'string | undefined' is not assignable to 'string' index type 'JobTemplate1'.
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
const sanitizedSchenma = schema.replace(
|
|
41
|
+
// eslint-disable-next-line no-useless-escape
|
|
42
|
+
/export interface HttpsGitlabComGitlabCiYml \{\n[ a-zA-Z0-9?$:;\n_!"\{\}\/*@\[\],.|\(\)]*\[k\: string\]: Job;\n\}/m,
|
|
43
|
+
""
|
|
44
|
+
);
|
|
45
|
+
if (existsSync(typeOutputPath)) {
|
|
46
|
+
await rm(typeOutputPath);
|
|
47
|
+
}
|
|
48
|
+
await writeFile(typeOutputPath, sanitizedSchenma, { encoding: "utf-8" });
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
generateFromCurrentSchema();
|
|
@@ -12,9 +12,10 @@ import {
|
|
|
12
12
|
import { writeBuildInfo } from "./writeBuildInfo";
|
|
13
13
|
import { writeDotEnv } from "./writeDotEnv";
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export type AppBuildJobDefinition = Partial<CatladderJob>;
|
|
16
|
+
export const createAppBuildJob = (
|
|
16
17
|
context: Context,
|
|
17
|
-
{ script, variables, ...def }:
|
|
18
|
+
{ script, variables, ...def }: AppBuildJobDefinition
|
|
18
19
|
): CatladderJob => {
|
|
19
20
|
return merge(
|
|
20
21
|
{
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sbomDeactivated } from "../../deploy/sbom";
|
|
2
|
+
import type { Context } from "../../types/context";
|
|
3
|
+
import type { CatladderJob } from "../../types/jobs";
|
|
4
|
+
import type { DockerBuildJobDefinition } from "../docker";
|
|
5
|
+
import { createDockerBuildJobBase, requiresDockerBuild } from "../docker";
|
|
6
|
+
import { createSbomBuildJob } from "../sbom";
|
|
7
|
+
import { APP_BUILD_JOB_NAME } from "./constants";
|
|
8
|
+
import type { AppBuildJobDefinition } from "./createAppBuildJob";
|
|
9
|
+
import { createAppBuildJob } from "./createAppBuildJob";
|
|
10
|
+
|
|
11
|
+
export const createBuildJobs = (
|
|
12
|
+
context: Context,
|
|
13
|
+
definitions: {
|
|
14
|
+
appBuild?: AppBuildJobDefinition;
|
|
15
|
+
dockerBuild: DockerBuildJobDefinition;
|
|
16
|
+
}
|
|
17
|
+
): CatladderJob[] => {
|
|
18
|
+
return [
|
|
19
|
+
...(definitions.appBuild
|
|
20
|
+
? [createAppBuildJob(context, definitions.appBuild)]
|
|
21
|
+
: []),
|
|
22
|
+
...(requiresDockerBuild(context)
|
|
23
|
+
? [
|
|
24
|
+
createDockerBuildJobBase(context, {
|
|
25
|
+
...definitions.dockerBuild,
|
|
26
|
+
needs: [
|
|
27
|
+
...(definitions.dockerBuild.needs ?? []),
|
|
28
|
+
...(definitions.appBuild ? [APP_BUILD_JOB_NAME] : []),
|
|
29
|
+
],
|
|
30
|
+
}),
|
|
31
|
+
]
|
|
32
|
+
: []),
|
|
33
|
+
...(sbomDeactivated(context) ? [] : [createSbomBuildJob(context)]),
|
|
34
|
+
];
|
|
35
|
+
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import type { Context } from "../../types/context";
|
|
3
3
|
import { ensureArray } from "../../utils";
|
|
4
|
-
import {
|
|
5
|
-
import { createBuildJob } from "../base/createBuildJob";
|
|
6
|
-
import { createDockerBuildJobDefault, requiresDockerBuild } from "../docker";
|
|
4
|
+
import { getDockerBuildDefaultScript, requiresDockerBuild } from "../docker";
|
|
7
5
|
import { isOfBuildType } from "../types";
|
|
8
6
|
|
|
9
7
|
import type { CatladderJob } from "../../types/jobs";
|
|
10
|
-
import {
|
|
11
|
-
import { sbomDeactivated } from "../../deploy/sbom";
|
|
8
|
+
import { createBuildJobs } from "../base";
|
|
12
9
|
|
|
13
10
|
const RUNNER_BUILD_VARIABLES = {
|
|
14
11
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
@@ -24,45 +21,35 @@ export const createCustomBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
24
21
|
throw new Error("deploy config is not custom");
|
|
25
22
|
}
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
script: [
|
|
55
|
-
buildConfig.docker?.type === "nginx"
|
|
56
|
-
? "ensureNginxDockerfile"
|
|
57
|
-
: "", // e.g. custom,
|
|
58
|
-
].filter(Boolean),
|
|
24
|
+
return createBuildJobs(context, {
|
|
25
|
+
appBuild:
|
|
26
|
+
buildConfig.buildCommand !== null
|
|
27
|
+
? {
|
|
28
|
+
image: buildConfig.jobImage,
|
|
29
|
+
variables: {
|
|
30
|
+
...RUNNER_BUILD_VARIABLES,
|
|
31
|
+
},
|
|
32
|
+
cache: buildConfig.jobCache,
|
|
33
|
+
services: buildConfig.jobServices,
|
|
34
|
+
script: [...(ensureArray(buildConfig.buildCommand) ?? [])],
|
|
35
|
+
artifacts: {
|
|
36
|
+
paths: [
|
|
37
|
+
join(context.componentConfig.dir, "__build_info.json"),
|
|
38
|
+
join(context.componentConfig.dir, "dist"),
|
|
39
|
+
...(buildConfig.artifactsPaths?.map((path) =>
|
|
40
|
+
join(context.componentConfig.dir, path)
|
|
41
|
+
) ?? []),
|
|
42
|
+
],
|
|
43
|
+
expire_in: "1 day",
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
: undefined,
|
|
47
|
+
dockerBuild: {
|
|
48
|
+
script: getDockerBuildDefaultScript(
|
|
49
|
+
buildConfig.docker?.type === "nginx" ? "ensureNginxDockerfile" : ""
|
|
50
|
+
),
|
|
59
51
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}),
|
|
64
|
-
]
|
|
65
|
-
: []),
|
|
66
|
-
...(sbomDeactivated(context) ? [] : [createSbomBuildJob(context)]),
|
|
67
|
-
];
|
|
52
|
+
variables: {},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
68
55
|
};
|
package/src/build/docker.ts
CHANGED
|
@@ -57,6 +57,7 @@ export const getDockerBuildVariables = (context: Context) => {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
export const DOCKER_BUILD_JOB_NAME = "🔨 docker";
|
|
60
|
+
|
|
60
61
|
export const getDockerJobBaseProps = (context: Context) => {
|
|
61
62
|
return {
|
|
62
63
|
image: getRunnerImage("docker-build"),
|
|
@@ -69,6 +70,8 @@ export const getDockerJobBaseProps = (context: Context) => {
|
|
|
69
70
|
variables: getDockerBaseVariables(),
|
|
70
71
|
};
|
|
71
72
|
};
|
|
73
|
+
|
|
74
|
+
export type DockerBuildJobDefinition = Partial<CatladderJob>;
|
|
72
75
|
export const createDockerBuildJobBase = (
|
|
73
76
|
context: Context,
|
|
74
77
|
{ script, ...def }: Partial<CatladderJob>
|
|
@@ -90,20 +93,14 @@ export const createDockerBuildJobBase = (
|
|
|
90
93
|
|
|
91
94
|
export const gitlabDockerLogin =
|
|
92
95
|
"docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY";
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE",
|
|
105
|
-
"docker push $DOCKER_CACHE_IMAGE",
|
|
106
|
-
],
|
|
107
|
-
...def,
|
|
108
|
-
});
|
|
109
|
-
};
|
|
96
|
+
|
|
97
|
+
export const getDockerBuildDefaultScript = (ensureDockerFileScript?: string) =>
|
|
98
|
+
[
|
|
99
|
+
ensureDockerFileScript,
|
|
100
|
+
gitlabDockerLogin,
|
|
101
|
+
"docker version",
|
|
102
|
+
"docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", //BUILDKIT_INLINE_CACHE, see https://testdriven.io/blog/faster-ci-builds-with-docker-cache/
|
|
103
|
+
"docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG",
|
|
104
|
+
"docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE",
|
|
105
|
+
"docker push $DOCKER_CACHE_IMAGE",
|
|
106
|
+
].filter(Boolean);
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { getRunnerImage } from "../../runner";
|
|
1
3
|
import type { Context } from "../../types/context";
|
|
4
|
+
import type { CatladderJob } from "../../types/jobs";
|
|
2
5
|
import { ensureArray } from "../../utils";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { createDockerBuildJobDefault, requiresDockerBuild } from "../docker";
|
|
6
|
-
import { join } from "path";
|
|
6
|
+
import { createBuildJobs } from "../base";
|
|
7
|
+
import { getDockerBuildDefaultScript, requiresDockerBuild } from "../docker";
|
|
7
8
|
import { isOfBuildType } from "../types";
|
|
8
9
|
import { getNextCache, getNodeCache, getYarnCache } from "./cache";
|
|
9
10
|
import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
|
|
10
11
|
import { getDockerAppCopyAndBuildScript, getYarnInstall } from "./yarn";
|
|
11
|
-
import type { CatladderJob } from "../../types/jobs";
|
|
12
|
-
import { getRunnerImage } from "../../runner";
|
|
13
|
-
import { createSbomBuildJob } from "../sbom";
|
|
14
|
-
import { sbomDeactivated } from "../../deploy/sbom";
|
|
15
12
|
|
|
16
13
|
export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
17
14
|
const buildConfig = context.componentConfig.build;
|
|
@@ -22,62 +19,54 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
22
19
|
|
|
23
20
|
const defaultImage = getRunnerImage("jobs-default");
|
|
24
21
|
const yarnInstall = getYarnInstall(context);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
...yarnInstall,
|
|
39
|
-
...(ensureArray(buildConfig.buildCommand) ?? []),
|
|
40
|
-
],
|
|
41
|
-
artifacts: {
|
|
42
|
-
paths: [
|
|
43
|
-
join(context.componentConfig.dir, "__build_info.json"),
|
|
44
|
-
join(context.componentConfig.dir, "dist"),
|
|
45
|
-
join(context.componentConfig.dir, ".next"),
|
|
46
|
-
...(buildConfig.artifactsPaths?.map((path) =>
|
|
47
|
-
join(context.componentConfig.dir, path)
|
|
48
|
-
) ?? []),
|
|
22
|
+
|
|
23
|
+
return createBuildJobs(context, {
|
|
24
|
+
appBuild:
|
|
25
|
+
buildConfig.buildCommand !== null
|
|
26
|
+
? {
|
|
27
|
+
image: buildConfig.jobImage ?? defaultImage,
|
|
28
|
+
variables: {
|
|
29
|
+
...NODE_RUNNER_BUILD_VARIABLES,
|
|
30
|
+
},
|
|
31
|
+
cache: [
|
|
32
|
+
...(ensureArray(buildConfig.jobCache) ?? []),
|
|
33
|
+
...getNodeCache(context),
|
|
34
|
+
...getNextCache(context),
|
|
49
35
|
],
|
|
50
|
-
expire_in: "1 day",
|
|
51
|
-
},
|
|
52
|
-
jobTags: buildConfig.jobTags,
|
|
53
|
-
})
|
|
54
|
-
: null;
|
|
55
|
-
return [
|
|
56
|
-
...(appBuildJob ? [appBuildJob] : []),
|
|
57
|
-
...(requiresDockerBuild(context)
|
|
58
|
-
? [
|
|
59
|
-
createDockerBuildJobDefault(context, {
|
|
60
36
|
script: [
|
|
61
|
-
|
|
62
|
-
buildConfig.
|
|
63
|
-
? "ensureNginxDockerfile"
|
|
64
|
-
: "ensureNodeDockerfile",
|
|
37
|
+
...yarnInstall,
|
|
38
|
+
...(ensureArray(buildConfig.buildCommand) ?? []),
|
|
65
39
|
],
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
40
|
+
artifacts: {
|
|
41
|
+
paths: [
|
|
42
|
+
join(context.componentConfig.dir, "__build_info.json"),
|
|
43
|
+
join(context.componentConfig.dir, "dist"),
|
|
44
|
+
join(context.componentConfig.dir, ".next"),
|
|
45
|
+
...(buildConfig.artifactsPaths?.map((path) =>
|
|
46
|
+
join(context.componentConfig.dir, path)
|
|
47
|
+
) ?? []),
|
|
48
|
+
],
|
|
49
|
+
expire_in: "1 day",
|
|
75
50
|
},
|
|
51
|
+
jobTags: buildConfig.jobTags,
|
|
52
|
+
}
|
|
53
|
+
: undefined,
|
|
76
54
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
55
|
+
dockerBuild: {
|
|
56
|
+
script: getDockerBuildDefaultScript(
|
|
57
|
+
buildConfig.type === "node-static" || buildConfig.type === "storybook"
|
|
58
|
+
? "ensureNginxDockerfile"
|
|
59
|
+
: "ensureNodeDockerfile"
|
|
60
|
+
),
|
|
61
|
+
cache: [...getYarnCache(context, "pull")],
|
|
62
|
+
variables: {
|
|
63
|
+
// only required for non static
|
|
64
|
+
DOCKER_COPY_AND_INSTALL_APP: getDockerAppCopyAndBuildScript(context),
|
|
65
|
+
DOCKER_COPY_WORKSPACE_FILES:
|
|
66
|
+
context.packageManagerInfo?.pathsToCopyInDocker
|
|
67
|
+
.map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
|
|
68
|
+
?.join("\n"),
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
83
72
|
};
|
package/src/build/node/meteor.ts
CHANGED
|
@@ -5,14 +5,11 @@ import type { Context } from "../../types/context";
|
|
|
5
5
|
|
|
6
6
|
import type { CatladderJob } from "../../types/jobs";
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { createDockerBuildJobDefault } from "../docker";
|
|
8
|
+
import { createBuildJobs } from "../base";
|
|
9
|
+
import { getDockerBuildDefaultScript } from "../docker";
|
|
11
10
|
import { isOfBuildType } from "../types";
|
|
12
11
|
import { getNodeCache } from "./cache";
|
|
13
12
|
import { getYarnInstall } from "./yarn";
|
|
14
|
-
import { sbomDeactivated } from "../../deploy/sbom";
|
|
15
|
-
import { createSbomBuildJob } from "../sbom";
|
|
16
13
|
|
|
17
14
|
const getMeteorCache = (context: Context): GitlabJobCache[] => [
|
|
18
15
|
{
|
|
@@ -37,42 +34,40 @@ export const createMeteorBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
const yarnInstall = getYarnInstall(context);
|
|
40
|
-
const appBuildJob: CatladderJob | null =
|
|
41
|
-
buildConfig.buildCommand !== null
|
|
42
|
-
? createBuildJob(context, {
|
|
43
|
-
cache: [...getNodeCache(context), ...getMeteorCache(context)],
|
|
44
|
-
image: getRunnerImage("jobs-meteor"),
|
|
45
|
-
variables: {
|
|
46
|
-
METEOR_DISABLE_OPTIMISTIC_CACHING: "1", // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
|
|
47
|
-
},
|
|
48
|
-
script: [
|
|
49
|
-
...yarnInstall,
|
|
50
37
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
return createBuildJobs(context, {
|
|
39
|
+
appBuild:
|
|
40
|
+
buildConfig.buildCommand !== null
|
|
41
|
+
? {
|
|
42
|
+
cache: [...getNodeCache(context), ...getMeteorCache(context)],
|
|
43
|
+
image: getRunnerImage("jobs-meteor"),
|
|
44
|
+
variables: {
|
|
45
|
+
METEOR_DISABLE_OPTIMISTIC_CACHING: "1", // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
|
|
46
|
+
},
|
|
47
|
+
script: [
|
|
48
|
+
...yarnInstall,
|
|
54
49
|
|
|
55
|
-
|
|
50
|
+
'echo "add healthcheck package"',
|
|
51
|
+
"meteor add panter:healthroute --allow-superuser",
|
|
52
|
+
"meteor add qualia:prod-shell --allow-superuser",
|
|
56
53
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
paths: [
|
|
61
|
-
context.componentConfig.dir + "/__build_info.json",
|
|
62
|
-
context.componentConfig.dir + "/dist",
|
|
54
|
+
'TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory',
|
|
55
|
+
|
|
56
|
+
"cp ./__build_info.json ./dist/bundle/programs/server",
|
|
63
57
|
],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
artifacts: {
|
|
59
|
+
paths: [
|
|
60
|
+
context.componentConfig.dir + "/__build_info.json",
|
|
61
|
+
context.componentConfig.dir + "/dist",
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
: undefined,
|
|
66
|
+
dockerBuild: {
|
|
67
|
+
script: getDockerBuildDefaultScript("ensureMeteorDockerfile"),
|
|
71
68
|
variables: {
|
|
72
69
|
METEOR_INSTALL_SCRIPTS: buildConfig.installScripts ? "true" : "",
|
|
73
70
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
...(sbomDeactivated(context) ? [] : [createSbomBuildJob(context)]),
|
|
77
|
-
];
|
|
71
|
+
},
|
|
72
|
+
});
|
|
78
73
|
};
|