# Dockerfile
# the FROM directive sets the Base Image for subsequent instructions
FROM galderak/node-base-image

# Set the work directory
WORKDIR /var/www/app/current

# Add our package.json and install *before* adding our application files
ADD package.json ./
ADD .npmrc ./
RUN npm i

# Install pm2 *globally* so we can run our application
RUN npm i -g pm2@2.10.4

# Add application files
ADD . ./

#Build the production bundle
RUN npm run build

# EXPOSE will open up a port on our container, but not necessarily the host system.
# Remember, these instructions are for Docker, not the host environment.
EXPOSE 80

# the --no-daemon is minor workaround to prevent the docker container
# from thinking pm2 has stopped running and ending itself
CMD ["pm2","start","processes.json","--no-daemon"]