FROM node:lts-bookworm
ENV SHELL bash
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

RUN npm install -g pnpm@8.15.1 && \
    pnpm setup

RUN apt-get -y --fix-missing update && \
    apt-get -y --fix-missing upgrade && \
    apt-get -y --no-install-recommends install \
    apt-utils \
    libgtk2.0-0 \
    libgtk-3-0 \
    libgbm-dev \
    libnotify-dev \
    libnss3 \
    libxss1 \
    libasound2 \
    libxtst6 \
    xauth \
    xvfb \
    chromium \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY \
    package.json \
    .npmrc \
    pnpm-lock.yaml \
    ./

RUN pnpm install && \
    pnpm install -g @quasar/cli@2.2.1 && \
    pnpm install cypress && \
    npx cypress install

COPY \
    quasar.config.js \
    index.html \
    jsconfig.json \
    quasar.extensions.json \
    postcss.config.js \
    cypress.config.js \
    ./

COPY test/cypress test/cypress

ENV CYPRESS_BROWSER=chrome
ENV CHROME_BIN=/usr/bin/chromium

CMD ["npx", "cypress", "run"]