@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
|
@@ -354051,7 +354051,7 @@ var createCustomBuildJobs = function (context) {
|
|
|
354051
354051
|
}
|
|
354052
354052
|
} : undefined,
|
|
354053
354053
|
dockerBuild: {
|
|
354054
|
-
script: (0, docker_1.getDockerBuildDefaultScript)(((_d = buildConfig.docker) === null || _d === void 0 ? void 0 : _d.type) === "nginx" ? "ensureNginxDockerfile" : ""),
|
|
354054
|
+
script: (0, docker_1.getDockerBuildDefaultScript)(context, ((_d = buildConfig.docker) === null || _d === void 0 ? void 0 : _d.type) === "nginx" ? "ensureNginxDockerfile" : ""),
|
|
354055
354055
|
variables: {}
|
|
354056
354056
|
}
|
|
354057
354057
|
});
|
|
@@ -354236,6 +354236,37 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
354236
354236
|
}
|
|
354237
354237
|
return t;
|
|
354238
354238
|
};
|
|
354239
|
+
var __read = this && this.__read || function (o, n) {
|
|
354240
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
354241
|
+
if (!m) return o;
|
|
354242
|
+
var i = m.call(o),
|
|
354243
|
+
r,
|
|
354244
|
+
ar = [],
|
|
354245
|
+
e;
|
|
354246
|
+
try {
|
|
354247
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
354248
|
+
} catch (error) {
|
|
354249
|
+
e = {
|
|
354250
|
+
error: error
|
|
354251
|
+
};
|
|
354252
|
+
} finally {
|
|
354253
|
+
try {
|
|
354254
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
354255
|
+
} finally {
|
|
354256
|
+
if (e) throw e.error;
|
|
354257
|
+
}
|
|
354258
|
+
}
|
|
354259
|
+
return ar;
|
|
354260
|
+
};
|
|
354261
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
354262
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
354263
|
+
if (ar || !(i in from)) {
|
|
354264
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
354265
|
+
ar[i] = from[i];
|
|
354266
|
+
}
|
|
354267
|
+
}
|
|
354268
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
354269
|
+
};
|
|
354239
354270
|
var __importDefault = this && this.__importDefault || function (mod) {
|
|
354240
354271
|
return mod && mod.__esModule ? mod : {
|
|
354241
354272
|
"default": mod
|
|
@@ -354248,6 +354279,9 @@ var deploy_1 = __nccwpck_require__(90223);
|
|
|
354248
354279
|
var runner_1 = __nccwpck_require__(55071);
|
|
354249
354280
|
var fs_1 = __nccwpck_require__(57147);
|
|
354250
354281
|
var path_1 = __importDefault(__nccwpck_require__(71017));
|
|
354282
|
+
var gitlab_1 = __nccwpck_require__(84997);
|
|
354283
|
+
var artifactsRegistry_1 = __nccwpck_require__(28159);
|
|
354284
|
+
var gcloudServiceAccountLoginCommands_1 = __nccwpck_require__(22607);
|
|
354251
354285
|
var DOCKER_RUNNER_BUILD_VARIABLES = {
|
|
354252
354286
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
354253
354287
|
KUBERNETES_CPU_LIMIT: "1",
|
|
@@ -354255,14 +354289,21 @@ var DOCKER_RUNNER_BUILD_VARIABLES = {
|
|
|
354255
354289
|
KUBERNETES_MEMORY_LIMIT: "2Gi"
|
|
354256
354290
|
};
|
|
354257
354291
|
var getDockerImageVariables = function (context) {
|
|
354258
|
-
return {
|
|
354292
|
+
return __assign(__assign({}, (0, deploy_1.isOfDeployType)(context.componentConfig.deploy, "google-cloudrun") ? {
|
|
354293
|
+
DOCKER_REGISTRY: (0, artifactsRegistry_1.getArtifactsRegistryHost)(context),
|
|
354294
|
+
DOCKER_IMAGE: (0, artifactsRegistry_1.getArtifactsRegistryImageName)(context),
|
|
354295
|
+
DOCKER_CACHE_IMAGE: (0, artifactsRegistry_1.getArtifactsRegistryBuildCacheImage)(context)
|
|
354296
|
+
} :
|
|
354297
|
+
// gitlab registry:
|
|
354298
|
+
{
|
|
354259
354299
|
DOCKER_REGISTRY: "$CI_REGISTRY",
|
|
354260
|
-
|
|
354261
|
-
|
|
354300
|
+
DOCKER_CACHE_IMAGE: "$CI_REGISTRY_IMAGE/caches/" + context.componentName,
|
|
354301
|
+
// ONLY USED IN KUBERNETES
|
|
354262
354302
|
DOCKER_IMAGE_NAME: context.environment.shortName + "/" + context.componentName,
|
|
354263
|
-
DOCKER_IMAGE: "$
|
|
354303
|
+
DOCKER_IMAGE: "$CI_REGISTRY_IMAGE/$DOCKER_IMAGE_NAME"
|
|
354304
|
+
}), {
|
|
354264
354305
|
DOCKER_IMAGE_TAG: "$CI_COMMIT_SHA"
|
|
354265
|
-
};
|
|
354306
|
+
});
|
|
354266
354307
|
};
|
|
354267
354308
|
exports.getDockerImageVariables = getDockerImageVariables;
|
|
354268
354309
|
/**
|
|
@@ -354317,9 +354358,13 @@ var createDockerBuildJobBase = function (context, _a) {
|
|
|
354317
354358
|
}, def);
|
|
354318
354359
|
};
|
|
354319
354360
|
exports.createDockerBuildJobBase = createDockerBuildJobBase;
|
|
354320
|
-
|
|
354321
|
-
|
|
354322
|
-
|
|
354361
|
+
var gitlabDockerLogin = function (context) {
|
|
354362
|
+
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"];
|
|
354363
|
+
};
|
|
354364
|
+
exports.gitlabDockerLogin = gitlabDockerLogin;
|
|
354365
|
+
var getDockerBuildDefaultScript = function (context, ensureDockerFileScript) {
|
|
354366
|
+
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/
|
|
354367
|
+
])), 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);
|
|
354323
354368
|
};
|
|
354324
354369
|
exports.getDockerBuildDefaultScript = getDockerBuildDefaultScript;
|
|
354325
354370
|
var hasDockerfile = function (context) {
|
|
@@ -354498,7 +354543,7 @@ var createNodeBuildJobs = function (context) {
|
|
|
354498
354543
|
jobTags: buildConfig.jobTags
|
|
354499
354544
|
} : undefined,
|
|
354500
354545
|
dockerBuild: {
|
|
354501
|
-
script: (0, docker_1.getDockerBuildDefaultScript)(buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "ensureNginxDockerfile" : "ensureNodeDockerfile"),
|
|
354546
|
+
script: (0, docker_1.getDockerBuildDefaultScript)(context, buildConfig.type === "node-static" || buildConfig.type === "storybook" ? "ensureNginxDockerfile" : "ensureNodeDockerfile"),
|
|
354502
354547
|
cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context, "pull")), false),
|
|
354503
354548
|
variables: {
|
|
354504
354549
|
// only required for non static
|
|
@@ -354760,7 +354805,7 @@ var createMeteorBuildJobs = function (context) {
|
|
|
354760
354805
|
}
|
|
354761
354806
|
} : undefined,
|
|
354762
354807
|
dockerBuild: {
|
|
354763
|
-
script: (0, docker_1.getDockerBuildDefaultScript)("ensureMeteorDockerfile"),
|
|
354808
|
+
script: (0, docker_1.getDockerBuildDefaultScript)(context, "ensureMeteorDockerfile"),
|
|
354764
354809
|
variables: {
|
|
354765
354810
|
METEOR_INSTALL_SCRIPTS: buildConfig.installScripts ? "true" : ""
|
|
354766
354811
|
}
|
|
@@ -354992,6 +355037,15 @@ var __read = this && this.__read || function (o, n) {
|
|
|
354992
355037
|
}
|
|
354993
355038
|
return ar;
|
|
354994
355039
|
};
|
|
355040
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
355041
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
355042
|
+
if (ar || !(i in from)) {
|
|
355043
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
355044
|
+
ar[i] = from[i];
|
|
355045
|
+
}
|
|
355046
|
+
}
|
|
355047
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
355048
|
+
};
|
|
354995
355049
|
exports.__esModule = true;
|
|
354996
355050
|
exports.createRailsBuildJobs = void 0;
|
|
354997
355051
|
var base_1 = __nccwpck_require__(18035);
|
|
@@ -355008,7 +355062,7 @@ var createRailsBuildJobs = function (context) {
|
|
|
355008
355062
|
return (0, base_1.createBuildJobs)(context, {
|
|
355009
355063
|
appBuild: undefined,
|
|
355010
355064
|
dockerBuild: {
|
|
355011
|
-
script: (0, docker_1.getDockerBuildDefaultScript)(),
|
|
355065
|
+
script: (0, docker_1.getDockerBuildDefaultScript)(context),
|
|
355012
355066
|
variables: {}
|
|
355013
355067
|
}
|
|
355014
355068
|
});
|
|
@@ -355025,9 +355079,9 @@ var createRailsBuildJobs = function (context) {
|
|
|
355025
355079
|
dockerBuild: {
|
|
355026
355080
|
variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
|
|
355027
355081
|
// custom script
|
|
355028
|
-
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",
|
|
355082
|
+
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",
|
|
355029
355083
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
355030
|
-
"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 : "")]
|
|
355084
|
+
"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)
|
|
355031
355085
|
}
|
|
355032
355086
|
});
|
|
355033
355087
|
};
|
|
@@ -355410,7 +355464,7 @@ exports.readConfigSync = readConfigSync;
|
|
|
355410
355464
|
|
|
355411
355465
|
exports.__esModule = true;
|
|
355412
355466
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
355413
|
-
exports.PIPELINE_IMAGE_TAG = "update-
|
|
355467
|
+
exports.PIPELINE_IMAGE_TAG = "update-node-b0c7282d" || 0;
|
|
355414
355468
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
|
|
355415
355469
|
|
|
355416
355470
|
/***/ }),
|
|
@@ -356725,7 +356779,7 @@ var createDeployJob = function (context, jobDefinition) {
|
|
|
356725
356779
|
var _a, _b, _c, _d;
|
|
356726
356780
|
var hasDocker = (0, docker_1.requiresDockerBuild)(context);
|
|
356727
356781
|
var isStoppable = (0, utils_1.contextIsStoppable)(context);
|
|
356728
|
-
var autoStop = context.environment.envType === "review" ? "
|
|
356782
|
+
var autoStop = context.environment.envType === "review" ? "1 week" : context.environment.envType === "dev" ? "4 weeks" : undefined;
|
|
356729
356783
|
// if auto or manual is configured explicitly, use that
|
|
356730
356784
|
var whenDeployDefined = context.componentConfig.deploy && context.componentConfig.deploy.when ? context.componentConfig.deploy.when : undefined;
|
|
356731
356785
|
// otherwise auto deploy if env is not prod. If its prod, deploy automatically if stage is disabled
|
|
@@ -356974,11 +357028,29 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
356974
357028
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
356975
357029
|
};
|
|
356976
357030
|
exports.__esModule = true;
|
|
356977
|
-
exports.getDeleteUnusedImagesCommands = exports.
|
|
356978
|
-
var docker_1 = __nccwpck_require__(33219);
|
|
357031
|
+
exports.getDeleteUnusedImagesCommands = exports.getArtifactsRegistryImage = exports.getArtifactsRegistryBuildCacheImage = exports.getArtifactsRegistryImageName = exports.getArtifactsRegistryDockerUrl = exports.getArtifactsRegistryHost = void 0;
|
|
356979
357032
|
var gitlab_1 = __nccwpck_require__(84997);
|
|
356980
357033
|
var types_1 = __nccwpck_require__(63109);
|
|
356981
357034
|
var removeFirstLinesFromCommandOutput_1 = __nccwpck_require__(77547);
|
|
357035
|
+
var getArtifactsRegistryHost = function (_a) {
|
|
357036
|
+
var deploy = _a.componentConfig.deploy;
|
|
357037
|
+
if (!(0, types_1.isOfDeployType)(deploy, "google-cloudrun")) {
|
|
357038
|
+
// should not happen
|
|
357039
|
+
throw new Error("deploy config is wrong");
|
|
357040
|
+
}
|
|
357041
|
+
return "".concat(deploy.region, "-docker.pkg.dev");
|
|
357042
|
+
};
|
|
357043
|
+
exports.getArtifactsRegistryHost = getArtifactsRegistryHost;
|
|
357044
|
+
var getArtifactsRegistryDockerUrl = function (context) {
|
|
357045
|
+
var deployConfig = context.componentConfig.deploy;
|
|
357046
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
357047
|
+
// should not happen
|
|
357048
|
+
throw new Error("deploy config is wrong");
|
|
357049
|
+
}
|
|
357050
|
+
var fullAppName = "".concat(context.fullConfig.customerName, "-").concat(context.fullConfig.appName);
|
|
357051
|
+
return "".concat((0, exports.getArtifactsRegistryHost)(context), "/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
357052
|
+
};
|
|
357053
|
+
exports.getArtifactsRegistryDockerUrl = getArtifactsRegistryDockerUrl;
|
|
356982
357054
|
/**
|
|
356983
357055
|
*
|
|
356984
357056
|
* 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
|
|
@@ -356988,37 +357060,25 @@ var getArtifactsRegistryImageName = function (context, lecacyReviewImageName) {
|
|
|
356988
357060
|
if (lecacyReviewImageName === void 0) {
|
|
356989
357061
|
lecacyReviewImageName = false;
|
|
356990
357062
|
}
|
|
356991
|
-
var deployConfig = context.componentConfig.deploy;
|
|
356992
|
-
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
356993
|
-
// should not happen
|
|
356994
|
-
throw new Error("deploy config is wrong");
|
|
356995
|
-
}
|
|
356996
357063
|
if (lecacyReviewImageName && context.environment.envType !== "review") {
|
|
356997
357064
|
throw new Error("lecacyReviewImageName is only allowed for review app");
|
|
356998
357065
|
}
|
|
356999
|
-
var
|
|
357000
|
-
var dockerUrl = "".concat(deployConfig.region, "-docker.pkg.dev/").concat(deployConfig.projectId, "/catladder-deploy/").concat(fullAppName);
|
|
357066
|
+
var dockerUrl = (0, exports.getArtifactsRegistryDockerUrl)(context);
|
|
357001
357067
|
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);
|
|
357002
357068
|
return gcloudImagePath.join("/");
|
|
357003
357069
|
};
|
|
357004
357070
|
exports.getArtifactsRegistryImageName = getArtifactsRegistryImageName;
|
|
357071
|
+
var getArtifactsRegistryBuildCacheImage = function (context) {
|
|
357072
|
+
var dockerUrl = (0, exports.getArtifactsRegistryDockerUrl)(context);
|
|
357073
|
+
// does not include env, so that after merge, you might get more cache hits (review-->dev)
|
|
357074
|
+
var gcloudImagePath = [dockerUrl, "caches", context.componentName];
|
|
357075
|
+
return gcloudImagePath.join("/");
|
|
357076
|
+
};
|
|
357077
|
+
exports.getArtifactsRegistryBuildCacheImage = getArtifactsRegistryBuildCacheImage;
|
|
357005
357078
|
var getArtifactsRegistryImage = function (context) {
|
|
357006
357079
|
return "".concat((0, exports.getArtifactsRegistryImageName)(context), ":$DOCKER_IMAGE_TAG");
|
|
357007
357080
|
};
|
|
357008
357081
|
exports.getArtifactsRegistryImage = getArtifactsRegistryImage;
|
|
357009
|
-
/**
|
|
357010
|
-
* 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
|
|
357011
|
-
*/
|
|
357012
|
-
var getPushToArtifactsRegistryCommands = function (context) {
|
|
357013
|
-
var deployConfig = context.componentConfig.deploy;
|
|
357014
|
-
if (!(0, types_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
|
|
357015
|
-
// should not happen
|
|
357016
|
-
throw new Error("deploy config is wrong");
|
|
357017
|
-
}
|
|
357018
|
-
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
357019
|
-
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")];
|
|
357020
|
-
};
|
|
357021
|
-
exports.getPushToArtifactsRegistryCommands = getPushToArtifactsRegistryCommands;
|
|
357022
357082
|
var getDeleteImageCommands = function (fullImageName, keepNewest) {
|
|
357023
357083
|
if (keepNewest === void 0) {
|
|
357024
357084
|
keepNewest = 0;
|
|
@@ -357054,7 +357114,8 @@ var getDeleteUnusedImagesCommands = function (context, keep) {
|
|
|
357054
357114
|
throw new Error("deploy config is wrong");
|
|
357055
357115
|
}
|
|
357056
357116
|
var fullImageName = (0, exports.getArtifactsRegistryImageName)(context);
|
|
357057
|
-
|
|
357117
|
+
var buildCacheImageName = (0, exports.getArtifactsRegistryBuildCacheImage)(context);
|
|
357118
|
+
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);
|
|
357058
357119
|
};
|
|
357059
357120
|
exports.getDeleteUnusedImagesCommands = getDeleteUnusedImagesCommands;
|
|
357060
357121
|
|
|
@@ -357252,7 +357313,7 @@ var jobName_1 = __nccwpck_require__(77311);
|
|
|
357252
357313
|
var artifactsRegistry_1 = __nccwpck_require__(28159);
|
|
357253
357314
|
var getServiceName_1 = __nccwpck_require__(89391);
|
|
357254
357315
|
var cleanup_1 = __nccwpck_require__(10964);
|
|
357255
|
-
var
|
|
357316
|
+
var setGoogleProjectNumberScript = function (deployConfig) {
|
|
357256
357317
|
return ["export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe ".concat(deployConfig.projectId, " --format=\"value(projectNumber)\")"), "echo \"GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER\""];
|
|
357257
357318
|
};
|
|
357258
357319
|
var createGoogleCloudRunDeployJobs = function (context) {
|
|
@@ -357314,9 +357375,10 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
357314
357375
|
var _a, _b, _c, _d, _e;
|
|
357315
357376
|
var customConfig = service !== true ? service : undefined;
|
|
357316
357377
|
var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
|
|
357378
|
+
var commandArray = command ? Array.isArray(command) ? command : command.split(" ") : undefined;
|
|
357317
357379
|
var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
|
|
357318
357380
|
// command as empty string resets it to default (uses the image's entrypoint)
|
|
357319
|
-
command:
|
|
357381
|
+
command: commandArray ? '"' + commandArray.join(",") + '"' : '""'
|
|
357320
357382
|
}, commonDeployArgs), {
|
|
357321
357383
|
"env-vars-file": "____envvars.yaml",
|
|
357322
357384
|
"min-instances": (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _b !== void 0 ? _b : 0,
|
|
@@ -357333,9 +357395,11 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
357333
357395
|
// due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
|
|
357334
357396
|
// lucky, update on the other hand accepts it... so let's just imediatly update it
|
|
357335
357397
|
// also we cannot upsert a job, so we have to create it and catch the error and then update
|
|
357398
|
+
var commandArray = Array.isArray(job.command) ? job.command : job.command.split(" ");
|
|
357336
357399
|
var commonDeployArgsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
|
|
357337
|
-
command: '"' +
|
|
357400
|
+
command: '"' + commandArray.join(",") + '"'
|
|
357338
357401
|
}, commonDeployArgs), {
|
|
357402
|
+
image: job.image || commonDeployArgs.image,
|
|
357339
357403
|
memory: job.memory || "512Mi",
|
|
357340
357404
|
"task-timeout": job.timeout || "10m"
|
|
357341
357405
|
}));
|
|
@@ -357350,8 +357414,8 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
357350
357414
|
return getJobCreateScriptsForJob(jobName, job);
|
|
357351
357415
|
}).flat();
|
|
357352
357416
|
};
|
|
357353
|
-
var getJobRunScriptForJob = function (jobName) {
|
|
357354
|
-
return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgsString);
|
|
357417
|
+
var getJobRunScriptForJob = function (jobName, wait) {
|
|
357418
|
+
return "gcloud beta run jobs execute ".concat(jobName, " ").concat(commonArgsString).concat(wait ? " --wait" : "");
|
|
357355
357419
|
};
|
|
357356
357420
|
var getJobRunScripts = function (when) {
|
|
357357
357421
|
return jobsWithNames.filter(function (_a) {
|
|
@@ -357359,7 +357423,9 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
357359
357423
|
return job.when === when;
|
|
357360
357424
|
}).map(function (_a) {
|
|
357361
357425
|
var jobName = _a.jobName;
|
|
357362
|
-
return getJobRunScriptForJob(jobName
|
|
357426
|
+
return getJobRunScriptForJob(jobName,
|
|
357427
|
+
// wait for completin on stop jobs, since stop will delete the jobs afterwards, so they will fail
|
|
357428
|
+
["preStop", "postStop"].includes(when));
|
|
357363
357429
|
});
|
|
357364
357430
|
};
|
|
357365
357431
|
var getCreateScheduleScripts = function () {
|
|
@@ -357399,7 +357465,7 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
357399
357465
|
"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)];
|
|
357400
357466
|
});
|
|
357401
357467
|
};
|
|
357402
|
-
var deployScripts = __spreadArray(__spreadArray(__spreadArray(__spreadArray(
|
|
357468
|
+
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
|
|
357403
357469
|
: []), 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) {
|
|
357404
357470
|
var _b = __read(_a, 2),
|
|
357405
357471
|
name = _b[0],
|
|
@@ -357407,11 +357473,11 @@ var createGoogleCloudRunDeployJobs = function (context) {
|
|
|
357407
357473
|
return getServiceDeployScript(service, "-" + name);
|
|
357408
357474
|
})), 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
|
|
357409
357475
|
)), false), __read((0, sbom_1.getDependencyTrackUploadScript)(context)), false);
|
|
357410
|
-
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) {
|
|
357476
|
+
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) {
|
|
357411
357477
|
var _b = __read(_a, 1),
|
|
357412
357478
|
name = _b[0];
|
|
357413
357479
|
return "gcloud run services delete ".concat(serviceName, "-").concat(name, " ").concat(commonArgsString);
|
|
357414
|
-
})), 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);
|
|
357480
|
+
})), 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);
|
|
357415
357481
|
return (0, base_1.createDeployementJobs)(context, {
|
|
357416
357482
|
deploy: (0, lodash_1.merge)((0, docker_1.getDockerJobBaseProps)(context), {
|
|
357417
357483
|
artifacts: {
|
|
@@ -357904,6 +357970,37 @@ var __assign = this && this.__assign || function () {
|
|
|
357904
357970
|
};
|
|
357905
357971
|
return __assign.apply(this, arguments);
|
|
357906
357972
|
};
|
|
357973
|
+
var __read = this && this.__read || function (o, n) {
|
|
357974
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
357975
|
+
if (!m) return o;
|
|
357976
|
+
var i = m.call(o),
|
|
357977
|
+
r,
|
|
357978
|
+
ar = [],
|
|
357979
|
+
e;
|
|
357980
|
+
try {
|
|
357981
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
357982
|
+
} catch (error) {
|
|
357983
|
+
e = {
|
|
357984
|
+
error: error
|
|
357985
|
+
};
|
|
357986
|
+
} finally {
|
|
357987
|
+
try {
|
|
357988
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
357989
|
+
} finally {
|
|
357990
|
+
if (e) throw e.error;
|
|
357991
|
+
}
|
|
357992
|
+
}
|
|
357993
|
+
return ar;
|
|
357994
|
+
};
|
|
357995
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
357996
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
357997
|
+
if (ar || !(i in from)) {
|
|
357998
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
357999
|
+
ar[i] = from[i];
|
|
358000
|
+
}
|
|
358001
|
+
}
|
|
358002
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
358003
|
+
};
|
|
357907
358004
|
exports.__esModule = true;
|
|
357908
358005
|
exports.createDockerTagDeployJobs = void 0;
|
|
357909
358006
|
var docker_1 = __nccwpck_require__(33219);
|
|
@@ -357921,7 +358018,7 @@ var createDockerTagDeployJobs = function (context) {
|
|
|
357921
358018
|
var tag = deployConfig.tag;
|
|
357922
358019
|
return (0, base_1.createDeployementJobs)(context, {
|
|
357923
358020
|
deploy: __assign(__assign({}, (0, docker_1.getDockerJobBaseProps)(context)), {
|
|
357924
|
-
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, "\"")]
|
|
358021
|
+
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)
|
|
357925
358022
|
})
|
|
357926
358023
|
});
|
|
357927
358024
|
};
|