FROM node:12.13-alpine

# Set to a non-root built-in user `node`
USER node

# Create app directory (with user `node`)
RUN mkdir -p /home/node/app

WORKDIR /home/node/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY --chown=node package*.json ./

RUN npm install

# Bundle app source code
COPY --chown=node . .

RUN npm run build

# Bind to all network interfaces so that it can be mapped to the host OS
# Bind to all network interfaces so that it can be mapped to the host OS
ENV HOST=${APP_HOST} PORT=${APP_PORT}

EXPOSE ${PORT}

RUN chmod 755 start.sh

CMD ["sh", "start.sh"]

