npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ezdocker

v1.0.4

Published

Makes building docker containers in javascript a breeze

Downloads

95

Readme

EZDocker

license:mit Build Status Coverage Status npm npm

EZDocker provides an easy and intuitive way to build docker images in JavaScript. This builds upon Dockerode to provide build patterns and output formatting to improve ease of use.

Although this was built to be used in a Gulp build environment, it can be used in any NodeJS-based build environment or even directly in NodeJS.

This README does not describe what exactly you should put into your Dockerfile or how to setup your project. This simply gives instructions on how to invoke Docker's build process.

Naming Conventions

EZDocker utilizes a standard naming convention for tagging images that follows the RedHat Image-Naming Conventions.
The naming convention is as follows:

REGISTRY[:PORT]/USER/REPO[:TAG]

This allows for convenient, explicit and easy pushing of images to the registry after they have been built.

Gulp Example Usage (ES5)

This example shows using EZDocker to build an image with multiple source folders and pulling the connection configuration from command line arguments:

(function() {

  var gulp = require('gulp'),
      EZDocker = require('ezdocker').default; // Note that in ES5, EZDocker is bound to ".default"

  gulp.task('docker:build-image', function() {
    return EZDocker.createFromArgs()
      .repository('docker.registry.my.company.com:5000/my-team/my-project')
      .buildImage()
      .with.tag('1.0.0')
      .and.path('docker')
      .and.path('dist/production', 'dist')
      .and.path('other/files', '.')
  });

})();

NodeJS Example Usage (ES6)

The example below shows how to use EZDocker to build an image with a single folder.

import EZDocker from 'ezdocker';

return EZDocker.createFromArgs()
  .repository('docker.registry.my.company.com:5000/my-team/my-project')
  .buildImage()
  .with.tag('1.0.0')
  .and.path('docker')
  .and.path('dist/production', 'dist')
  .and.path('other/files', '.')

Configuring Connection to Docker Host

Ultimately under the covers, this is communicating with a Docker host to do the building of the images. By default EZDocker will try to communicate with a host running on the local machine. If the docker host is running remotely, these parameters must be passed in as connection options when constructing an instance of EZDocker.

let ezdocker = new EZDocker({host: 'http://192.168.1.30', port: 3000});

Below are all of the possible configuration parameters you could send. For more details, see Dockerode's Getting Started section.

  • No Parameters -- Defaults to connecting to socket at /var/run/docker.sock
  • socketPath -- local socket to connect to (should be a file path)
  • host -- host domain or IP with optional protocol
  • port -- port
  • protocol -- https or http
  • ca, cert, key -- used to authenticate with host

Connection Configuration from Command Line

Configuration parameters can be obtained from the command line too by calling EZDocker.createFromArgs(). Any command line arguments prefixed with docker. will be used as connection parameters. So to build using the docker host running at https://192.168.1.30:3000 using the Gulp example above, this would be the command:

$ npm docker:build-image --docker.host=192.168.1.30 --docker.port=3000 --docker.protocol=https

Other Docker Tasks

EZDocker also supports pushing and removing images.

import EZDocker from 'ezdocker';

let repository = new EZDocker().repository('docker.registry.my.company.com:5000/my-team/my-project');

repository.pushImages()
  .then(() => {
    console.log('Images pushed, time to clean up the local repository');
    return repository.removeImages();
  })
  .then(() => {
    console.log('Great Success!');
  })
  .catch(() => {
    console.error('Great Failure!');
  ));

Installation

$ npm install --save-dev ezdocker

Submitting Issues

Please file a github issue for any problems or feature requests.

Thank You

Huge thanks to Dockerode on which this is built.

Contributing

See Contributing

License

Licensed under MIT