@catladder/cli 0.0.0-update-docker-for-apps-e047cc44 → 0.0.0-update-node-b0c7282d
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/bundles/catenv/index.js +146 -49
- package/dist/bundles/cli/index.js +146 -49
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -39512,7 +39512,7 @@ var createCustomBuildJobs = function (context) {
|
|
|
39512
39512
|
}
|
|
39513
39513
|
} : undefined,
|
|
39514
39514
|
dockerBuild: {
|
|
39515
|
-
script: (0, docker_1.getDockerBuildDefaultScript)(((_d = buildConfig.docker) === null || _d === void 0 ? void 0 : _d.type) === "nginx" ? "ensureNginxDockerfile" : ""),
|
|
39515
|
+
script: (0, docker_1.getDockerBuildDefaultScript)(context, ((_d = buildConfig.docker) === null || _d === void 0 ? void 0 : _d.type) === "nginx" ? "ensureNginxDockerfile" : ""),
|
|
39516
39516
|
variables: {}
|
|
39517
39517
|
}
|
|
39518
39518
|
});
|
|
@@ -39697,6 +39697,37 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
39697
39697
|
}
|
|
39698
39698
|
return t;
|
|
39699
39699
|
};
|
|
39700
|
+
var __read = this && this.__read || function (o, n) {
|
|
39701
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
39702
|
+
if (!m) return o;
|
|
39703
|
+
var i = m.call(o),
|
|
39704
|
+
r,
|
|
39705
|
+
ar = [],
|
|
39706
|
+
e;
|
|
39707
|
+
try {
|
|
39708
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
39709
|
+
} catch (error) {
|
|
39710
|
+
e = {
|
|
39711
|
+
error: error
|
|
39712
|
+
};
|
|
39713
|
+
} finally {
|
|
39714
|
+
try {
|
|
39715
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
39716
|
+
} finally {
|
|
39717
|
+
if (e) throw e.error;
|
|
39718
|
+
}
|
|
39719
|
+
}
|
|
39720
|
+
return ar;
|
|
39721
|
+
};
|
|
39722
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
39723
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39724
|
+
if (ar || !(i in from)) {
|
|
39725
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
39726
|
+
ar[i] = from[i];
|
|
39727
|
+
}
|
|
39728
|
+
}
|
|
39729
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
39730
|
+
};
|
|
39700
39731
|
var __importDefault = this && this.__importDefault || function (mod) {
|
|
39701
39732
|
return mod && mod.__esModule ? mod : {
|
|
39702
39733
|
"default": mod
|
|
@@ -39709,6 +39740,9 @@ var deploy_1 = __nccwpck_require__(223);
|
|
|
39709
39740
|
var runner_1 = __nccwpck_require__(5071);
|
|
39710
39741
|
var fs_1 = __nccwpck_require__(7147);
|
|
39711
39742
|
var path_1 = __importDefault(__nccwpck_require__(1017));
|
|
39743
|
+
var gitlab_1 = __nccwpck_require__(4997);
|
|
39744
|
+
var artifactsRegistry_1 = __nccwpck_require__(8159);
|
|
39745
|
+
var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(2607);
|
|
39712
39746
|
var DOCKER_RUNNER_BUILD_VARIABLES = {
|
|
39713
39747
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
39714
39748
|
KUBERNETES_CPU_LIMIT: "1",
|
|
@@ -39716,14 +39750,21 @@ var DOCKER_RUNNER_BUILD_VARIABLES = {
|
|
|
39716
39750
|
KUBERNETES_MEMORY_LIMIT: "2Gi"
|
|
39717
39751
|
};
|
|
39718
39752
|
var getDockerImageVariables = function (context) {
|
|
39719
|
-
return {
|
|
39753
|
+
return __assign(__assign({}, (0, deploy_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun") ? {
|
|
39754
|
+
DOCKER_REGISTRY: (0, artifactsRegistry_1.getArtifactsRegistryHost)(context),
|
|
39755
|
+
DOCKER_IMAGE: (0, artifactsRegistry_1.getArtifactsRegistryImageName)(context),
|
|
39756
|
+
DOCKER_CACHE_IMAGE: (0, artifactsRegistry_1.getArtifactsRegistryBuildCacheImage)(context)
|
|
39757
|
+
} :
|
|
39758
|
+
// gitlab registry:
|
|
39759
|
+
{
|
|
39720
39760
|
DOCKER_REGISTRY: "$CI_REGISTRY",
|
|
39721
|
-
|
|
39722
|
-
|
|
39761
|
+
DOCKER_CACHE_IMAGE: "$CI_REGISTRY_IMAGE/caches/" + context.componentName,
|
|
39762
|
+
// ONLY USED IN KUBERNETES
|
|
39723
39763
|
DOCKER_IMAGE_NAME: context.environment.shortName + "/" + context.componentName,
|
|
39724
|
-
DOCKER_IMAGE: "$
|
|
39764
|
+
DOCKER_IMAGE: "$CI_REGISTRY_IMAGE/$DOCKER_IMAGE_NAME"
|
|
39765
|
+
}), {
|
|
39725
39766
|
DOCKER_IMAGE_TAG: "$CI_COMMIT_SHA"
|
|
39726
|
-
};
|
|
39767
|
+
});
|
|
39727
39768
|
};
|
|
39728
39769
|
exports.getDockerImageVariables = getDockerImageVariables;
|
|
39729
39770
|
/**
|
|
@@ -39778,9 +39819,13 @@ var createDockerBuildJobBase = function (context, _a) {
|
|
|
39778
39819
|
}, def);
|
|
39779
39820
|
};
|
|
39780
39821
|
exports.createDockerBuildJobBase = createDockerBuildJobBase;
|
|
39781
|
-
|
|
39782
|
-
|
|
39783
|
-
|
|
39822
|
+
var gitlabDockerLogin = function (context) {
|
|
39823
|
+
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"];
|
|
39824
|
+
};
|
|
39825
|
+
exports.gitlabDockerLogin = gitlabDockerLogin;
|
|
39826
|
+
var getDockerBuildDefaultScript = function (context, ensureDockerFileScript) {
|
|
39827
|
+
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/
|
|
39828
|
+
])), 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);
|
|
39784
39829
|
};
|
|
39785
39830
|
exports.getDockerBuildDefaultScript = getDockerBuildDefaultScript;
|
|
39786
39831
|
var hasDockerfile = function (context) {
|
|
@@ -39959,7 +40004,7 @@ var createNodeBuildJobs = function (context) {
|
|
|
39959
40004
|
jobTags: buildConfig.jobTags
|
|
39960
40005
|
} : undefined,
|
|
39961
40006
|
dockerBuild: {
|
|
39962
|
-
script: (0, docker_1.getDockerBuildDefaultScript)(buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "ensureNginxDockerfile" : "ensureNodeDockerfile"),
|
|
40007
|
+
script: (0, docker_1.getDockerBuildDefaultScript)(context, buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "ensureNginxDockerfile" : "ensureNodeDockerfile"),
|
|
39963
40008
|
cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context, "pull")), false),
|
|
39964
40009
|
variables: {
|
|
39965
40010
|
// only required for non static
|
|
@@ -40221,7 +40266,7 @@ var createMeteorBuildJobs = function (context) {
|
|
|
40221
40266
|
}
|
|
40222
40267
|
} : undefined,
|
|
40223
40268
|
dockerBuild: {
|
|
40224
|
-
script: (0, docker_1.getDockerBuildDefaultScript)("ensureMeteorDockerfile"),
|
|
40269
|
+
script: (0, docker_1.getDockerBuildDefaultScript)(context, "ensureMeteorDockerfile"),
|
|
40225
40270
|
variables: {
|
|
40226
40271
|
METEOR_INSTALL_SCRIPTS: buildConfig.installScripts ? "true" : ""
|
|
40227
40272
|
}
|
|
@@ -40453,6 +40498,15 @@ var __read = this && this.__read || function (o, n) {
|
|
|
40453
40498
|
}
|
|
40454
40499
|
return ar;
|
|
40455
40500
|
};
|
|
40501
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
40502
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40503
|
+
if (ar || !(i in from)) {
|
|
40504
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40505
|
+
ar[i] = from[i];
|
|
40506
|
+
}
|
|
40507
|
+
}
|
|
40508
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
40509
|
+
};
|
|
40456
40510
|
exports.__esModule = true;
|
|
40457
40511
|
exports.createRailsBuildJobs = void 0;
|
|
40458
40512
|
var base_1 = __nccwpck_require__(8035);
|
|
@@ -40469,7 +40523,7 @@ var createRailsBuildJobs = function (context) {
|
|
|
40469
40523
|
return (0, base_1.createBuildJobs)(context, {
|
|
40470
40524
|
appBuild: undefined,
|
|
40471
40525
|
dockerBuild: {
|
|
40472
|
-
script: (0, docker_1.getDockerBuildDefaultScript)(),
|
|
40526
|
+
script: (0, docker_1.getDockerBuildDefaultScript)(context),
|
|
40473
40527
|
variables: {}
|
|
40474
40528
|
}
|
|
40475
40529
|
});
|
|
@@ -40486,9 +40540,9 @@ var createRailsBuildJobs = function (context) {
|
|
|
40486
40540
|
dockerBuild: {
|
|
40487
40541
|
variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
|
|
40488
40542
|
// custom script
|
|
40489
|
-
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",
|
|
40543
|
+
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",
|
|
40490
40544
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
40491
|
-
"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 : "")]
|
|
40545
|
+
"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)
|
|
40492
40546
|
}
|
|
40493
40547
|
});
|
|
40494
40548
|
};
|
|
@@ -40871,7 +40925,7 @@ exports.readConfigSync = readConfigSync;
|
|
|
40871
40925
|
|
|
40872
40926
|
exports.__esModule = true;
|
|
40873
40927
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
40874
|
-
exports.PIPELINE_IMAGE_TAG = "update-
|
|
40928
|
+
exports.PIPELINE_IMAGE_TAG = "update-node-b0c7282d" || 0;
|
|
40875
40929
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
|
|
40876
40930
|
|
|
40877
40931
|
/***/ }),
|
|
@@ -42186,7 +42240,7 @@ var createDeployJob = function (context, jobDefinition) {
|
|
|
42186
42240
|
var _a, _b, _c, _d;
|
|
42187
42241
|
var hasDocker = (0, docker_1.requiresDockerBuild)(context);
|
|
42188
42242
|
var isStoppable = (0, utils_1.contextIsStoppable)(context);
|
|
42189
|
-
var autoStop = context.environment.envType === "review" ? "
|
|
42243
|
+
var autoStop = context.environment.envType === "review" ? "1 week" : context.environment.envType === "dev" ? "4 weeks" : undefined;
|
|
42190
42244
|
// if auto or manual is configured explicitly, use that
|
|
42191
42245
|
var whenDeployDefined = context.componentConfig.deploy && context.componentConfig.deploy.when ? context.componentConfig.deploy.when : undefined;
|
|
42192
42246
|
// otherwise auto deploy if env is not prod. If its prod, deploy automatically if stage is disabled
|
|
@@ -42435,11 +42489,29 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
42435
42489
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
42436
42490
|
};
|
|
42437
42491
|
exports.__esModule = true;
|
|
42438
|
-
exports.getDeleteUnusedImagesCommands = exports.
|
|
42439
|
-
var docker_1 = __nccwpck_require__(3219);
|
|
42492
|
+
exports.getDeleteUnusedImagesCommands = exports.getArtifactsRegistryImage = exports.getArtifactsRegistryBuildCacheImage = exports.getArtifactsRegistryImageName = exports.getArtifactsRegistryDockerUrl = exports.getArtifactsRegistryHost = void 0;
|
|
42440
42493
|
var gitlab_1 = __nccwpck_require__(4997);
|
|
42441
42494
|
var types_1 = __nccwpck_require__(3109);
|
|
42442
42495
|
var removeFirstLinesFromCommandOutput_1 = __nccwpck_require__(7547);
|
|
42496
|
+
var getArtifactsRegistryHost = function (_a) {
|
|
42497
|
+
var deploy = _a.componentConfig.deploy;
|
|
42498
|
+
if (!(0, types_1.isOfDeployType)(deploy, "google-cloudrun")) {
|
|
42499
|
+
// should not happen
|
|
42500
|
+
throw new Error("deploy config is wrong");
|
|
42501
|
+
}
|
|
42502
|
+
return "".concat(deploy.region, "-docker.pkg.dev");
|
|
42503
|
+
};
|
|
42504
|
+
exports.getArtifactsRegistryHost = getArtifactsRegistryHost;
|
|
42505
|
+
var getArtifactsRegistryDockerUrl = function (context) {
|
|
42506
|
+
var deployConfig = context.componentConfig.deploy;
|
|
42507
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
42508
|
+
// should not happen
|
|
42509
|
+
throw new Error("deploy config is wrong");
|
|
42510
|
+
}
|
|
42511
|
+
var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
|
|
42512
|
+
return "".concat((0, exports.getArtifactsRegistryHost)(context), "/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
42513
|
+
};
|
|
42514
|
+
exports.getArtifactsRegistryDockerUrl = getArtifactsRegistryDockerUrl;
|
|
42443
42515
|
/**
|
|
42444
42516
|
*
|
|
42445
42517
|
* lecacyReviewImageName is only temporary. In old versions the images had no reviewslug in review apps, which makes cleanup harder. We delete all those images now, but need the path
|
|
@@ -42449,37 +42521,25 @@ var getArtifactsRegistryImageName = function (context, lecacyReviewImageName) {
|
|
|
42449
42521
|
if (lecacyReviewImageName === void 0) {
|
|
42450
42522
|
lecacyReviewImageName = false;
|
|
42451
42523
|
}
|
|
42452
|
-
var deployConfig = context.componentConfig.deploy;
|
|
42453
|
-
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
42454
|
-
// should not happen
|
|
42455
|
-
throw new Error("deploy config is wrong");
|
|
42456
|
-
}
|
|
42457
42524
|
if (lecacyReviewImageName && context.environment.envType !== "review") {
|
|
42458
42525
|
throw new Error("lecacyReviewImageName is only allowed for review app");
|
|
42459
42526
|
}
|
|
42460
|
-
var
|
|
42461
|
-
var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
42527
|
+
var dockerUrl = (0, exports.getArtifactsRegistryDockerUrl)(context);
|
|
42462
42528
|
var gcloudImagePath = __spreadArray([dockerUrl, context.environment.shortName, context.componentName], __read(context.environment.envType === "review" && !lecacyReviewImageName ? [(_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.reviewSlug] : []), false);
|
|
42463
42529
|
return gcloudImagePath.join("/");
|
|
42464
42530
|
};
|
|
42465
42531
|
exports.getArtifactsRegistryImageName = getArtifactsRegistryImageName;
|
|
42532
|
+
var getArtifactsRegistryBuildCacheImage = function (context) {
|
|
42533
|
+
var dockerUrl = (0, exports.getArtifactsRegistryDockerUrl)(context);
|
|
42534
|
+
// does not include env, so that after merge, you might get more cache hits (review-->dev)
|
|
42535
|
+
var gcloudImagePath = [dockerUrl, "caches", context.componentName];
|
|
42536
|
+
return gcloudImagePath.join("/");
|
|
42537
|
+
};
|
|
42538
|
+
exports.getArtifactsRegistryBuildCacheImage = getArtifactsRegistryBuildCacheImage;
|
|
42466
42539
|
var getArtifactsRegistryImage = function (context) {
|
|
42467
42540
|
return "".concat((0, exports.getArtifactsRegistryImageName)(context), ":$DOCKER_IMAGE_TAG");
|
|
42468
42541
|
};
|
|
42469
42542
|
exports.getArtifactsRegistryImage = getArtifactsRegistryImage;
|
|
42470
|
-
/**
|
|
42471
|
-
* commands to pull the image from the default registry and pushes it to google artifact registry. We might build and push directly to google artifact registry in the future
|
|
42472
|
-
*/
|
|
42473
|
-
var getPushToArtifactsRegistryCommands = function (context) {
|
|
42474
|
-
var deployConfig = context.componentConfig.deploy;
|
|
42475
|
-
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
42476
|
-
// should not happen
|
|
42477
|
-
throw new Error("deploy config is wrong");
|
|
42478
|
-
}
|
|
42479
|
-
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
42480
|
-
return [docker_1.gitlabDockerLogin, "gcloud auth configure-docker ".concat(deployConfig.region, "-docker.pkg.dev"), "docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG ".concat(fullImageName, ":$DOCKER_IMAGE_TAG"), "docker push ".concat(fullImageName, ":$DOCKER_IMAGE_TAG")];
|
|
42481
|
-
};
|
|
42482
|
-
exports.getPushToArtifactsRegistryCommands = getPushToArtifactsRegistryCommands;
|
|
42483
42543
|
var getDeleteImageCommands = function (fullImageName, keepNewest) {
|
|
42484
42544
|
if (keepNewest === void 0) {
|
|
42485
42545
|
keepNewest = 0;
|
|
@@ -42515,7 +42575,8 @@ var getDeleteUnusedImagesCommands = function (context, keep) {
|
|
|
42515
42575
|
throw new Error("deploy config is wrong");
|
|
42516
42576
|
}
|
|
42517
42577
|
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
42518
|
-
|
|
42578
|
+
var buildCacheImageName = (0, exports.getArtifactsRegistryBuildCacheImage)(context);
|
|
42579
|
+
return __spreadArray(__spreadArray(__spreadArray([], __read(getDeleteImageCommands(fullImageName, keep)), false), __read(getDeleteImageCommands(buildCacheImageName, 1)), false), __read(context.environment.envType === "review" ? (0, gitlab_1.allowFailureInScripts)(getDeleteImageCommands((0, exports.getArtifactsRegistryImageName)(context, true), 0)) : []), false);
|
|
42519
42580
|
};
|
|
42520
42581
|
exports.getDeleteUnusedImagesCommands = getDeleteUnusedImagesCommands;
|
|
42521
42582
|
|
|
@@ -42713,7 +42774,7 @@ var jobName_1 = __nccwpck_require__(7311);
|
|
|
42713
42774
|
var artifactsRegistry_1 = __nccwpck_require__(8159);
|
|
42714
42775
|
var getServiceName_1 = __nccwpck_require__(9391);
|
|
42715
42776
|
var cleanup_1 = __nccwpck_require__(964);
|
|
42716
|
-
var
|
|
42777
|
+
var setGoogleProjectNumberScript = function (deployConfig) {
|
|
42717
42778
|
return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
|
|
42718
42779
|
};
|
|
42719
42780
|
var createGoogleCloudRunDeployJobs = function (context) {
|
|
@@ -42775,9 +42836,10 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
42775
42836
|
var _a, _b, _c, _d, _e;
|
|
42776
42837
|
var customConfig = service !== true ? service : undefined;
|
|
42777
42838
|
var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
|
|
42839
|
+
var commandArray = command ? Array.isArray(command) ? command : command.split(" ") : undefined;
|
|
42778
42840
|
var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
|
|
42779
42841
|
// command as empty string resets it to default (uses the image's entrypoint)
|
|
42780
|
-
command:
|
|
42842
|
+
command: commandArray ? '"' + commandArray.join(",") + '"' : '""'
|
|
42781
42843
|
}, commonDeployArgs), {
|
|
42782
42844
|
"env-vars-file": "____envvars.yaml",
|
|
42783
42845
|
"min-instances": (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _b !== void 0 ? _b : 0,
|
|
@@ -42794,9 +42856,11 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
42794
42856
|
// due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
|
|
42795
42857
|
// lucky, update on the other hand accepts it... so let's just imediatly update it
|
|
42796
42858
|
// also we cannot upsert a job, so we have to create it and catch the error and then update
|
|
42859
|
+
var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
|
|
42797
42860
|
var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
|
|
42798
|
-
command: '"' +
|
|
42861
|
+
command: '"' + commandArray.join(",") + '"'
|
|
42799
42862
|
}, commonDeployArgs), {
|
|
42863
|
+
image: job.image || commonDeployArgs.image,
|
|
42800
42864
|
memory: job.memory || "512Mi",
|
|
42801
42865
|
"task-timeout": job.timeout || "10m"
|
|
42802
42866
|
}));
|
|
@@ -42811,8 +42875,8 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
42811
42875
|
return getJobCreateScriptsForJob(jobName, job);
|
|
42812
42876
|
}).flat();
|
|
42813
42877
|
};
|
|
42814
|
-
var getJobRunScriptForJob = function (jobName) {
|
|
42815
|
-
return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgsString);
|
|
42878
|
+
var getJobRunScriptForJob = function (jobName, wait) {
|
|
42879
|
+
return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgsString).concat(wait ? " --wait" : "");
|
|
42816
42880
|
};
|
|
42817
42881
|
var getJobRunScripts = function (when) {
|
|
42818
42882
|
return jobsWithNames.filter(function (_a) {
|
|
@@ -42820,7 +42884,9 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
42820
42884
|
return job.when === when;
|
|
42821
42885
|
}).map(function (_a) {
|
|
42822
42886
|
var jobName = _a.jobName;
|
|
42823
|
-
return getJobRunScriptForJob(jobName
|
|
42887
|
+
return getJobRunScriptForJob(jobName,
|
|
42888
|
+
// wait for completin on stop jobs, since stop will delete the jobs afterwards, so they will fail
|
|
42889
|
+
["preStop", "postStop"].includes(when));
|
|
42824
42890
|
});
|
|
42825
42891
|
};
|
|
42826
42892
|
var getCreateScheduleScripts = function () {
|
|
@@ -42860,7 +42926,7 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
42860
42926
|
"gcloud beta run jobs executions list ".concat(commonArgsString, " --job ").concat(jobName, " --format=\"value(name)\" | xargs -I {} gcloud beta run jobs executions delete {} --quiet ").concat(commonArgsString), "gcloud beta run jobs delete ".concat(jobName, " ").concat(commonArgsString)];
|
|
42861
42927
|
});
|
|
42862
42928
|
};
|
|
42863
|
-
var deployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(
|
|
42929
|
+
var deployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gitlab_1.collapseableSection)("prepare", "Prepare...")(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(setGoogleProjectNumberScript(deployConfig)), false))), false), __read((0, gitlab_1.collapseableSection)("deploy", "Deploy to cloud run")(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(["echo \"$ENV_VARS\" > ____envvars.yaml"], __read(deployConfig.cloudSql ? (0, database_1.getDatabaseCreateScript)(context, deployConfig) // we create the db, so that we can also delete it afterwards
|
|
42864
42930
|
: []), false), __read(getCreateScheduleScripts()), false), __read(getJobCreateScripts()), false), __read(getJobRunScripts("preDeploy")), false), __read(deployConfig.service !== false ? [getServiceDeployScript(deployConfig.service)] : []), false), __read(Object.entries((_b = deployConfig.additionalServices) !== null && _b !== void 0 ? _b : {}).map(function (_a) {
|
|
42865
42931
|
var _b = __read(_a, 2),
|
|
42866
42932
|
name = _b[0],
|
|
@@ -42868,11 +42934,11 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
42868
42934
|
return getServiceDeployScript(service, "-" + name);
|
|
42869
42935
|
})), false), __read(getJobRunScripts("postDeploy")), false))), false), __read((0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy") // we cleanup inactive images both on deploy and stop
|
|
42870
42936
|
)), false), __read((0, sbom_1.getDependencyTrackUploadScript)(context)), false);
|
|
42871
|
-
var stopScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(deployConfig.service !== false ? ["gcloud run services delete ".concat(serviceName, " ").concat(commonArgsString)] : []), false), __read(Object.entries((_c = deployConfig.additionalServices) !== null && _c !== void 0 ? _c : {}).map(function (_a) {
|
|
42937
|
+
var stopScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context)), false), __read(getJobRunScripts("preStop")), false), __read(deployConfig.service !== false ? ["gcloud run services delete ".concat(serviceName, " ").concat(commonArgsString)] : []), false), __read(Object.entries((_c = deployConfig.additionalServices) !== null && _c !== void 0 ? _c : {}).map(function (_a) {
|
|
42872
42938
|
var _b = __read(_a, 1),
|
|
42873
42939
|
name = _b[0];
|
|
42874
42940
|
return "gcloud run services delete ".concat(serviceName, "-").concat(name, " ").concat(commonArgsString);
|
|
42875
|
-
})), false), __read(getDeleteSchedulesScripts()), false), __read(getDeleteJobsScripts()), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false), __read((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "onStop")), false), __read((0, sbom_1.getDependencyTrackDeleteScript)(context)), false);
|
|
42941
|
+
})), false), __read(getJobRunScripts("postStop")), false), __read(getDeleteSchedulesScripts()), false), __read(getDeleteJobsScripts()), false), __read(deployConfig.cloudSql && deployConfig.cloudSql.deleteDatabaseOnStop ? (0, database_1.getDatabaseDeleteScript)(context, deployConfig) : []), false), __read((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "onStop")), false), __read((0, sbom_1.getDependencyTrackDeleteScript)(context)), false);
|
|
42876
42942
|
return (0, base_1.createDeployementJobs)(context, {
|
|
42877
42943
|
deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
|
|
42878
42944
|
artifacts: {
|
|
@@ -43365,6 +43431,37 @@ var __assign = this && this.__assign || function () {
|
|
|
43365
43431
|
};
|
|
43366
43432
|
return __assign.apply(this, arguments);
|
|
43367
43433
|
};
|
|
43434
|
+
var __read = this && this.__read || function (o, n) {
|
|
43435
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
43436
|
+
if (!m) return o;
|
|
43437
|
+
var i = m.call(o),
|
|
43438
|
+
r,
|
|
43439
|
+
ar = [],
|
|
43440
|
+
e;
|
|
43441
|
+
try {
|
|
43442
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43443
|
+
} catch (error) {
|
|
43444
|
+
e = {
|
|
43445
|
+
error: error
|
|
43446
|
+
};
|
|
43447
|
+
} finally {
|
|
43448
|
+
try {
|
|
43449
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
43450
|
+
} finally {
|
|
43451
|
+
if (e) throw e.error;
|
|
43452
|
+
}
|
|
43453
|
+
}
|
|
43454
|
+
return ar;
|
|
43455
|
+
};
|
|
43456
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
43457
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
43458
|
+
if (ar || !(i in from)) {
|
|
43459
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
43460
|
+
ar[i] = from[i];
|
|
43461
|
+
}
|
|
43462
|
+
}
|
|
43463
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
43464
|
+
};
|
|
43368
43465
|
exports.__esModule = true;
|
|
43369
43466
|
exports.createDockerTagDeployJobs = void 0;
|
|
43370
43467
|
var docker_1 = __nccwpck_require__(3219);
|
|
@@ -43382,7 +43479,7 @@ var createDockerTagDeployJobs = function (context) {
|
|
|
43382
43479
|
var tag = deployConfig.tag;
|
|
43383
43480
|
return (0, base_1.createDeployementJobs)(context, {
|
|
43384
43481
|
deploy: __assign(__assign({}, (0, docker_1.getDockerJobBaseProps)(context)), {
|
|
43385
|
-
script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_IMAGE:".concat(tag), "docker push $DOCKER_IMAGE:".concat(tag), "echo \"pushed as $DOCKER_IMAGE:".concat(tag, "\"")]
|
|
43482
|
+
script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["docker pull $DOCKER_IMAGE:$DOCKER_IMAGE_TAG", "docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_IMAGE:".concat(tag), "docker push $DOCKER_IMAGE:".concat(tag), "echo \"pushed as $DOCKER_IMAGE:".concat(tag, "\"")], false)
|
|
43386
43483
|
})
|
|
43387
43484
|
});
|
|
43388
43485
|
};
|