Skip to content

Cloudxtreme/nodejs-runtime

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Node.js runtime Dockerfile

This repository contains Dockerfile of Node.js runtime for Docker's automated build published to the public Docker Hub Registry.

This image is a base image for easily running Node.js application.

It can automatically bundle a Node.js application with its dependencies and set the default command with no additional Dockerfile instructions.

This project heavily borrowed code from Google's google/nodejs-runtime Docker image.

Base Docker Image

Installation

  1. Install Docker.

  2. Download automated build from public Docker Hub Registry: docker pull dockerfile/nodejs-runtime

    (alternatively, you can build an image from Dockerfile: docker build -t="dockerfile/nodejs-runtime" github.com/dockerfile/nodejs-runtime)

Usage

This image assumes that your application:

  • has a file named package.json listing its dependencies.
  • has a file named server.js as the entrypoint script or define in package.json the attribute: "scripts": {"start": "node <entrypoint_script_js>"}
  • listens on port 8080

When building your application docker image, ONBUILD triggers install NPM module dependencies of your application using npm install.

  • Step 1: Create a Dockerfile in your Node.js application directory with the following content:
    FROM dockerfile/nodejs-runtime
  • Step 2: Build your container image by running the following command in your application directory:
    docker build -t="app" .
  • Step 3: Run application by mapping port 8080:
    APP=$(docker run -d -p 8080 app)
    PORT=$(docker port $APP 8080 | awk -F: '{print $2}')
    echo "Open http://localhost:$PORT/"

About

Node.js runtime Dockerfile for trusted automated Docker builds.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published