MCPcopy Index your code
hub / github.com/Unitech/pm2 / switchDockerFile

Function switchDockerFile

lib/API/Containerizer.js:95–112  ·  view source on GitHub ↗

* Replace ENV, COPY and CMD depending on the mode * @param {String} docker_filepath Dockerfile absolute path * @param {String} main_file Main file to start in container * @param {String} mode Mode to switch the Dockerfile

(docker_filepath, main_file, opts)

Source from the content-addressed store, hash-verified

93 * @param {String} mode Mode to switch the Dockerfile
94 */
95function switchDockerFile(docker_filepath, main_file, opts) {
96 return new Promise(function(resolve, reject) {
97 var data = fs.readFileSync(docker_filepath, 'utf8').toString();
98
99 if (['distribution', 'development'].indexOf(opts.mode) == -1)
100 return reject(new Error('Unknown mode'));
101
102 var lines = parseAndSwitch(data, main_file, opts)
103 fs.writeFile(docker_filepath, lines, function(err) {
104 if (err) return reject(err);
105 resolve({
106 Dockerfile_path : docker_filepath,
107 Dockerfile : lines,
108 CMD : ''
109 });
110 })
111 });
112}
113
114/**
115 * Generate sample Dockerfile (lib/templates/Dockerfiles)

Callers 1

Containerizer.jsFile · 0.85

Calls 3

parseAndSwitchFunction · 0.85
toStringMethod · 0.80
indexOfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…