3import * as _ from 'lodash-es' 20export const getDockerBaseStr = async ({ 21 afterYarnInstallDockPathsA, aptPkgNames = [], fromImgName, 22 extraDockerSetupLine, appPath, includeShaInTag, 23 bundle, entrypointAbsPath, bundleName, nativeInstallPackages = [], 25 afterYarnInstallDockPathsA: string[], aptPkgNames?: string[], fromImgName?: string, 26 extraDockerSetupLine?: string, appPath: string, includeShaInTag?: boolean, 27 bundle?: boolean, entrypointAbsPath?: string, bundleName?: string, nativeInstallPackages?: string[], 31 const dockFile = initDockFile(`FROM ${fromImgName} AS yarninstallstage`, {includeShaInTag}) 32 const {pushLine, pushCpTar} = dockFile 36 let aptInstallStr = `RUN echo ${dockBumpNo} && apt-get update && apt-get install -y apt-transport-https` 38 aptInstallStr += ` && echo omg` 39 pushLine(aptInstallStr) 41 if (aptPkgNames.length > 0) { 42 pushLine(`RUN apt-get update && apt-get install -y ${[...aptPkgNames].sort().join(' ')}`) 45 if (extraDockerSetupLine) pushLine(extraDockerSetupLine) 46 if ((getAppCfg() as Record<string, unknown>)?.forceIpv4Dns) dockFile.pushEnv('NODE_OPTIONS', '--dns-result-order=ipv4first', {append: true}) 49 pushCpTar(await genBundleTar({entrypointAbsPath: entrypointAbsPath!, bundleName: bundleName!, externalA: nativeInstallPackages})) 52 if (nativeInstallPackages.length) pushLine(`RUN npm install ${nativeInstallPackages.join(' ')}`) 56 const packageJsonPath = `${ptDir}/${appPath}/package.json` 57 const pkgJsonA = await recPkgJsonsPathA({packageJsonPath}) as {packageJsonPath: string, pkgJson: {name: string}}[] 65 pushLine(`ENV CXXFLAGS="--std=c++14"`) 66 pushLine(`#^ https://github.com/nodejs/node/issues/38367`) 68 if ((npmName as string) == 'yarn') { 70 pushLine(`# workaround for openid-client@5.1.8: The engine "node" is incompatible with this module 71RUN yarn install --ignore-engines --production`) 72 } else if (npmName == 'pnpm') { 74 const appPkgName = pkgJsonA[0].pkgJson.name 76 pushLine(`ENV PNPM_HOME="/pnpm"`) 77 pushLine(`ENV PATH="$PNPM_HOME:$PATH"`) 78 pushLine(corepackInstallLine) 79 const pnpmInstallCmd = `pnpm install --frozen-lockfile --filter ${appPkgName}...` 81 ? `RUN ${pnpmInstallCmd}` 82 : `RUN --mount=type=cache,id=pnpm,target=/pnpm/store ${pnpmInstallCmd}`)