Last active
August 30, 2016 13:02
-
-
Save shoemaker/9ce77bef223d85664680 to your computer and use it in GitHub Desktop.
Dockerfile + Node.js Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dockerfile + Node.js Examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DOCKER-VERSION 1.2.0 | |
FROM centos:centos7 | |
MAINTAINER Brian Shoemaker <brianshoemaker@gmail.com> | |
# Update packages | |
RUN yum update -y | |
RUN yum upgrade -y | |
# Install dependencies | |
WORKDIR /packages | |
RUN yum install -y g++; yum install -y make; yum install -y gcc | |
# Enable EPEL for Node.js | |
# This URL will likely change, follow EL7 link here: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F | |
RUN rpm -Uvh http://mirror.pnl.gov/epel/7/x86_64/e/epel-release-7-2.noarch.rpm | |
# Install Node.js and npm | |
RUN yum install -y nodejs npm | |
# Install git | |
RUN yum install -y git | |
# Install Node dependencies | |
RUN rm -rf ~/.npm | |
RUN npm cache clean -f | |
RUN npm install -g npm | |
RUN npm install -g forever | |
RUN npm install -g bower | |
# Copy projects | |
# Edit this section to suit your needs | |
WORKDIR /projects/project-1 | |
ADD . /projects/project-1 | |
# Initialize project dependencies, and more. | |
RUN npm install --loglevel warn --production | |
RUN bower install --allow-root | |
RUN gulp build | |
# Fire up the application. | |
EXPOSE 3000 | |
CMD ["forever", "/projects/project-1/server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DOCKER-VERSION 1.2.0 | |
FROM ubuntu:latest | |
MAINTAINER Brian Shoemaker <brianshoemaker@gmail.com> | |
# Update packages | |
RUN apt-get update -y | |
RUN apt-get upgrade -y | |
# Install curl | |
RUN apt-get install -y curl | |
# Install ssh | |
RUN apt-get install -y openssh-client | |
# Install Node.js (includes npm) | |
WORKDIR /packages | |
RUN curl -sL https://deb.nodesource.com/setup | sudo bash - | |
RUN apt-get install -y nodejs | |
RUN npm cache clean -f | |
# TODO: need npm@1.3 to overcome race condition on npm package installs. | |
# RUN npm install -g npm | |
RUN npm install -g npm@1.3 | |
RUN npm install -g forever | |
RUN npm install -g gulp | |
RUN npm install -g bower | |
# Copy private GitHub keys | |
RUN mkdir /root/.ssh/ | |
ADD id_rsa /root/.ssh/id_rsa | |
RUN chmod 700 /root/.ssh/id_rsa | |
RUN chown -R root:root /root/.ssh | |
# Create known_hosts | |
RUN touch /root/.ssh/known_hosts | |
# Add GitHub key | |
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts | |
# Install git | |
RUN apt-get install -y git | |
# Create place for project(s) | |
RUN mkdir /projects | |
RUN mkdir /projects/.tmp | |
RUN rm -rf ~/.npm | |
RUN npm cache clear | |
# Clone the project(s) | |
WORKDIR /projects/project-1 | |
RUN git clone --progress git@github.com:<username>/<repository>.git | |
# Install project dependencies, build if needed. | |
RUN npm install --loglevel warn --production | |
RUN bower install --allow-root | |
RUN gulp build | |
# Fire up the application. | |
EXPOSE 3000 | |
CMD ["forever", "/projects/project-1/server.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Ubuntu + GitHub example assumes id_rsa file in same location as Dockerfile.