Skip to content

Commit

Permalink
Merge pull request #57 from d00rman/docker/hide-ports
Browse files Browse the repository at this point in the history
Docker: do not expose the ports when building the deploy repo
  • Loading branch information
Marko Obrovac committed Oct 11, 2015
2 parents cfd6563 + 644e560 commit 46a47fc
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/docker.js
Expand Up @@ -153,9 +153,10 @@ function buildImg() {
* Starts the container and returns once it has finished executing
*
* @param {Array} args the array of extra parameters to pass, optional
* @param {Boolean} whether to keep the ports hidden inside the container, optional
* @return {Promise} the promise starting the container
*/
function startContainer(args) {
function startContainer(args, hidePorts) {

var cmd = ['docker', 'run', '--name', name, '--rm'];

Expand All @@ -164,12 +165,14 @@ function startContainer(args) {
Array.prototype.push.apply(cmd, args);
}

// list all of the ports defined in the config file
config.services.forEach(function(srv) {
srv.conf = srv.conf || {};
srv.conf.port = srv.conf.port || 8888;
cmd.push('-p', srv.conf.port + ':' + srv.conf.port);
});
if (!hidePorts) {
// list all of the ports defined in the config file
config.services.forEach(function(srv) {
srv.conf = srv.conf || {};
srv.conf.port = srv.conf.port || 8888;
cmd.push('-p', srv.conf.port + ':' + srv.conf.port);
});
}

// append the image name to create a container from
cmd.push(imgName);
Expand Down Expand Up @@ -308,7 +311,7 @@ function updateDeploy() {
return promisedSpawn(['rm', '-rf', 'node_modules'], true);
}).then(function() {
// start the container which builds the modules
return startContainer(['-v', opts.dir + ':/opt/service', '-w', '/opt/service']);
return startContainer(['-v', opts.dir + ':/opt/service', '-w', '/opt/service'], true);
}).then(function() {
// remove unnecessary files
return promisedSpawn([
Expand Down

0 comments on commit 46a47fc

Please sign in to comment.