FROM node:10-alpine AS base

WORKDIR /var/www


RUN apk update && \
    apk add openssh-client git python make g++ && \
    mkdir /root/.ssh

COPY yarn.lock yarn.lock
COPY package.json package.json
COPY ssh_private_key /root/.ssh/id_rsa

RUN chmod 6000 /root/.ssh/id_rsa && \
    touch /root/.ssh/known_hosts && \
    ssh-keyscan github.com >> /root/.ssh/known_hosts && \
    yarn 

RUN shred -u /root/.ssh/id_rsa

FROM node:10-alpine
WORKDIR /var/www

RUN apk update && \
    apk add tini --no-cache

COPY --from=base /var/www/node_modules/ node_modules
COPY . .

RUN shred -u ssh_private_key

#USER pharah

#RUN yarn test-jenkins

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["sh", "entrypoint.sh"]
