tsdocker/ts/tsdocker.snippets.ts

38 lines
1023 B
TypeScript
Raw Normal View History

2019-05-10 09:45:20 +00:00
import * as plugins from './tsdocker.plugins';
2016-07-18 22:37:13 +00:00
export interface IDockerfileSnippet {
baseImage: string;
command: string;
2017-10-13 14:44:25 +00:00
}
let getMountSolutionString = (optionsArg: IDockerfileSnippet) => {
if (process.env.CI) {
return 'COPY ./ /workspace';
2017-10-13 14:44:25 +00:00
} else {
return '# not copying workspcae since not in CI';
2017-10-13 14:44:25 +00:00
}
};
2017-10-13 14:44:25 +00:00
let getGlobalPreparationString = (optionsArg: IDockerfileSnippet) => {
if (optionsArg.baseImage !== 'hosttoday/ht-docker-node:npmdocker') {
return 'RUN npm install -g npmdocker';
2017-10-13 14:44:25 +00:00
} else {
return '# not installing npmdocker since it is included in the base image';
2017-10-13 14:44:25 +00:00
}
};
2016-07-18 22:37:13 +00:00
2017-04-02 12:48:23 +00:00
export let dockerfileSnippet = (optionsArg: IDockerfileSnippet): string => {
2017-10-13 14:44:25 +00:00
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"]
`
);
};