@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
63 lines (61 loc) • 3.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createMeteorBuildJobs = void 0;
const BashExpression_1 = require("../../bash/BashExpression");
const runner_1 = require("../../runner");
const base_1 = require("../base");
const docker_1 = require("../docker");
const types_1 = require("../types");
const cache_1 = require("./cache");
const yarn_1 = require("./yarn");
const getMeteorCache = context => [{
key: "meteor-build-cache",
policy: "pull-push",
paths: [".meteor/local/resolver-result-cache.json", ".meteor/local/plugin-cache", ".meteor/local/isopacks", ".meteor/local/bundler-cache/scanner"]
}];
const getMeteorDockerInstallScripts = async context => {
const packageManagerInfo = await context.packageManagerInfo;
if (packageManagerInfo.isClassic) {
return new BashExpression_1.BashExpression(`
COPY $APP_DIR/package.json $APP_DIR/yarn.lock ./
RUN yarn --frozen-lockfile --production=true --ignore-scripts --ignore-engines
COPY $APP_DIR .
RUN yarn --frozen-lockfile --production=true --ignore-engines
`.trim());
}
// yarn >= 4 ships with built-in plugins, see https://github.com/yarnpkg/berry/pull/4253
const doesNotShipWithBuiltInPlugins = ["2", "3"].some(v => packageManagerInfo.version.startsWith(v));
const maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
return new BashExpression_1.BashExpression(`
ENV YARN_ENABLE_INLINE_BUILDS=1
COPY $APP_DIR .
${maybeAddWorkspaceToolsCommand}
RUN yarn workspaces focus --production
`.trim());
};
const createMeteorBuildJobs = async context => {
const buildConfig = context.build.config;
if (!(0, types_1.isOfBuildType)(buildConfig, "meteor")) {
throw new Error("deploy config is not meteor");
}
const [yarnInstall, nodeCache, meteorInstallScripts] = await Promise.all([(0, yarn_1.getYarnInstall)(context), (0, cache_1.getNodeCache)(context), buildConfig.installScripts ? getMeteorDockerInstallScripts(context) : Promise.resolve("")]);
return (0, base_1.createComponentBuildJobs)(context, {
appBuild: buildConfig.buildCommand !== null && buildConfig.buildCommand !== false ? {
cache: [...nodeCache, ...getMeteorCache(context)],
image: (0, runner_1.getRunnerImage)("jobs-meteor"),
variables: {
METEOR_DISABLE_OPTIMISTIC_CACHING: "1" // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
},
script: [...yarnInstall, 'TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory', "cp ./__build_info.json ./dist/bundle/programs/server"]
} : undefined,
dockerBuild: {
script: (0, docker_1.getDockerBuildScriptWithBuiltInDockerFile)(context, "meteor"),
variables: {
METEOR_INSTALL_SCRIPTS: meteorInstallScripts
}
}
});
};
exports.createMeteorBuildJobs = createMeteorBuildJobs;