Skip to content

Instantly share code, notes, and snippets.

@mssio
Last active November 28, 2018 19:56
Show Gist options
  • Save mssio/323fff97d172b60e1875 to your computer and use it in GitHub Desktop.
Save mssio/323fff97d172b60e1875 to your computer and use it in GitHub Desktop.
Dockerfile for Node App

#Dockerfile for Node App

Here is sample dockerfile for a basic express app

FROM ubuntu:14.04

RUN apt-get update
RUN apt-get install -qy curl
RUN curl -sL https://deb.nodesource.com/setup | sudo bash -
RUN apt-get install -qy nodejs

RUN npm install -g forever

# ...put your own build instructions here...
RUN mkdir -p /apps/production/node
ADD nodeapp /apps/production/node
ADD start_server.sh /usr/bin/start_server
RUN chmod +x /usr/bin/start_server

# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

EXPOSE 3000
ENTRYPOINT /usr/bin/start_server

And here is what inside the start_server.sh

#!/bin/bash
cd /apps/production/node
forever app.js

Everything inside nodeapp folder is an express app with app.js as it's starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment