dockerify

Prepares any tarball containing a project so that a docker image can be built from it.

dockerify

Prepares any tarball containing a project so that a docker image can be built from it

var fs = require('fs')
  , dockerify = require('dockerify')
 
var intar = fs.createReadStream(__dirname + '/in.tar', 'utf8');
dockerify(intar, { strip: 1, dockerfile: __dirname + '/Dockerfile' })
  .on('error', console.error)
  .pipe(process.stdout)
# dockerify local file
cat in.tar | dockerify -l silly -c 'from ubuntu' -s 1 > out.tar
 
# dockerify github tarball
curl -L https://github.com/thlorenz/browserify-markdown-editor/archive/010-finished-dev-version.tar.gz |\
  dockerify -s 1 -c 'from dockerfile/nodejs\nadd . src\n' --gz > out.tar
npm install dockerify
dockerify <options> 
 
   Creates a tarball stream into which a .tar or .tar.gz file can be piped in order to be dockerized 
 
OPTIONS:
 
  -l, --loglevel    level at which to log: silly|verbose|info|warn|error|silent -- default: verbose
  
  -h, --help        Print this help message.
 
  -g, --gz          set this if you are piping a .tar.gz file
 
  -s, --strip       default: 0, sets the number of path segments to strip from each directory  
 
  -c, --content     content of the Dockerfile, defaults to reading --dockerfile or to 'from ubuntu\n'
 
  -d, --dockerfile  file to read Dockerfile content from in case opts.content wasn't provided 
 
  -o, --override    default: false if the project contains a Dockerfile at the root (after directories are stripped), 
                    it will be overwritten with the content/file provided if this option is set
 
 
EXAMPLES:
  
  dockerify a local tarball and strip outer directory, use default Dockerfile
    
    cat in.tar | dockerify -l silly -s 1 > out.tar
 
  dockerify a .tar.gz file release on github, setting dockerfile content - Note --gz option
 
    curl -L https://github.com/thlorenz/browserify-markdown-editor/archive/010-finished-dev-version.tar.gz |\
      dockerify -s 1 -c 'from dockerfile/nodejs\nadd . src\n' --gz > out.tar

Modifies the given tar stream according to given options. The main purpose is adding a Dockerfile so the resulting tar stream can be piped direclty into docker build

The returned tar stream emits the following events on top of the typical ReadableStream events:

  • entry emitted whenever an entry was processed and modified
  • existing-dockerfile emitted whenever an existing Dockerfile was found and used instead of the supplied one
  • overriding-dockerfile emitted whenever an exising Dockerfile was overridden with the supplied one
  • {number=} opts.strip default: 0 sets the number of path segments to strip from each directory
  • {string=} opts.content content of the Dockerfile, defaults to read(opts.dockerfile) or 'from ubuntu\n'
  • {string=} opts.dockerfile file to read Dockerfile content from in case opts.content wasn't provided
  • {boolean=} opts.override default: false if the project contains a Dockerfile at the root (after directories are stripped), it will be overwritten with the content/file provided if this option is set

  • {Object} opts.stats allows setting mtime, mode, uname, gname, uid and gid of the created Dockefile

Name Type Description
stream ReadableStream

the original tar stream

opts Object

@see above

Source:

the transformed tar stream

Type ReadableStream

Gunzips the .tar.gz stream and passes it along to tar.

Name Type Description
stream ReadableStream

.tar.gz stream

opts Object

@see tar

Source:

the transformed tar stream

Type ReadableStream

generated with docme

MIT