Public Repository

Last pushed: 2 months ago
Short Description
A configurable Docker container for running Node; designed for use with AWS ElasticBeanstalk! :P
Full Description

Node Docker Image

A configurable Docker container for running Node; designed for use with AWS ElasticBeanstalk! :P

Overview

This is a minimal Docker image for running Node in a customizable manner, by making use of a bash script with hooks as the container's entrypoint. This container supports arbitrary methods of starting your node process, as well as auto-pre-installation of npm dependencies prior to startup. It's meant primarily as a workaround for AWS ElasticBeanstalk's lack of a way to specify a run command for a Docker container, and is intended for the nodejs app to be included via a docker-mounted directory to /var/app.

Base Docker Image

Usage

  1. If you haven't already, install Docker
  2. Pull the latest automated build from DockerHub: docker pull vixlet/node:latest
  3. Run!

Run in background

docker run -d \
    -p 8080:8080 \
    -v $( pwd ):/var/app \
    --name "vixlet-node-example" \
    vixlet/node:latest

Run interactively

docker run -it --rm \
    -p 8080:8080 \
    -v $( pwd ):/var/app \
    --name "vixlet-node-example" \
    vixlet/node:latest

Run with custom container commands

#### START WITH A CUSTOM NPM SCRIPT
docker run -it --rm \
    -p 8080:8080 \
    -v $( pwd ):/var/app \
    --name "vixlet-node-example" \
    vixlet/node:latest \
    npm run my-custom-start-script

#### START WITH INCLUDED FOREVER.JS
docker run -it --rm \
    -p 8080:8080 \
    -v $( pwd ):/var/app \
    --name "vixlet-node-example" \
    vixlet/node:latest \
    forever start -c "npm start"

#### START WITH INCLUDED NODEMON.JS
docker run -it --rm \
    -p 8080:8080 \
    -v $( pwd ):/var/app \
    --name "vixlet-node-example" \
    vixlet/node:latest \
    nodemon

Hooking into container pre-start

A custom pre-start script can be provided to handle any tasks prior to the container starting. To use a pre-start script, include an executable file in your application named docker-prestart.sh.

Alternatively, you can use an arbitrarily-named pre-start script by defining the environment variable CONTAINER_PRESTART.

Bypassing auto-pre-installation

Setting the environment variable CONTAINER_PREINSTALL to "skip" will bypass the npm installation step of the container entrypoint script.

Environment variables

  • CONTAINER_PREINSTALL
    • Command used to install npm dependencies
    • default: "npm install --production --no-bin-links"
  • CONTAINER_PRESTART
    • Command to run prior to starting container
    • default: "/var/app/docker-prestart.sh"
    • skip: "skip"

License

© 2014, 2015, 2016 VIXLET CA LLC <admin@vixlet.com>

The "ISC" license:

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Docker Pull Command
Owner
vixlet