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

cccf

v3.3.0

Published

Common Container Configuration Format

Downloads

15

Readme

Common Container Configuration Format

NPM

The Common Container Configuration Format (cccf) is an attempt at creating a standard container configuration format, in JSON.

It describes containers, their properties and the relationship between them. This repository will include a JSON schema validator for the cccf.

The format is extensible so other modules can expand it's capabilities and semantics.

DISCLAIMER WORK IN PROGRESS

Example

{
    "id"      : "app",                 // Container Id
    "image"   : "megacorp/webapp",     // Image path
    "cmd"     : "python server.py",    // Command to run        (optional)
    "ports"   : ["80:80","53:53/udp"], // List of port mappings (optional)
    "env"     : ["FOO=BAR"],           // Environment variables (optional)
    "volumes" : ["/tmp:/tmp"],         // Container volumes     (optional)
}

Id

The id, app in the example, is the container identifier. It can be any arbitrary string. No spaces.

Image

The image, megacorp/webapp in the example, is URI to the container image. It can be any valid URI, relative or full.

Cmd

The cmd, python server.py in the example, is the command to execute when running the container. It can be an arbitrary string.

Ports

The ports, ["80:80"] in the example, is a list of port mappings. A port mapping is defined using a string with two ports separated by a colon: "host-port:container-port" where host-port references a port on the host running the container, and the container-port references a port inside the running container. Since version 3.2.0 cccf also support specifying the protocol; ["53:53/udp"]. The two supported protocols are tcp and udp.

Env

The env, ["FOO=BAR"] in the example, is a list of environment variables. An evironment variable is defined using a string with a key and a value separated by a equals sign: "key=value".

Volumes

The volumes, ["/tmp:/tmp"] in the example, is a list of volumes to mount inside the container. There are two different ways to specify a volume:

"/host/path:/container/path"  // Mounts a specified path on the host to the specified path in the container
"/host/path"                  // Mounts a specified path on the host to the same path in the container

Install the module

npm install cccf 

API

validate(containers)

The main use-case for this module is to validate container configs.

var cccf       = require('cccf')
var container  = require('./container.json')
var containers = require('./containers.json')

try {
  cccf.validate(container)
  cccf.validate(containers)
} catch(e) {
  console.log(e instanceof cccf.exception, e.trace)
}

random(num, opts)

Generate random container configs. Useful for testing etc.

var cccf = require('cccf')
var containers = cccf.random(5, { host: { hostname: 'yolo' }})

schema

The cccf json schema.

exception

The cccf exception throws if bad config.

Ecosystem

Some modules using cccf

Changelog

3.3.0

  • Added support for generating random containers

3.2.0

  • Support for port protocols tcp and udp
  • Removed docs for expose (planning to remove it in next major)

3.1.0

  • Loosened the regex for env. I'm gonna need some help with the regexes :-P Feel free to HALP!

3.0.0

  • Throwing exceptions instead of returning err. Makes for better composition. If no err, validate returns the passed config (in input format).

2.1.0

  • Added cccf/example.json and cccf/example-multiple.json for easier example require from other modules

2.0.0

  • Removed the validateMultiple API and rather do a quick instanceof Array verification for validate

1.0.1

NB! Moved from common-container-configuration-format to cccf.

  • Updates for package move

1.0.0

  • Initial release