From ecc465b49a76229a90c90f79b2b4ccad3e78ee9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20VIGNELLES?= Date: Sat, 23 Jan 2016 18:36:09 +0100 Subject: [PATCH 1/3] fixed a volume mount issue when source/destination path differs --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 53409ea..4cb6a5b 100644 --- a/index.js +++ b/index.js @@ -59,9 +59,9 @@ var run = function(image, opts) { } if (opts.volumes) { - Object.keys(opts.volumes).forEach(function(host) { - var container = opts.volumes[host] - copts.Volumes[host] = {} + Object.keys(opts.volumes).forEach(function(container) { + var host = opts.volumes[container] + copts.Volumes[container] = {} if(!endsWith(container, ':rw') || !endsWith(container, ':ro')) container += ':rw' From 20089a75d1762746307c999911aff0aef68ec23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20VIGNELLES?= Date: Sat, 23 Jan 2016 18:52:02 +0100 Subject: [PATCH 2/3] add tests for volume and env parameters --- test.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/test.js b/test.js index cb80724..fa69794 100644 --- a/test.js +++ b/test.js @@ -2,6 +2,9 @@ var tape = require('tape') var concat = require('concat-stream') var run = require('./') +var fs = require('fs') +var path = require('path') + tape('spawn bash', function(t) { var child = run('mafintosh/dev') @@ -12,6 +15,35 @@ tape('spawn bash', function(t) { })) }) +tape('env', function(t) { + var child = run('mafintosh/dev', { + env:{ + 'ENV_TEST_VAR':'hello world' + } + }) + + child.stdin.end('echo $ENV_TEST_VAR') + child.stdout.pipe(concat(function(data) { + t.same(data.toString(), 'hello world\n', 'echoes $ENV_TEST_VAR') + t.end() + })) +}) + +tape('volume', function(t) { + var child = run('mafintosh/dev', { + volumes:{ + '/test':__dirname + } + }) + + var licenceContent = fs.readFileSync(path.join(__dirname, 'LICENSE'), 'utf8') + child.stdin.end('cat /test/LICENSE') + child.stdout.pipe(concat(function(data) { + t.same(data.toString(), licenceContent, 'echoes license file through volume') + t.end() + })) +}) + tape('destroy', function(t) { var child = run('mafintosh/dev') @@ -20,4 +52,4 @@ tape('destroy', function(t) { t.ok(code !== 0, 'not ok exit') t.end() }) -}) \ No newline at end of file +}) From c37407c5414d039f1cc953253f7a0fb26d95459d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20VIGNELLES?= Date: Sun, 24 Jan 2016 18:49:07 +0100 Subject: [PATCH 3/3] fixed the same issue as #8 for port mappings --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4cb6a5b..711dc29 100644 --- a/index.js +++ b/index.js @@ -44,8 +44,8 @@ var run = function(image, opts) { if (opts.entrypoint) copts.Entrypoint = [].concat(opts.entrypoint) if (opts.ports) { - Object.keys(opts.ports).forEach(function(host) { - var container = opts.ports[host] + Object.keys(opts.ports).forEach(function(container) { + var host = opts.ports[container] if (!/\//.test(container)) container += '/tcp' copts.ExposedPorts[container] = {} sopts.PortBindings[container] = [{HostPort:host+''}]