Skip to content
/ dockrr Public

An npm package for generating docker file, building, running and stopping running docker image of a Node.js application.

License

Notifications You must be signed in to change notification settings

Kenec/dockrr

Repository files navigation

dockrr

Build Status Coverage Status
dockrr is an an NPM package for auto generating Dockerfile, building docker image, running and stopping the docker container in Node.js.

Installation

npm install dockrr --save-dev

Configuration

  1. Setup the dockrr config file in your application package.json file
...

"dockrr":{
    "cmd": "node index.js",
    "expose": 3000,
    "env": [
        { "name": "name 1" },
        { "metadata": "meta data 1" },
        { "path": "Log Path 1" }
      ],
    "label": [
        { "version": "1.0" }, 
        { "description": "A sample label" },
        { "maintainer": "[email protected]" }
      ],
    "workdir": "/app"
  },
  1. Add script to generate Dockerfile, build docker image, start and stop docker container in your scripts section of package.json file
....

"scripts": {
    "start": "node index.js",
    "dockrr-generate": "node ./node_modules/dockrr generate",
    "dockrr-build": "node ./node_modules/dockrr build",
    "dockrr-run": "node ./node_modules/dockrr run",
    "dockrr-stop": "node ./node_modules/dockrr stop"
  },

Alternatively, we can use dockrr aliases such as

....

"scripts": {
    "start": "node index.js",
    "dockrr-generate": "node ./node_modules/dockrr g",
    "dockrr-build": "node ./node_modules/dockrr b",
    "dockrr-run": "node ./node_modules/dockrr r",
    "dockrr-stop": "node ./node_modules/dockrr s"
  },

Usage

  1. To generate Dockerfile for your application, run
npm run dockrr-generate
  1. To build docker image using the generated Dockerfile, run
npm run dockrr-build
  1. To run the docker container using the built image, run
npm run dockrr-run

Visit the application on your web browser on http://localhost:<port number>/

  1. To stop the docker container, run
npm run dockrr-stop

dockrr config commands

Commands Description Type Required
cmd Command that docker will use to start your application String True
expose The application port which you want the container to run on Integer True
env The environment variables for docker Array of Objects False
label Key value pair of metadata to the image Array of Objects False
workdir The working directory in the Dockerfile String False

ISSUES

To report an issue or give feedback, Click link Issues and Feedback

Contributing

We are more than happy to have you contribute to this project.

License

MIT

About

An npm package for generating docker file, building, running and stopping running docker image of a Node.js application.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published