Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dockerode-compose

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dockerode-compose - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

12

lib/services.js

@@ -27,2 +27,3 @@ const tools = require('./tools');

var serviceNames = tools.sortServices(recipe);
const cwdPath = path.dirname(output.file);
for (var serviceName of serviceNames) {

@@ -157,3 +158,8 @@ var pathScope = {};

Image: service.image,
HostConfig: servicesTools.buildHostConfig(projectName, service, recipe),
HostConfig: servicesTools.buildHostConfig(
projectName,
service,
recipe,
cwdPath
),
Env: servicesTools.buildEnvVars(service),

@@ -170,5 +176,5 @@ NetworkingConfig: {

if (service.networks !== undefined) {
servicesTools.buildNetworks(service.networks, networksToAttach);
servicesTools.buildNetworks(projectName, serviceName, service.networks, networksToAttach, opts);
} else {
opts.HostConfig.NetworkMode = projectName + '_default'
opts.HostConfig.NetworkMode = projectName + '_default';
opts.NetworkingConfig.EndpointsConfig[projectName + '_default'] = {

@@ -175,0 +181,0 @@ IPAMConfig: null,

@@ -6,2 +6,35 @@ const fs = require('fs');

/**
* if host path in the volume string (e.g. `./mylocal/file:/container/file`) is not absolute path,
* this function will convert it to an absolute path using `cwd` (current working directory) parameter.
* Otherwise, it will return volume string as it is.
*
* @param {*} volumeStr
* @param {*} cwd
*/
function standardizeVolumeStr(volumeStr, cwd) {
if (typeof volumeStr !== 'string' || volumeStr.length < 1) {
return volumeStr;
}
volumeStr = volumeStr.trim();
if (
volumeStr.substring(0, 2) !== './' &&
volumeStr.substring(0, 3) !== '../'
) {
return volumeStr;
}
const parts = volumeStr.split(':');
if (parts.length !== 2) {
return volumeStr;
}
if (!cwd) {
throw new Error(
'Current working dir path not available when local path is a relative path: ' +
parts[0]
);
}
const localPath = parts[0];
return path.resolve(cwd, localPath) + ':' + parts[1];
}
module.exports = {

@@ -45,3 +78,5 @@ buildPorts: function (servicePorts, output) {

ports[split_port_split1_array[index] + '/tcp'] = [
{ HostPort: split_port_split0_array[index].toString() },
{
HostPort: split_port_split0_array[index].toString(),
},
];

@@ -54,3 +89,5 @@ }

for (let i = split_port_split[0]; i <= split_port_split[1]; i++) {
ports[port_split[1] + '/tcp'].push({ HostPort: i.toString() });
ports[port_split[1] + '/tcp'].push({
HostPort: i.toString(),
});
}

@@ -120,3 +157,3 @@ } else if (port_split[1].includes('/')) {

//ToDo: complete the compose specification
buildHostConfig: function (projectName, service, recipe) {
buildHostConfig: function (projectName, service, recipe, cwd) {
var output = {

@@ -130,3 +167,9 @@ RestartPolicy: { Name: service.restart },

var svf = recipe.services[vf[0]];
this.buildVolumesHostconfig(projectName, svf.volumes, output, vf[1]);
this.buildVolumesHostconfig(
projectName,
svf.volumes,
output,
vf[1],
cwd
);
}

@@ -136,3 +179,9 @@ }

if (service.volumes !== undefined) {
this.buildVolumesHostconfig(projectName, service.volumes, output);
this.buildVolumesHostconfig(
projectName,
service.volumes,
output,
undefined,
cwd
);
}

@@ -343,3 +392,3 @@

buildVolumesHostconfig: function (projectName, volumes, output, type) {
buildVolumesHostconfig: function (projectName, volumes, output, type, cwd) {
if (output['Binds'] === undefined) {

@@ -350,12 +399,36 @@ output['Binds'] = [];

if (typeof volume === 'string' || volume instanceof String) {
var aux = projectName + '_' + volume;
if (type == 'ro') {
aux += ':ro';
if (
volume.substring(0, 2) === './' ||
volume.substring(0, 3) === '../' ||
volume[0] === '/'
) {
const stdVolume = standardizeVolumeStr(volume, cwd);
const aux = stdVolume;
if (type == 'ro') {
aux += ':ro';
}
output['Binds'].push(aux);
} else {
var aux = projectName + '_' + volume;
if (type == 'ro') {
aux += ':ro';
}
output['Binds'].push(aux);
}
output['Binds'].push(aux);
} else {
var volumestr = '';
if (volume.source && volume.target) {
volumestr +=
projectName + '_' + volume.source + ':' + volume.target + ':';
if (
volume.source.substring(0, 2) === './' ||
volume.source.substring(0, 3) === '../' ||
volume.source[0] === '/'
) {
volumestr += standardizeVolumeStr(
volume.source + ':' + volume.target,
cwd
);
} else {
volumestr +=
projectName + '_' + volume.source + ':' + volume.target + ':';
}
}

@@ -382,2 +455,5 @@ if (volume.read_only || type == 'ro') {

for (var volume of volumes) {
if (volume.substring(0, 2) === './' || volume[0] === '/') {
continue;
}
if (typeof volume === 'string' || volume instanceof String) {

@@ -422,3 +498,3 @@ var v = volume.split(':');

buildNetworks: function (serviceNetworks, networksToAttach) {
buildNetworks: function (projectName, serviceName, serviceNetworks, networksToAttach, opts) {
if (Array.isArray(serviceNetworks)) {

@@ -425,0 +501,0 @@ for (let index = 0; index < serviceNetworks.length; index++) {

{
"name": "dockerode-compose",
"version": "1.3.1",
"version": "1.3.2",
"description": "docker-compose in nodejs using dockerode",

@@ -24,3 +24,3 @@ "main": "./compose.js",

"dependencies": {
"dockerode": "^3.3.1",
"dockerode": "^3.3.0",
"js-yaml": "^4.0.0",

@@ -27,0 +27,0 @@ "tar-fs": "^2.1.1"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc