@catladder/pipeline 1.123.1 → 1.124.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.
Files changed (40) hide show
  1. package/dist/build/custom/buildJob.js +1 -1
  2. package/dist/build/docker.d.ts +26 -6
  3. package/dist/build/docker.js +53 -8
  4. package/dist/build/node/buildJob.js +1 -1
  5. package/dist/build/node/meteor.js +1 -1
  6. package/dist/build/rails/build.js +12 -3
  7. package/dist/bundles/catladder-gitlab/index.js +3 -3
  8. package/dist/constants.js +1 -1
  9. package/dist/deploy/cloudRun/artifactsRegistry.d.ts +7 -4
  10. package/dist/deploy/cloudRun/artifactsRegistry.js +30 -23
  11. package/dist/deploy/cloudRun/deployJob.js +1 -1
  12. package/dist/deploy/dockerTag/deployJob.js +32 -1
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +72 -76
  15. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +72 -76
  16. package/examples/__snapshots__/cloud-run-non-public.ts.snap +72 -76
  17. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +144 -152
  18. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +144 -152
  19. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +72 -76
  20. package/examples/__snapshots__/custom-build-job.ts.snap +72 -76
  21. package/examples/__snapshots__/custom-deploy.ts.snap +40 -28
  22. package/examples/__snapshots__/custom-sbom-java.ts.snap +72 -76
  23. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +40 -28
  24. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +40 -28
  25. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +40 -28
  26. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +80 -56
  27. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +40 -28
  28. package/examples/__snapshots__/meteor-kubernetes.ts.snap +40 -28
  29. package/examples/__snapshots__/native-app.ts.snap +72 -76
  30. package/examples/__snapshots__/node-build-with-custom-image.ts.snap +72 -76
  31. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +56 -52
  32. package/package.json +1 -1
  33. package/src/build/custom/buildJob.ts +1 -0
  34. package/src/build/docker.ts +56 -16
  35. package/src/build/node/buildJob.ts +1 -0
  36. package/src/build/node/meteor.ts +1 -1
  37. package/src/build/rails/build.ts +2 -2
  38. package/src/deploy/cloudRun/artifactsRegistry.ts +35 -32
  39. package/src/deploy/cloudRun/deployJob.ts +1 -8
  40. package/src/deploy/dockerTag/deployJob.ts +1 -1
@@ -75,7 +75,7 @@ var createCustomBuildJobs = function (context) {
75
75
  }
76
76
  } : undefined,
77
77
  dockerBuild: {
78
- script: (0, docker_1.getDockerBuildDefaultScript)(((_d = buildConfig.docker) === null || _d === void 0 ? void 0 : _d.type) === "nginx" ? "ensureNginxDockerfile" : ""),
78
+ script: (0, docker_1.getDockerBuildDefaultScript)(context, ((_d = buildConfig.docker) === null || _d === void 0 ? void 0 : _d.type) === "nginx" ? "ensureNginxDockerfile" : ""),
79
79
  variables: {}
80
80
  }
81
81
  });
@@ -1,12 +1,16 @@
1
1
  import type { Context } from "../types";
2
2
  import type { CatladderJob } from "../types/jobs";
3
3
  export declare const getDockerImageVariables: (context: Context) => {
4
+ DOCKER_IMAGE_TAG: string;
5
+ DOCKER_REGISTRY: string;
6
+ DOCKER_IMAGE: string;
7
+ DOCKER_CACHE_IMAGE: string;
8
+ } | {
9
+ DOCKER_IMAGE_TAG: string;
4
10
  DOCKER_REGISTRY: string;
5
- DOCKER_REGISTRY_IMAGE_PATH: string;
6
11
  DOCKER_CACHE_IMAGE: string;
7
12
  DOCKER_IMAGE_NAME: string;
8
13
  DOCKER_IMAGE: string;
9
- DOCKER_IMAGE_TAG: string;
10
14
  };
