Skip to content
This repository has been archived by the owner on Aug 18, 2018. It is now read-only.

Automate docker compose environments from JavaScript / Node.js

License

Notifications You must be signed in to change notification settings

ts-archive/docker-compose-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-compose-js - Javascript API for docker-compose

This is a simple API wrapper for the docker-compose command line tool. Its primary purpose is to allow integration tests written in node.js to dynamically manipulate the docker-compose environment.

A larger example of the API used in this way is available in the integration tests for the Teraslice project

Installation

npm install docker-compose-js

Usage

The API largely just mirrors the regular docker-compose commands such as up(), down(), start(), stop() and so on. At the present time all commands except 'logs' and 'events' have been implemented.

The API is Promise based using the Bluebird promises library.

The examples below show the common patterns for calls. Since this is a wrapper around the standard docker-compose command details on each operation can be found in the docker-compose documentation.

Note: Each function takes an object for keyword parameters as the last argument.

var compose = require('docker-compose-js')('docker-compose.yaml');

compose.up()
    .then(function() {
        return compose.stop('test');
    })
    .then(function() {
        return compose.kill('test', { s: 'SIGINT' });
    })
    .then(function() {
        return compose.ps();
    })
    .then(console.log)
    .catch(function(error) {
        console.log(error);
    })
    .finally(function() {
        compose.down();
    })

Example of scaling a particular task

var compose = require('docker-compose-js')('docker-compose.yaml');

compose.up()
    .then(function(result) {
        return compose.scale('test=2');
    })
    .then(function() {
        return compose.ps();
    })
    .then(console.log)
    .catch(function(error) {
        console.log(error);
    })
    .finally(function() {
        return compose.down();
    })

About

Automate docker compose environments from JavaScript / Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published