spinup-tarstreams
Spins up tar streams each in it's own docker container.
var path = require('path')
, dockerifyRepo = require('dockerify-github-repo')
, spinup = require('spinup-tarstreams')
var group = 'bmarkdown';
// we get a tar stream for each tagged release of thlorenz/browserify-markdown-editor
// and launch a docker container for each to be able to inspect multiple versions of it
dockerifyRepo(
'thlorenz/browserify-markdown-editor'
, { dockerify: { dockerfile: path.join(__dirname, 'Dockerfile') } }
, function (err, streamfns) {
if (err) return console.error(err);
launch(group, streamfns)
}
);
function launch(group, streamfns) {
spinup(streamfns, { group: group, loglevel: 'verbose', container: { exposePort: 3000 } }, function (err, res) {
if (err) return console.error(err);
console.log('Started the following containers: ', res);
});
}
Installation
npm install spinup-tarstreams
API
spinupTarstreams(streamfns, opts, cb)
Creates images for each provided tar stream and then starts a container for each image that matches the given group.
This means that containers for already existing images can be started as well in order to allow reusing existing images instead of having to rebuild them for each run.
Containers are exposing the provided port and bind it to a unique port on the host machine.
This is the only API you will need most likely, all other functions are considered advanced API.
Parameters:
| Name | Type | Argument | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
streamfns |
Array.<function()> | functions that return a tar stream each |
|||||||||||||||||||||||||
opts |
Object |
<optional> |
options that describe how each image and container is created and started Properties
|
||||||||||||||||||||||||
cb |
function | when finished, calls back with all currently running containers for the given group or with an error |
spinupTarstreams::buildImages(images, streamfns, group, useExisting, cb)
Builds an image for each streamfn for the given configuration.
Parameters:
| Name | Type | Description |
|---|---|---|
images |
Object | instance of initialized |
streamfns |
Object | functions returning tar streams hashed by tag name |
group |
string | group for which to build images (i.e. repo name) |
useExisting |
boolean | (default: true) if false existing all images will be built even if one for group and tag exists |
cb |
function | called back with error or an array of images that were built |
spinupTarstreams::runContainers(containers, opts, imageNames, cb)
Creates and starts containers for the given images according to the options.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
containers |
Object | instance of initialized |
||||||||||||||||||||||||
opts |
Object | options that describe how each container is created and started Properties
|
||||||||||||||||||||||||
imageNames |
Array.<string> | names of all images, in form |
||||||||||||||||||||||||
cb |
function | called back when all containers were created or with an error if it failed |
spinupTarstreams::runGroup(images, containers, group, containerOpts, cb)
Starts up a container for each image of the given group that is found.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
images |
Object | instance of initialized |
|
containers |
Object | instance of initialized |
|
group |
string | group of images for which to start containers |
|
containerOpts |
Object |
<optional> |
options that describe how each container is created and started (@see spinupTarstreams::runContainers) |
cb |
function | when finished, calls back with all currently running containers for the group or with an error |
spinupTarstreams::runImages(containers, imagesToRun, containerOpts, cb)
Starts up a container for each given image.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
containers |
Object | instance of initialized |
|
imagesToRun |
Array.<string> | names of images to run of the form |
|
containerOpts |
Object |
<optional> |
options that describe how each container is created and started (@see spinupTarstreams::runContainers) |
cb |
function | called back when all containers for the images were started or with an error |
generated with docme
License
MIT