Skip to content
Prepares any tarball containing a project so that a docker image can be built from it.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
test
.gitignore
.travis.yml
LICENSE
Readme.md
index.js
package.json

Readme.md

dockerify build status

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)

command line example

# 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

Installation

npm install dockerify

Commandline Usage

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

API

tar(stream, opts) → {ReadableStream}

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

Note

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

opts

  • {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

Parameters:
Name Type Description
stream ReadableStream

the original tar stream

opts Object

@see above

Source:
Returns:

the transformed tar stream

Type
ReadableStream

targz(stream, opts) → {ReadableStream}

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

Parameters:
Name Type Description
stream ReadableStream

.tar.gz stream

opts Object

@see tar

Source:
Returns:

the transformed tar stream

Type
ReadableStream

generated with docme

License

MIT

You can’t perform that action at this time.