Skip to content

Instantly share code, notes, and snippets.

@ppshein
Last active June 6, 2019 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppshein/9d781d4ffbc0e693cbdd84c1c3ee79f9 to your computer and use it in GitHub Desktop.
Save ppshein/9d781d4ffbc0e693cbdd84c1c3ee79f9 to your computer and use it in GitHub Desktop.
SailsJS Docker Image
# Instructions from the app developer
# - you should use the 'node' official image, with the alpine 6.x branch
FROM node:latest
# - this app listens on port 3000, but the container should launch on port 80
# so it will respond to http://localhost:80 on your computer
EXPOSE 1337
# - then it should use alpine package manager to install tini: 'apk add --update tini'
# RUN apk add --update tini
# - then it should create directory /usr/src/app for app files with 'mkdir -p /usr/src/app'
RUN mkdir -p /usr/src/app
# - Node uses a "package manager", so it needs to copy in package.json file
WORKDIR /usr/src/app
COPY package.json package.json
# - then it needs to run 'npm install' to install dependencies from that file
RUN npm install && npm cache clean --force && npm install sails -g
# - to keep it clean and small, run 'npm cache clean --force' after above
# - then it needs to copy in all files from current directory
COPY . .
# - then it needs to start container with command 'tini -- node ./bin/www'
# CMD ["forever", "start" ,"./app.js","--prod"]
# CMD ["node","./app.js","--prod"]
CMD ["node","./app.js"]
# - in the end you should be using FROM, RUN, WORKDIR, COPY, EXPOSE, and CMD commands
# Base Docker-image on Ubuntu
FROM ubuntu:latest
#install mongodb
#install git, curl, python and mongo
# node-gyp
RUN apt-get install -y build-essential make automake gcc g++ cpp libkrb5-dev libc6-dev man-db autoconf pkg-config
# Create the MongoDB data directory
RUN mkdir -p /data/db
# mongodb setup
# Install NodeJS
RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
RUN apt-get update && apt-get install -y nodejs
RUN npm install -g node-gyp
# Git-clone project
# expose ports
# Install dependencies and start server and database
CMD cd /server && sh start.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment