tsdocker/ts/tsdocker.snippets.ts
2019-05-10 11:45:20 +02:00

38 lines
1023 B
TypeScript

import * as plugins from './tsdocker.plugins';
export interface IDockerfileSnippet {
baseImage: string;
command: string;
}
let getMountSolutionString = (optionsArg: IDockerfileSnippet) => {
if (process.env.CI) {
return 'COPY ./ /workspace';
} else {
return '# not copying workspcae since not in CI';
}
};
let getGlobalPreparationString = (optionsArg: IDockerfileSnippet) => {
if (optionsArg.baseImage !== 'hosttoday/ht-docker-node:npmdocker') {
return 'RUN npm install -g npmdocker';
} else {
return '# not installing npmdocker since it is included in the base image';
}
};
export let dockerfileSnippet = (optionsArg: IDockerfileSnippet): string => {
return plugins.smartstring.indent.normalize(
`
FROM ${optionsArg.baseImage}
# For info about what npmdocker does read the docs at https://gitzone.github.io/npmdocker
${getGlobalPreparationString(optionsArg)}
${getMountSolutionString(optionsArg)}
WORKDIR /workspace
ENV CI=true
ENTRYPOINT ["npmdocker"]
CMD ["runinside"]
`
);
};