From 644e5602038f566d41f7aa99a8c07e1fda26043f Mon Sep 17 00:00:00 2001 From: Marko Obrovac Date: Thu, 8 Oct 2015 19:20:10 +0200 Subject: [PATCH] Docker: do not expose the ports when building the deploy repo --- lib/docker.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/docker.js b/lib/docker.js index e0832a1..dcf8b34 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -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']; @@ -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); @@ -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([