@catladder/pipeline 1.124.0 → 1.124.2

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 +20 -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 +48 -72
  15. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +48 -72
  16. package/examples/__snapshots__/cloud-run-non-public.ts.snap +48 -72
  17. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +96 -144
  18. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +96 -144
  19. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +48 -72
  20. package/examples/__snapshots__/custom-build-job.ts.snap +48 -72
  21. package/examples/__snapshots__/custom-deploy.ts.snap +16 -24
  22. package/examples/__snapshots__/custom-sbom-java.ts.snap +48 -72
  23. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +16 -24
  24. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +16 -24
  25. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +16 -24
  26. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +32 -48
  27. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +16 -24
  28. package/examples/__snapshots__/meteor-kubernetes.ts.snap +16 -24
  29. package/examples/__snapshots__/native-app.ts.snap +48 -72
  30. package/examples/__snapshots__/node-build-with-custom-image.ts.snap +48 -72
  31. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +32 -48
  32. package/package.json +1 -1
  33. package/src/build/custom/buildJob.ts +1 -0
  34. package/src/build/docker.ts +41 -11
  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;
@@ -62,6 +62,8 @@ var runner_1 = require("../runner");
62
62
  var fs_1 = require("fs");
63
63
  var path_1 = __importDefault(require("path"));
64
64
  var gitlab_1 = require("../utils/gitlab");
65
+ var artifactsRegistry_1 = require("../deploy/cloudRun/artifactsRegistry");
66
+ var gcloudServiceAccountLoginCommands_1 = require("../deploy/cloudRun/utils/gcloudServiceAccountLoginCommands");
65
67
  var DOCKER_RUNNER_BUILD_VARIABLES = {
66
68
  KUBERNETES_CPU_REQUEST: "0.5",
67
69
  KUBERNETES_CPU_LIMIT: "1",
@@ -69,14 +71,21 @@ var DOCKER_RUNNER_BUILD_VARIABLES = {
69
71
  KUBERNETES_MEMORY_LIMIT: "2Gi"
70
72
  };
71
73
  var getDockerImageVariables = function (context) {
72
- 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
+ {
73
81
  DOCKER_REGISTRY: "$CI_REGISTRY",
74
- DOCKER_REGISTRY_IMAGE_PATH: "$CI_REGISTRY_IMAGE",
75
- 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
76
84
  DOCKER_IMAGE_NAME: context.environment.shortName + "/" + context.componentName,
77
- DOCKER_IMAGE: "$DOCKER_REGISTRY_IMAGE_PATH/$DOCKER_IMAGE_NAME",
85
+ DOCKER_IMAGE: "$CI_REGISTRY_IMAGE/$DOCKER_IMAGE_NAME"
86
+ }), {
78
87
  DOCKER_IMAGE_TAG: "$CI_COMMIT_SHA"
79
- };
88
+ });
80
89
  };
81
90
  exports.getDockerImageVariables = getDockerImageVariables;
82
91
  /**
@@ -131,9 +140,12 @@ var createDockerBuildJobBase = function (context, _a) {
131
140
  }, def);
132
141
  };
133
142
  exports.createDockerBuildJobBase = createDockerBuildJobBase;
134
- exports.gitlabDockerLogin = "docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY";
135
- var getDockerBuildDefaultScript = function (ensureDockerFileScript) {
136
- return __spreadArray(__spreadArray(__spreadArray([ensureDockerFileScript], __read((0, gitlab_1.collapseableSection)("docker-login", "Docker Login")([exports.gitlabDockerLogin])), 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/
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/
137
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);
138
150
  };
139
151
  exports.getDockerBuildDefaultScript = getDockerBuildDefaultScript;
@@ -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
  };