# Run tests inside docker without requiring full installation of dependencies on local machine
# Simply run "docker build -f Dockerfile_test ."
# WARNING: sometimes it fails with a core dumped exception

FROM ubuntu:focal

RUN apt-get -qq update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install \
      ca-certificates \	
      wget \
      pkg-config \
      xvfb \
      libglfw3-dev \
      libuv1-dev \
      libjpeg-turbo8 \
      libicu66 \
      unzip \
      libcurl4-openssl-dev \
&& apt-get clean

RUN wget -qO- https://deb.nodesource.com/setup_16.x | bash
RUN apt-get install -y nodejs

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

RUN wget -O test_data.zip https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
RUN unzip -q test_data.zip -d test_data

ENV NODE_ENV="test"

COPY package.json .
RUN npm install
COPY . .
RUN xvfb-run --server-args="-screen 0 1024x768x24" npm test
