FROM node:18.12.0-bullseye-slim

RUN apt-get update && \
    apt-get install --no-install-recommends -y \
    libgtk2.0-0 \
    libgtk-3-0 \
    libnotify-dev \
    libgconf-2-4 \
    libgbm-dev \
    libnss3 \
    libxss1 \
    libasound2 \
    libxtst6 \
    procps \
    xauth \
    xvfb \
    # install text editors
    vim-tiny \
    nano \
    # install emoji font
    fonts-noto-color-emoji \
    # install Chinese fonts
    # this list was copied from https://github.com/jim3ma/docker-leanote
    fonts-arphic-bkai00mp \
    fonts-arphic-bsmi00lp \
    fonts-arphic-gbsn00lp \
    fonts-arphic-gkai00mp \
    fonts-arphic-ukai \
    fonts-arphic-uming \
    ttf-wqy-zenhei \
    ttf-wqy-microhei \
    xfonts-wqy \
    expect\
    netcat\
    # clean up
    && rm -rf /var/lib/apt/lists/* \
    && apt-get clean

# a few environment variables to make NPM installs easier
# good colors for most applications
ENV TERM=xterm
# avoid million NPM install messages
ENV npm_config_loglevel=warn
# allow installing when the main user is root
ENV npm_config_unsafe_perm=true

RUN npm --version \
    && npm install -g yarn@latest --force \
    && yarn --version \
    && node -p process.versions \
    && node -p 'module.paths' \
    && echo  " node version:    $(node -v) \n" \
    "npm version:     $(npm -v) \n" \
    "yarn version:    $(yarn -v) \n" \
    "debian version:  $(cat /etc/debian_version) \n" \
    "user:            $(whoami) \n"

WORKDIR /app

COPY . .
# COPY --from=report-builder /app/json-formatter ./formatter/json-formatter

RUN yarn install && yarn cache clean
EXPOSE 5000

# ENV CYPRESS_FULL_SITE_URL=https://full-site-local:3000
# ENV CYPRESS_WIDGET_URL=https://widget-local:3002

CMD ["sh","./entrypoint.sh"]