2015-07-20 00:09:47 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
2015-10-19 11:08:23 -07:00
|
|
|
var Docker = require('dockerode');
|
2015-07-20 00:09:47 -07:00
|
|
|
|
2015-10-19 11:24:21 -07:00
|
|
|
exports = module.exports = {
|
|
|
|
|
connection: connectionInstance()
|
|
|
|
|
};
|
2015-10-19 11:08:23 -07:00
|
|
|
|
|
|
|
|
function connectionInstance() {
|
2015-07-20 00:09:47 -07:00
|
|
|
var docker;
|
|
|
|
|
|
2015-07-24 01:42:28 -07:00
|
|
|
if (process.env.BOX_ENV === 'test') {
|
2015-07-20 00:09:47 -07:00
|
|
|
// test code runs a docker proxy on this port
|
|
|
|
|
docker = new Docker({ host: 'http://localhost', port: 5687 });
|
2015-10-19 11:08:23 -07:00
|
|
|
|
|
|
|
|
// proxy code uses this to route to the real docker
|
|
|
|
|
docker.options = { socketPath: '/var/run/docker.sock' };
|
2015-07-20 00:09:47 -07:00
|
|
|
} else {
|
2015-10-19 11:08:23 -07:00
|
|
|
docker = new Docker({ socketPath: '/var/run/docker.sock' });
|
2015-07-20 00:09:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return docker;
|
|
|
|
|
}
|