@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
52 lines • 2.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRailsBuildJobs = void 0;
const __1 = require("../..");
const base_1 = require("../base");
const docker_1 = require("../docker");
const types_1 = require("../types");
const createRailsBuildJobs = (context) => {
var _a, _b, _c;
const buildConfig = context.build.config;
if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
// should not happen
throw new Error("build type is not rails");
}
// if its not a standalone build, we don't need to run tests
if (!(0, __1.componentContextIsStandaloneBuild)(context)) {
throw new Error("workspace builds are not supported for rails apps");
}
if ((0, docker_1.hasDockerfile)(context)) {
return (0, base_1.createComponentBuildJobs)(context, {
appBuild: undefined,
dockerBuild: {
script: (0, docker_1.getDockerBuildDefaultScript)(context),
variables: {},
},
});
}
const cnbConf = buildConfig.cnbBuilder;
const packEnvArgs = Object.entries((_a = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _a !== void 0 ? _a : {})
.map(([k, v]) => `--env '${k}${v ? `=${v}` : ""}'`)
.join(" ");
return (0, base_1.createComponentBuildJobs)(context, {
appBuild: undefined,
dockerBuild: {
variables: {
...context.environment.jobOnlyVars.build.envVars,
},
// custom script
script: [
...(0, docker_1.gitlabDockerLogin)(context),
`cd ${context.build.dir}`,
`wget --output-document=- https://github.com/buildpacks/pack/releases/download/v${cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion}/pack-v${cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion}-linux.tgz | tar -zx --directory /usr/local/bin pack`,
`chmod +x /usr/local/bin/pack`,
// replace private git ssh gem sources with https to make bundler with credentials via env var work
`sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock`,
`pack build "$DOCKER_IMAGE:$DOCKER_IMAGE_TAG" --builder '${cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image}' --publish --cache-image "$DOCKER_CACHE_IMAGE" ${packEnvArgs} ${(_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : ""}`,
],
},
});
};
exports.createRailsBuildJobs = createRailsBuildJobs;
//# sourceMappingURL=build.js.map