0.3.1 • Published 7 years ago

stateless-dev v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

Stateless-dev

Develop applications in a totally stateless manner using containers whose lifetime is tied to your application lifetime

npm install stateless-dev

stateless-dev diagram

Running

Environment Variables

STATELESS_RUN : Your container run command. Ex : run -d -p 6379:6379 redis Allows pipe delimited | for multiple containers

STATELESS_MACHINE (optional) : Docker Machine name. Only specify this if using docker-machine. Ex : default

STATELESS_SCRIPT (optional) : the path to a node.js script to run after containers have started up. Ex : ./examples/setup.js

STATELESS_DEBUG (optional) : set to 1 to print informative messages and total runtime cost

API

const stateless = require('stateless-dev');
stateless();

or, if you want to use the version that returns a promise

stateless.async();

:warning: Part of running stateless development containers means all the containers returned by docker ps will be destroyed at the beginning of every run :warning:

Requirements

docker must be on your path

docker-machine must be on your path if using Docker Machine

Convenience

  • stateless-dev will put your docker-machine ip into the environment variable MACHINE_HOST for you (if using docker-machine)

    stateless();
    
    // env.machine_host was set by the program, not by the user
    const client = redis.createClient({ host: process.env.machine_host }); 
  • If process.env.NODE_ENV is set to 'production', then stateless() will be a no-op. You can also disable stateless by setting STATELESS_DISABLE to 1.

  • Environment Variables Support String interpolation

    Ex:

    STATELESS_RUN : run -d -p ${redisPort}:${redisPort} redis

    Where redisPort is another environment variable.