* 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)
| 93 | * @param {String} mode Mode to switch the Dockerfile |
| 94 | */ |
| 95 | function 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) |
no test coverage detected
searching dependent graphs…