#
# BEFORE YOU BUILD FROM THIS DOCKERFILE
# Make sure to log-in to AWS ECR via by running the following command:
#
#    $(aws ecr get-login --no-include-email --region ap-southeast-2)
#

# STAGE 1: Build and/or run the tests
FROM node:10 as builder

WORKDIR /usr/src/

# TODO make this more selective and remove the .dockerignore file?
COPY . .

RUN npm install 2>&1

# NOTE: Redirecting STDERR to STDOUT because, for whatever reason, npm test
#       prints the test output to STDERR which `docker build` then takes to
#       mean as error messages, making it add ANSI escape sequences that color
#       it red. AWS CodeBuilder doesn't handle ANSI escape sequences well so
#       we do this to clean up AWS CodeBuild's log.
RUN npm run test -- --no-colors 2>&1

RUN npm run build