11
15
  /**
12
16
  * Weather the context requires a docker build
@@ -17,12 +21,28 @@ export declare const requiresDockerBuild: ({
17
21
  }
18
22
  }: Context) => boolean;
19
23
  export declare const getDockerBuildVariables: (context: Context) => {
24
+ DOCKER_IMAGE_TAG: string;
25
+ DOCKER_REGISTRY: string;
26
+ DOCKER_IMAGE: string;
27
+ DOCKER_CACHE_IMAGE: string;
28
+ DOCKER_HOST: string;
29
+ DOCKER_TLS_CERTDIR: string;
30
+ DOCKER_DRIVER: string;
31
+ DOCKER_BUILDKIT: string;
32
+ DOCKERFILE_ADDITIONS: string | undefined;
33
+ DOCKERFILE_ADDITIONS_END: string | undefined;
34
+ APP_DIR: string;
35
+ DOCKER_DIR: string;
36
+ KUBERNETES_CPU_REQUEST: string;
37
+ KUBERNETES_CPU_LIMIT: string;
38
+ KUBERNETES_MEMORY_REQUEST: string;
39
+ KUBERNETES_MEMORY_LIMIT: string;
40
+ } | {
41
+ DOCKER_IMAGE_TAG: string;
20
42
  DOCKER_REGISTRY: string;
21
- DOCKER_REGISTRY_IMAGE_PATH: string;
22
43
  DOCKER_CACHE_IMAGE: string;
23
44
  DOCKER_IMAGE_NAME: string;
24
45
  DOCKER_IMAGE: string;
25
- DOCKER_IMAGE_TAG: string;
26
46
  DOCKER_HOST: string;
27
47
  DOCKER_TLS_CERTDIR: string;
28
48
  DOCKER_DRIVER: string;
@@ -55,6 +75,6 @@ export declare const createDockerBuildJobBase: (context: Context, {
55
75
  script,
56
76
  ...def
57
77
  }: Partial<CatladderJob>) => CatladderJob;
58
- export declare const gitlabDockerLogin = "docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY";
59
- export declare const getDockerBuildDefaultScript: (ensureDockerFileScript?: string | undefined) => (string | undefined)[];
78
+ export declare const gitlabDockerLogin: (context: Context) => string[];
79
+ export declare const getDockerBuildDefaultScript: (context: Context, ensureDockerFileScript?: string | undefined) => (string | undefined)[];
60
80
  export declare const hasDockerfile: (context: Context) => boolean;
@@ -18,6 +18,37 @@ var __rest = this && this.__rest || function (s, e) {
18
18
  }
19
19
  return t;
20
20
  };
21
+ var __read = this && this.__read || function (o, n) {
22
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
23
+ if (!m) return o;
24
+ var i = m.call(o),
25
+ r,
26
+ ar = [],
27
+ e;
28
+ try {
29
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
+ } catch (error) {
31
+ e = {
32
+ error: error
33
+ };
34
+ } finally {
35
+ try {
36
+ if (r && !r.done && (m = i["return"])) m.call(i);
37
+ } finally {
38
+ if (e) throw e.error;
39
+ }
40
+ }
41
+ return ar;
42
+ };
43
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
44
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
45
+ if (ar || !(i in from)) {
46
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
47
+ ar[i] = from[i];
48
+ }
49
+ }
50
+ return to.concat(ar || Array.prototype.slice.call(from));
51
+ };
21
52
  var __importDefault = this && this.__importDefault || function (mod) {
22
53
  return mod && mod.__esModule ? mod : {
23
54
  "default": mod
@@ -30,6 +61,9 @@ var deploy_1 = require("../deploy");
30
61
  var runner_1 = require("../runner");
31
62
  var fs_1 = require("fs");
32
63
  var path_1 = __importDefault(require("path"));
64
+ var gitlab_1 = require("../utils/gitlab");
65
+ var artifactsRegistry_1 = require("../deploy/cloudRun/artifactsRegistry");
66
+ var gcloudServiceAccountLoginCommands_1 = require("../deploy/cloudRun/utils/gcloudServiceAccountLoginCommands");
33
67
  var DOCKER_RUNNER_BUILD_VARIABLES = {
34
68
  KUBERNETES_CPU_REQUEST: "0.5",
35
69
  KUBERNETES_CPU_LIMIT: "1",
@@ -37,14 +71,21 @@ var DOCKER_RUNNER_BUILD_VARIABLES = {
37
71
  KUBERNETES_MEMORY_LIMIT: "2Gi"
38
72
  };
39
73
  var getDockerImageVariables = function (context) {
40
- return {
74
+ return __assign(__assign({}, (0, deploy_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun") ? {
75
+ DOCKER_REGISTRY: (0, artifactsRegistry_1.getArtifactsRegistryHost)(context),
76
+ DOCKER_IMAGE: (0, artifactsRegistry_1.getArtifactsRegistryImageName)(context),
77
+ DOCKER_CACHE_IMAGE: (0, artifactsRegistry_1.getArtifactsRegistryBuildCacheImage)(context)
78
+ } :
79
+ // gitlab registry:
80
+ {
41
81
  DOCKER_REGISTRY: "$CI_REGISTRY",
42
- DOCKER_REGISTRY_IMAGE_PATH: "$CI_REGISTRY_IMAGE",
43
- DOCKER_CACHE_IMAGE: "$DOCKER_REGISTRY_IMAGE_PATH/caches/" + context.componentName,
82
+ DOCKER_CACHE_IMAGE: "$CI_REGISTRY_IMAGE/caches/" + context.componentName,
83
+ // ONLY USED IN KUBERNETES
44
84
  DOCKER_IMAGE_NAME: context.environment.shortName + "/" + context.componentName,
45
- DOCKER_IMAGE: "$DOCKER_REGISTRY_IMAGE_PATH/$DOCKER_IMAGE_NAME",
85
+ DOCKER_IMAGE: "$CI_REGISTRY_IMAGE/$DOCKER_IMAGE_NAME"
86
+ }), {
46
87
  DOCKER_IMAGE_TAG: "$CI_COMMIT_SHA"
47
- };
88
+ });
48
89
  };
49
90
  exports.getDockerImageVariables = getDockerImageVariables;
50
91
  /**
@@ -99,9 +140,13 @@ var createDockerBuildJobBase = function (context, _a) {
99
140
  }, def);
100
141
  };
101
142
  exports.createDockerBuildJobBase = createDockerBuildJobBase;
102
- exports.gitlabDockerLogin = "docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY";
103
- var getDockerBuildDefaultScript = function (ensureDockerFileScript) {
104
- return [ensureDockerFileScript, exports.gitlabDockerLogin, "docker version", "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", "docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE", "docker push $DOCKER_CACHE_IMAGE"].filter(Boolean);
143
+ var gitlabDockerLogin = function (context) {
144
+ return (0, deploy_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun") ? __spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), ["gcloud auth configure-docker ".concat((0, artifactsRegistry_1.getArtifactsRegistryHost)(context))], false) : ["docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY"];
145
+ };
146
+ exports.gitlabDockerLogin = gitlabDockerLogin;
147
+ var getDockerBuildDefaultScript = function (context, ensureDockerFileScript) {
148
+ return __spreadArray(__spreadArray(__spreadArray([ensureDockerFileScript], __read((0, gitlab_1.collapseableSection)("docker-login", "Docker Login")((0, exports.gitlabDockerLogin)(context))), false), __read((0, gitlab_1.collapseableSection)("docker-build", "Docker build")(["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/
149
+ ])), false), __read((0, gitlab_1.collapseableSection)("docker-push", "Docker push and tag")(["docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE", "docker push $DOCKER_CACHE_IMAGE"])), false).filter(Boolean);
105
150
  };
106
151
  exports.getDockerBuildDefaultScript = getDockerBuildDefaultScript;
107
152
  var hasDockerfile = function (context) {
@@ -79,7 +79,7 @@ var createNodeBuildJobs = function (context) {
79
79
  jobTags: buildConfig.jobTags
80
80
  } : undefined,
81
81
  dockerBuild: {
82
- script: (0, docker_1.getDockerBuildDefaultScript)(buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "ensureNginxDockerfile" : "ensureNodeDockerfile"),
82
+ script: (0, docker_1.getDockerBuildDefaultScript)(context, buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "ensureNginxDockerfile" : "ensureNodeDockerfile"),
83
83
  cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context, "pull")), false),
84
84
  variables: {
85
85
  // only required for non static
@@ -66,7 +66,7 @@ var createMeteorBuildJobs = function (context) {
66
66
  }
67
67
  } : undefined,
68
68
  dockerBuild: {
69
- script: (0, docker_1.getDockerBuildDefaultScript)("ensureMeteorDockerfile"),
69
+ script: (0, docker_1.getDockerBuildDefaultScript)(context, "ensureMeteorDockerfile"),
70
70
  variables: {
71
71
  METEOR_INSTALL_SCRIPTS: buildConfig.installScripts ? "true" : ""
72
72
  }
@@ -32,6 +32,15 @@ var __read = this && this.__read || function (o, n) {
32
32
  }
33
33
  return ar;
34
34
  };
35
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
36
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
37
+ if (ar || !(i in from)) {
38
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
39
+ ar[i] = from[i];
40
+ }
41
+ }
42
+ return to.concat(ar || Array.prototype.slice.call(from));
43
+ };
35
44
  exports.__esModule = true;
36
45
  exports.createRailsBuildJobs = void 0;
37
46
  var base_1 = require("../base");
@@ -48,7 +57,7 @@ var createRailsBuildJobs = function (context) {
48
57
  return (0, base_1.createBuildJobs)(context, {
49
58
  appBuild: undefined,
50
59
  dockerBuild: {
51
- script: (0, docker_1.getDockerBuildDefaultScript)(),
60
+ script: (0, docker_1.getDockerBuildDefaultScript)(context),
52
61
  variables: {}
53
62
  }
54
63
  });
@@ -65,9 +74,9 @@ var createRailsBuildJobs = function (context) {
65
74
  dockerBuild: {
66
75
  variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
67
76
  // custom script
68
- script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
77
+ script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
69
78
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
70
- "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")]
79
+ "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")], false)
71
80
  }
72
81
  });
73
82
  };