This repository contains Dockerfile of Node.js w/ Bower & Gulp 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.
-
Install Docker.
-
Download automated build from public Docker Hub Registry:
docker pull dockerfile/xcf(alternatively, you can build an image from Dockerfile:
docker build -t="dockerfile/xcf" github.com/dockerfile/xcf)
This image assumes that your application:
- has a file named package.json listing its dependencies.
- has a file named bower.json listing its dependencies.
- has a file named Gulpfile.js registering
buildtask. - has a file named
server.jsas the entrypoint script or define in package.json the attribute:"scripts": {"start": "node <entrypoint_script_js>"} - listens on port
3000
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.jsapplication directory with the following content:
FROM dockerfile/xcf- 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
3000:
APP=$(docker run -d -p 3000 app)
PORT=$(docker port $APP 3000 | awk -F: '{print $2}')
echo "Open http://localhost:$PORT/"