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

docker-command-builder

v0.0.5

Published

Docker command generator that take cares of container dependencies

Downloads

4

Readme

Docker Command Builder

Docker command generator that take cares of container dependencies

Build status

Build Status

Installation

Use NPM to install the library:

npm install docker-command-builder

Usage

You can use the runner component to create dependant containers:

dockerComm = require("docker-command-builder");

var runnerBuilderChild = dockerComm("runner");
runnerBuilderChild
    .setName("selenium-named-chrome")
    .setImage("selenium-node-chrome:2.45.0")
    .setAlias("chrome")
    .setDaemon(true);
    
var runnerBuilder = dockerComm("runner");
    
runnerBuilder
    .setName("hub")
    .setImage("selenium-hub:2.45.0")
    .setDaemon(true)
    .addChild(runnerBuilderChild);
        
var runnerBuilderApp = dockerComm("runner");
    
runnerBuilderApp
    .setName("hub")
    .setImage("custom-application:1.0.0")
    .setDaemon(true)
    .addChild(runnerBuilder);
    
var command = runnerBuilderApp.make();
console.log(command)

Will output te next array :

[
    'docker pull selenium-node-chrome:2.45.0',
    'docker pull selenium-hub:2.45.0',
    'docker pull custom-application:1.0.0',
    'docker run -d --name=selenium-named-chrome selenium-node-chrome:2.45.0',
    'docker run -d --name=hub --link selenium-named-chrome:chrome selenium-hub:2.45.0',
    'docker run -d --name=hub --link hub:selenium-hub custom-application:1.0.0'
]

You can set build folder and tag, environment variables, volumes, etc...

Docker Version

You can initiate the any docker-commander object with different version, by default is the latest version.

dockerComm = require("docker-command-builder");

var runnerBuilderChild_13 = dockerComm("runner", 1.3); //<-- set the version on creation

API

puller

Exposed by:

require("docker-command-builder")("puller")

puller#setImage(image)

Sets the name of the image for the pull command

puller#setRegistry(registry)

By default is setted to null (the official docker registry), you can change it on this variable

var pullerBuilder = dockerComm("puller");
pullerBuilder.setImage("image1");
pullerBuilder.setRegistry("registry.custom.server.com");
pullerBuilder.setVersion("1.1.1");
var command = pullerBuilder.make();

console.log(command);
//--> docker pull registry.custom.server.com/image1:1.1.1

puller#make

Generates the command array

builder

Exposed by require("docker-command-builder")("builder")

builder#setTag(tag)

Sets the tag of the build

builder#setDir(dir)

Sets the dir of the build. Must be absolute path

builder#make

Generates the command array

runner

Exposed by require("docker-command-builder")("runner")

runner#setBuild(tag,dir)

Disables the image option, and sets the build tag as image of the run

runner#setAlias(alias)

If setted, instead the name of the image to generate the link on parent containers, will use the alias

runner#getAlias

Returns the alias

runner#addPort

Add a port definition as 127.0.0.1:8000:80

runner#addChild(runner instance)

Add a runner instance as child container

runner#setDaemon(boolean flag)

Sets the run command as daemon or not (by default is true). If enabled, disables the cleanUp flag.

runner#setCleanUp(boolean flag)

Sets the container flag for clean up (--rm). If enabled, disables the daemon flag.

runner#setPrivileged(boolean flag)

Sets the container flag for privileged container (--privileged).

runner#setImage(image)

Sets the image of the command. Disabled the build information.

runner#getImage

Returns the image setted.

runner#addEnvironmentVariable(key,value)

Adds a new environment variable to the container

runner#addVolume(hostDir,containerDir,mode=rw|ro[optional])

Adds a new volume to the container. Mode by default is empty

runner#make

Generates the command array

TODO

  • Add runtime constraints to runner (memory and cpu)
  • Add user option to runner
  • Add workdir option to runner
  • Add command option to runner

LICENSE

MIT