开发者社区> 镜像站> NPM> spinup-tarstreams
spinup-tarstreams
Spins up tar streams each in it's own docker container.
Last updated 7 years ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install spinup-tarstreams 
SYNC missed versions from official npm registry.

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);
  });
}

full exampe

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
Name Type Argument Description
loglevel string <optional>

(default: 'info') if set logs will be written to stderr (@see dockops:logEvents)

container Object <optional>

options that describe how each container is created and started (@see spinupTarstreams::runContainers)

dockerhost string <optional>

(default: $DOCKER_HOST or 'tcp://127.0.0.1:4243') the host that docker is running on

group string <optional>

(default: 'ungrouped') the group aka REPOSITORY to which the add the created images and whose containers to start

useExistingImages boolean <optional>

(default: true) if false all images are created, even if one for the group and tag exists

cb function

when finished, calls back with all currently running containers for the given group or with an error

Source:

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 {Images}, it is also used to emit progress events over

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

Source:

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 {Containers}

opts Object

options that describe how each container is created and started

Properties
Name Type Argument Description
exposePort Object

port to expose from the running docker process, the needed port bindings are set up as well

hostPortStart Object <optional>

each docker container binds the exposed port to a host port starting at this port

removeExisting Object <optional>

(default: true) if true all existing containers for the groups the images belong to are stopped and removed before new ones are created

create Object

container creation options passed to dockerode

start Object

container start options passed to dockerode's container.start

imageNames Array.<string>

names of all images, in form 'group:tag' that were added to docker before for which to run a container

cb function

called back when all containers were created or with an error if it failed

Source:

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 {Images}

containers Object

instance of initialized {Containers}

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

Source:

spinupTarstreams::runImages(containers, imagesToRun, containerOpts, cb)

Starts up a container for each given image.

Parameters:
Name Type Argument Description
containers Object

instance of initialized {dockops.Containers}

imagesToRun Array.<string>

names of images to run of the form 'group:tag'

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

Source:

generated with docme

License

MIT

Current Tags

  • 0.1.0                                ...           latest (7 years ago)

2 Versions

  • 0.1.0                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (4)
Dependents (0)
None