#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "./hack/run update"
#
# DO NOT EDIT IT DIRECTLY.
#
FROM node:4-alpine
# <pre>

MAINTAINER AusNimbus <<EMAIL>>

LABEL summary="Platform for running Node.js 4 applications" \
      maintainer="AusNimbus <<EMAIL>>" \
      io.k8s.description="Platform for running Node.js 4 applications" \
      io.k8s.display-name="Node.js 4"

ENV USER=100 \
    HOME=/opt/app-root/src

USER 0

RUN apk --no-cache add bash rsync curl && \
    ln -sf /bin/bash /bin/sh && \
    mkdir -p $HOME && \
    adduser -S -u 1001 -G root -h $HOME -s /sbin/nologin \
      -g "Default Application User" default && \
    chown -R 1001:0 /opt/app-root

# Copy common executable utilities.
COPY ./common/bin/ /usr/bin/

# Each container image can have 'contrib' a directory with extra files needed to
# run and build the application.
COPY ./contrib/ /opt/app-root

# </pre>
# <s2i>

RUN apk --no-cache add git && rm -rf /var/cache/apk/*

ENV STI_SCRIPTS_PATH=/usr/libexec/s2i

LABEL io.openshift.expose-services="8080:http" \
    io.openshift.tags="builder,node" \
    io.openshift.s2i.scripts-url=image:///usr/libexec/s2i

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH

# Directory with the sources is set as the working directory so all S2I scripts
# can execute relative to this path.
WORKDIR ${HOME}

EXPOSE 8080
CMD /usr/bin/base-usage

# </s2i>
# <template>

# Builddeps required by gyp
RUN apk add --no-cache \
        python \
        make \
        g++ \
        jq

# Globally install nodemon before setting NPM_CONFIG_PREFIX
RUN npm install -g nodemon && \
    rm -rf $HOME/.npm/ && \
    rm -rf $HOME/.config/ && \
    chown -R $USER:0 /usr/local/lib/node_modules/ && \
    chmod -R ug+rwx /usr/local/lib/node_modules/

# Add $HOME/node_modules/.bin to the $PATH, allowing user to make npm scripts
# available on the CLI without using npm's --global installation mode
ENV NPM_CONFIG_PREFIX=$HOME/.npm \
    PATH=$HOME/node_modules/.bin/:$HOME/.npm/bin/:$PATH

# </template>
# <post>

# Standardize on UID $USER (alpine:3.4 does not have the shadow package)
RUN apk add shadow --no-cache --repository http://rsync.alpinelinux.org/alpine/latest-stable/community/ && \
    usermod -o -u $USER default && \
    apk del shadow

# Drop the root user and make the content of /opt/app-root owned by user default
RUN chown -R $USER:0 /opt/app-root && chmod -R ug+rwx /opt/app-root
USER $USER

ENTRYPOINT ["container-entrypoint"]

# </post>
