{{if eq .Framework "meteor"}}
FROM node:{{.Version}}

# setup user home dir
ENV USER node
ENV HOME_DIR /home/$USER
RUN mkdir -pv /home/$USER 
RUN chown $USER:$USER /home/$USER

# setup application dir
ENV APP_HOME /app
RUN mkdir -pv $APP_HOME
RUN chown $USER:$USER $APP_HOME

# run next commands as user deamon
USER $USER
ENV HOME /home/$USER
ENV PATH $PATH:$HOME/.meteor

# install meteor (for building distribution)
RUN curl -sL https://install.meteor.com/?release={{.FrameworkVersion}} | /bin/sh

# setup temp dir for building meteor distribution
USER root

#install required packages (magick)
RUN apt-get update
RUN apt-get install apt-utils -y
RUN apt-get install imagemagick libmagick++-dev  libmagick++-6.q16-dev -y
ENV PATH /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:$PATH

ENV APP_TMP /tmp
WORKDIR $APP_TMP
COPY . $APP_TMP
RUN chown -R $USER:$USER $APP_TMP
USER $USER

# set NPM stuff
ENV NODE_ENV production
ENV NPM_CONFIG_LOGLEVEL warn
ENV ROOT_URL http://www.example.com

# ADD CUSTOM REGISTRY HERE IF REQUIRED
# ENV CUSTOM_REGISTRY https://registry.npmjs.org/
# RUN npm config set strict-ssl false
# RUN npm config set registry $CUSTOM_REGISTRY

#install npm packages first
RUN meteor npm install

# build the distribution and deploy in app dir
RUN meteor build --server-only --architecture=os.linux.x86_64 build
RUN tar -xf build/tmp.tar.gz --strip-components=1 -C $APP_HOME

# install NPM packages
WORKDIR $APP_HOME
RUN cd programs/server && npm install
{{else}}
FROM node:{{.Version}}

ENV APP_HOME /app
RUN mkdir -pv $APP_HOME
WORKDIR $APP_HOME

ADD . $APP_HOME

ENV NODE_ENV production
ENV NPM_CONFIG_LOGLEVEL warn

# ADD CUSTOM REGISTRY HERE IF REQUIRED
# ENV CUSTOM_REGISTRY https://registry.npmjs.org/ 
# RUN npm config set strict-ssl false
# RUN npm config set registry $CUSTOM_REGISTRY

RUN npm install
{{end}}