UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

35 lines 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.writeStandaloneDockerfile = void 0; const rimraf_1 = require("rimraf"); const paths_1 = require("../../paths"); const util_1 = require("../../util"); const app_json_file_1 = require("./app-json-file"); async function writeStandaloneDockerfile() { const spawner = (0, util_1.JsSpawner)(); if (!(await spawner.exists(paths_1.DOCKERFILE))) { throw new Error(`${paths_1.DOCKERFILE} does not exist!`); } if (await spawner.exists(paths_1.DOCKERFILE_STANDALONE)) { await (0, rimraf_1.default)(paths_1.DOCKERFILE_STANDALONE); } const dockerfileContents = []; dockerfileContents.push('# Do not edit this file; auto-generated by alwaysAI'); const origContents = await spawner.readFile(paths_1.DOCKERFILE); origContents.split(/\r?\n/).forEach((line) => { dockerfileContents.push(line); }); dockerfileContents.push('ENV PATH="/app/venv/bin:$PATH"'); dockerfileContents.push('ENV PYTHONUNBUFFERED=1'); dockerfileContents.push('WORKDIR /app'); dockerfileContents.push('COPY . ./'); const appJsonFile = (0, app_json_file_1.AppJsonFile)(); const appJson = appJsonFile.read(); const startScript = `CMD ["${appJson.scripts.start .split(' ') .join('", "')}"]`; dockerfileContents.push(startScript); await spawner.writeFile(paths_1.DOCKERFILE_STANDALONE, dockerfileContents.join('\n')); } exports.writeStandaloneDockerfile = writeStandaloneDockerfile; //# sourceMappingURL=write-standalone-dockerfile.js.map