Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thlorenz/spinup-tarstreams

Spins up tar streams each in it's own docker container.
https://github.com/thlorenz/spinup-tarstreams

Last synced: 26 days ago
JSON representation

Spins up tar streams each in it's own docker container.

Awesome Lists containing this project

README

        

# spinup-tarstreams

Spins up tar streams each in it's own docker container.

```js
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](https://github.com/thlorenz/spinup-tarstreams/blob/master/examples/github-repo-all-editors.js)

## 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](https://github.com/thlorenz/docme)*

## License

MIT