FROM cypress/base:26.0.0@sha256:446be8fcb63e3cad2f9a4e14720e3d8e35993e12f36da541e09f5740a4c2477c as builder
WORKDIR /build

RUN npm install --global node-gyp && \
    git config --global --add safe.directory /build

COPY ./package.json ./package-lock.json ./
RUN npm ci --no-progress
COPY . /build
RUN npm run postinstall && npm run generate && npm run lint && npm run test:coverage

FROM scratch as export
COPY --from=builder /build/coverage /

FROM amd64/nginx:1.31.0@sha256:fa7c6d43590b7e05153638f1aa2eda009fd444923a524cd2c58d36270c7d48af
MAINTAINER Joakim Olsson <joakim@unbound.se>

COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
COPY ./nginx/security_headers.conf /etc/nginx/security_headers.conf
COPY --from=builder /build/.output/public/ /usr/share/nginx/html/
