FROM    centos:centos7

# Install node
RUN     curl -sL https://rpm.nodesource.com/setup_10.x | bash -
RUN     yum install -y nodejs

# Install Yarn
RUN     curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
RUN     rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg
RUN     yum -y install yarn

# Install aws cli
RUN     yum -y install python-setuptools && easy_install pip && pip install awscli

# Copy app and install packages
WORKDIR /var/app
COPY package*.json ./
COPY yarn.lock ./
COPY babel.config.js ./
COPY apollo.config.js ./
COPY src ./src
RUN yarn && yarn build

# Add startup script and datadog init
ADD     nodejs-start.sh /
RUN     chmod +x /nodejs-start.sh

ENV PORT 8080

EXPOSE  8080
CMD     ["/nodejs-start.sh"]
