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 {
|
2018-05-18 11:09:14 +00:00
|
|
|
baseImage: string;
|
|
|
|
command: string;
|
2017-10-13 14:44:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let getMountSolutionString = (optionsArg: IDockerfileSnippet) => {
|
|
|
|
if (process.env.CI) {
|
2018-05-18 11:09:14 +00:00
|
|
|
return 'COPY ./ /workspace';
|
2017-10-13 14:44:25 +00:00
|
|
|
} else {
|
2018-05-18 11:09:14 +00:00
|
|
|
return '# not copying workspcae since not in CI';
|
2017-10-13 14:44:25 +00:00
|
|
|
}
|
2018-05-18 11:09:14 +00:00
|
|
|
};
|
2017-10-13 14:44:25 +00:00
|
|
|
|
|
|
|
let getGlobalPreparationString = (optionsArg: IDockerfileSnippet) => {
|
|
|
|
if (optionsArg.baseImage !== 'hosttoday/ht-docker-node:npmdocker') {
|
2018-07-21 11:32:51 +00:00
|
|
|
return 'RUN npm install -g npmdocker';
|
2017-10-13 14:44:25 +00:00
|
|
|
} else {
|
2018-05-18 11:09:14 +00:00
|
|
|
return '# not installing npmdocker since it is included in the base image';
|
2017-10-13 14:44:25 +00:00
|
|
|
}
|
2018-05-18 11:09:14 +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"]
|
|
|
|
`
|
2018-05-18 11:09:14 +00:00
|
|
|
);
|
|
|
|
};
|