tsdocker/ts/npmdocker.snippets.ts

24 lines
721 B
TypeScript
Raw Permalink Normal View History

2016-07-18 22:37:13 +00:00
import * as plugins from "./npmdocker.plugins";
export interface IDockerfileSnippet {
baseImage:string;
command:string;
}
2016-07-18 22:59:57 +00:00
export let dockerfileSnippet = (optionsArg:IDockerfileSnippet):string => {
2016-07-19 17:21:06 +00:00
let commandArray = optionsArg.command.split(/\s/);
2016-07-18 22:59:57 +00:00
let commandString:string = "";
for(let stringItem of commandArray){
if(!(commandString == "")){
commandString = commandString + ",";
}
commandString = commandString + '"' + stringItem + '"';
2016-07-19 17:21:06 +00:00
};
return plugins.smartstring.indent.normalize(`
2016-07-18 22:37:13 +00:00
FROM ${optionsArg.baseImage}
COPY ./buildContextDir /workspace
2016-07-19 00:03:54 +00:00
WORKDIR /workspace
2016-07-19 17:21:06 +00:00
ENV CI=true
CMD [${commandString}];
`);
2016-07-18 22:37:13 +00:00
}