ARG PARENT_IMAGE=437795906767.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:node12
FROM $PARENT_IMAGE AS parent

WORKDIR /app

RUN git clone https://github.com/sorry-cypress/sorry-cypress.git .

RUN yarn install --frozen-lockfile
RUN yarn workspace @sorry-cypress/common build
RUN yarn workspace @sorry-cypress/dashboard build

FROM nginx:1-alpine
WORKDIR /usr/share/nginx/html
COPY --from=parent /app/packages/dashboard/nginx/default.conf.template /etc/nginx/templates/default.conf.template
COPY --from=parent /app/packages/dashboard/server/static .
COPY --from=parent /app/packages/dashboard/dist .
COPY --from=parent /app/packages/dashboard/dist/views/index.ejs index.html
