@catladder/pipeline 1.98.2 → 1.99.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/node/buildJob.js +1 -7
- package/dist/build/node/yarn.d.ts +2 -5
- package/dist/build/node/yarn.js +27 -15
- package/dist/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/deploy/types/kubernetes.d.ts +12 -0
- package/dist/pipeline/packageManager.js +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +24 -12
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +24 -12
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +24 -12
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +48 -24
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +48 -24
- package/examples/__snapshots__/custom-deploy.ts.snap +24 -12
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +24 -12
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +24 -12
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +24 -12
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +48 -24
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +2652 -0
- package/examples/kubernetes-with-mongodb.ts +49 -0
- package/package.json +1 -1
- package/src/build/node/buildJob.ts +3 -8
- package/src/build/node/yarn.ts +38 -25
- package/src/deploy/types/kubernetes.ts +14 -0
- package/src/pipeline/packageManager.ts +7 -6
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
const config: Config = {
|
|
4
|
+
appName: "test-app",
|
|
5
|
+
customerName: "pan",
|
|
6
|
+
components: {
|
|
7
|
+
api: {
|
|
8
|
+
dir: "api",
|
|
9
|
+
build: {
|
|
10
|
+
type: "node",
|
|
11
|
+
},
|
|
12
|
+
deploy: {
|
|
13
|
+
type: "kubernetes",
|
|
14
|
+
cluster: {
|
|
15
|
+
name: "some-cluster-name",
|
|
16
|
+
region: "europe-west6",
|
|
17
|
+
projectId: "some-project-id",
|
|
18
|
+
type: "gcloud",
|
|
19
|
+
domainCanonical: "panter.cloud",
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
values: {
|
|
23
|
+
application: {
|
|
24
|
+
command: "node main.js",
|
|
25
|
+
},
|
|
26
|
+
mongodb: {
|
|
27
|
+
enabled: true,
|
|
28
|
+
architecture: "replicaset",
|
|
29
|
+
persistence: {
|
|
30
|
+
storageClass: "premium-rwo",
|
|
31
|
+
},
|
|
32
|
+
tolerations: [
|
|
33
|
+
{
|
|
34
|
+
key: "mongodb",
|
|
35
|
+
operator: "Equal",
|
|
36
|
+
value: "true",
|
|
37
|
+
effect: "NoSchedule",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
it("matches snapshot", async () => {
|
|
48
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
49
|
+
});
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { join } from "path";
|
|
|
7
7
|
import { isOfBuildType } from "../types";
|
|
8
8
|
import { getNextCache, getNodeCache, getYarnCache } from "./cache";
|
|
9
9
|
import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
|
|
10
|
-
import {
|
|
10
|
+
import { getDockerAppCopyAndBuildScript, getYarnInstall } from "./yarn";
|
|
11
11
|
import type { CatladderJob } from "../../types/jobs";
|
|
12
12
|
|
|
13
13
|
export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
@@ -55,13 +55,8 @@ export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
55
55
|
cache: [...getYarnCache(context, "pull")],
|
|
56
56
|
variables: {
|
|
57
57
|
// only required for non static
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}),
|
|
61
|
-
YARN_INSTALL_WITHOUT_SCRIPTS: getYarnInstallCommand(context, {
|
|
62
|
-
prodOnly: true,
|
|
63
|
-
noScripts: true,
|
|
64
|
-
}),
|
|
58
|
+
DOCKER_COPY_AND_INSTALL_APP:
|
|
59
|
+
getDockerAppCopyAndBuildScript(context),
|
|
65
60
|
DOCKER_COPY_WORKSPACE_FILES:
|
|
66
61
|
context.packageManagerInfo?.pathsToCopyInDocker
|
|
67
62
|
.map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
|
package/src/build/node/yarn.ts
CHANGED
|
@@ -1,33 +1,16 @@
|
|
|
1
1
|
import type { Context } from "../../types";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
) => {
|
|
3
|
+
const YARN_INSTALL_CLASSIC = `yarn install --frozen-lockfile`;
|
|
4
|
+
|
|
5
|
+
// FIXME: check why and when rebuild is needed
|
|
6
|
+
const YARN_BERRY_PROD_REBUILD = `yarn workspaces focus --production && yarn rebuild`;
|
|
7
|
+
|
|
8
|
+
const getYarnInstallCommand = (context: Context) => {
|
|
10
9
|
if (context.packageManagerInfo?.isClassic) {
|
|
11
|
-
return
|
|
12
|
-
options?.prodOnly ? "--production" : ""
|
|
13
|
-
} ${options?.noScripts ? "--ignore-scripts" : ""}`;
|
|
10
|
+
return YARN_INSTALL_CLASSIC;
|
|
14
11
|
}
|
|
15
|
-
// is modern
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
// trying to import those fail on this version
|
|
19
|
-
const doesNotShipWithBuiltInPlugins = ["2", "3"].some((v) =>
|
|
20
|
-
context.packageManagerInfo?.version.startsWith(v)
|
|
21
|
-
);
|
|
22
|
-
return options?.prodOnly
|
|
23
|
-
? `${options?.noScripts ? "YARN_ENABLE_SCRIPTS=false " : ""}${
|
|
24
|
-
doesNotShipWithBuiltInPlugins
|
|
25
|
-
? "yarn plugin import workspace-tools && "
|
|
26
|
-
: " "
|
|
27
|
-
}yarn workspaces focus --production && yarn rebuild` // needs yarn plugin import workspace-tools
|
|
28
|
-
: `${
|
|
29
|
-
options?.noScripts ? "YARN_ENABLE_SCRIPTS=false " : ""
|
|
30
|
-
}yarn install --immutable`;
|
|
13
|
+
return `yarn install --immutable`;
|
|
31
14
|
};
|
|
32
15
|
|
|
33
16
|
export const ensureNodeVersion = (context: Context) => [
|
|
@@ -38,3 +21,33 @@ export const getYarnInstall = (context: Context) => [
|
|
|
38
21
|
...ensureNodeVersion(context),
|
|
39
22
|
getYarnInstallCommand(context),
|
|
40
23
|
];
|
|
24
|
+
|
|
25
|
+
const DOCKER_COPY_FILES = `COPY --chown=node:node $APP_DIR .`;
|
|
26
|
+
|
|
27
|
+
export const getDockerAppCopyAndBuildScript = (context: Context) => {
|
|
28
|
+
if (context.packageManagerInfo?.isClassic) {
|
|
29
|
+
return `
|
|
30
|
+
RUN ${YARN_INSTALL_CLASSIC} --production --ignore-scripts
|
|
31
|
+
${DOCKER_COPY_FILES}
|
|
32
|
+
RUN ${YARN_INSTALL_CLASSIC} --production
|
|
33
|
+
`.trim();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
|
|
37
|
+
// trying to import those fail on this version
|
|
38
|
+
const doesNotShipWithBuiltInPlugins = ["2", "3"].some((v) =>
|
|
39
|
+
context.packageManagerInfo?.version.startsWith(v)
|
|
40
|
+
);
|
|
41
|
+
const maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins
|
|
42
|
+
? "RUN yarn plugin import workspace-tools"
|
|
43
|
+
: "";
|
|
44
|
+
|
|
45
|
+
// copy first everything and then install
|
|
46
|
+
// rebuild first does not work as it will run postinstall and that might require files in the app
|
|
47
|
+
return `
|
|
48
|
+
${DOCKER_COPY_FILES}
|
|
49
|
+
${maybeAddWorkspaceToolsCommand}
|
|
50
|
+
RUN ${YARN_BERRY_PROD_REBUILD}
|
|
51
|
+
|
|
52
|
+
`.trim();
|
|
53
|
+
};
|
|
@@ -98,6 +98,19 @@ export type KubernetesWorkerDef = {
|
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
+
type KubernetesTolerationExists = {
|
|
102
|
+
operator: "Exists";
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
type KubernetesTolerationEqual = {
|
|
106
|
+
operator: "Equal";
|
|
107
|
+
value: string;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type KubernetesToleration = {
|
|
111
|
+
key: string;
|
|
112
|
+
effect: "NoSchedule" | "PreferNoSchedule" | "NoExecute";
|
|
113
|
+
} & (KubernetesTolerationEqual | KubernetesTolerationExists);
|
|
101
114
|
export type DeployConfigMongodbBase = {
|
|
102
115
|
enabled?: boolean;
|
|
103
116
|
dbName?: string;
|
|
@@ -113,6 +126,7 @@ export type DeployConfigMongodbBase = {
|
|
|
113
126
|
size?: string;
|
|
114
127
|
};
|
|
115
128
|
resources?: KubernetesResourcesDef;
|
|
129
|
+
tolerations?: KubernetesToleration[];
|
|
116
130
|
};
|
|
117
131
|
|
|
118
132
|
export type DeployConfigMongodbStandalone = {
|
|
@@ -29,11 +29,12 @@ export const getPackageManagerInfo = async (
|
|
|
29
29
|
? join(workspaceRoot, "yarn.lock")
|
|
30
30
|
: join(component.dir, "yarn.lock");
|
|
31
31
|
const configFiles = [".yarnrc", ".yarnrc.yml", ".npmrc", ".yarn"]; // ".yarn" is yarn 2 folder
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
// copy all those configFiles from workspace root and/or component folder
|
|
33
|
+
|
|
34
|
+
const configFilePaths = [
|
|
35
|
+
...configFiles,
|
|
36
|
+
...configFiles.map((f) => join(component.dir, f)),
|
|
37
|
+
].filter((f) => existsSync(f));
|
|
37
38
|
|
|
38
39
|
// get all folders that this workspace depend on
|
|
39
40
|
// we will later copy them into the docker build
|
|
@@ -50,7 +51,7 @@ export const getPackageManagerInfo = async (
|
|
|
50
51
|
packageJson,
|
|
51
52
|
...(workspacePackageJson ? [workspacePackageJson] : []),
|
|
52
53
|
lockFile,
|
|
53
|
-
...
|
|
54
|
+
...configFilePaths,
|
|
54
55
|
...workspaceDependencies,
|
|
55
56
|
];
|
|
56
57
|
return {
|