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

dkm

v1.0.20

Published

A user-friendly executable to manage docker deployments in NodeJS

Downloads

1

Readme

What is dkm?

A user-friendly executable to manage docker deployments in NodeJS

Prerequites

Install docker for your platform

> docker --version
Docker version X.Y.Z, build ---

Usage

Install dkm as a npm package:

> npm install -g dkm

This docker manager is intended to be used for an application made of several components, each component being a dedicated container. All containers will be interconnected on the same docker network.

Create application directory:

> mkdir app
> cd app

Create component directory:

> mkdir comp
> cd comp

Create Dockerfile:

FROM node:latest

Create file dkm.json with docker configuration:

{
  "dev": {
    "network": "dev",
    "volumes": {
      "disk": "/disk"
    },
    "variables": {
      "var1": "123",
      "var2": "456"
    },
    "ports": {
      "8080": "80",
      "8181": "81"
    }
  }
}  

Create volume

> mkdir disk
> touch disk/hello.txt

Run container:

> dkm start dev

Check that container runs with all expected parameters:

> docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED        STATUS                  PORTS                                        NAMES
cb4c19aeeb24   app_comp_dev   "docker-entrypoint.s…"   1 second ago   Up Less than a second   0.0.0.0:8080->80/tcp, 0.0.0.0:8181->81/tcp   app_comp_dev

> docker exec -it app_comp_dev sh
# echo $var1 
123
# echo $var2
456
# ls /disk
hello.txt
# exit

> docker network inspect
[
  {
    "Name": "dev",
    "Containers": { 
      "...": {
        "Name": "app_comp_dev",
        "..."
      }
    }
    "..."
  }
]

Stop container:

> dkm stop dev

The restart parameter

Set this parameter to "true" to enable docker restart when container stops. This is especially useful for production environment.

The dockerFile parameter

This parameter is used to specify a Dockerfile for a specific configuration

The script parameter

The file dkm.json can contain another argument called "script". This was implemented because some docker images like mongo do not work immediately after contain start. dkm will run a post script that can do any configurable action.

See example/mongo/dkm.json for an illustration.

Start and stop application with multiple components

Multiple components can be started and stopped at once with one single command. The application directory should contain a dkm.json file with the following contents:

{
  "components": {
    "system": [
      "comp1",
      "comp2"
    ]
  }
}

Use environment variables

Sometimes, environment variables need to be used in dkm.json files. In this case, use the following syntax:

"variables": {
  "SECRET": "$ENV"
}

Use build-args for docker build

When Docker containers need to be built with docker environment variables, use the following syntax in dkm.json:

"build-args": {
  "VAR": "value"
}

Use "clean" optional argument to force reload

When needed, docker needs to be rebuilt without using cache. Use this command in this case:

dkm start dev clean

Try the example

The example directory contains example of our this program works, with various technologies. Each container can be started with the command:

> dkm start dev

The application itself can also be run with this command.