# Check out https://hub.docker.com/_/node to select a new base image
FROM 256144430281.dkr.ecr.us-east-1.amazonaws.com/payments-merchant-portal-api-shared:base

# 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}
CMD ["./start.sh"]
