FROM    centos:centos7

# Install node
RUN     curl -sL https://rpm.nodesource.com/setup_16.x | bash -

# 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 nodejs-16.16.0-1nodesource
RUN     yum -y install yarn

# Copy app and install packages
WORKDIR /var/app

COPY    .npmrc.shadow package.json scripts/setup.sh yarn.lock tsconfig.json tsconfig.build.json ./
COPY    node-start.sh ./node-start.sh
RUN     chmod +x ./node-start.sh

COPY    scripts ./scripts
COPY    src ./src

RUN     --mount=type=secret,id=tokens,uid=1000 chmod +x ./setup.sh && ./setup.sh && yarn --frozen-lockfile && yarn build


ENV     PORT 8080

EXPOSE  8080

CMD     ["/var/app/node-start.sh"]
