tsdocker/ts/npmdocker.snippets.ts

37 lines
1014 B
TypeScript
Raw Normal View History

2016-07-18 22:37:13 +00:00
import * as plugins from "./npmdocker.plugins";
export interface IDockerfileSnippet {
2017-10-13 14:44:25 +00:00
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 yarn global add npmdocker'
} else {
return '# not installing npmdocker since it is included in the base image'
}
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"]
`
)
2016-07-18 22:37:13 +00:00
}