1+ FROM node:14 AS development
2+
3+ ENV USERNAME timetracker
4+ ENV HOME /home/${USERNAME}
5+ ENV CHROME_BIN /opt/google/chrome/google-chrome
6+ # Essential tools and xvfb
7+ RUN apt-get update && apt-get install -y \
8+ software-properties-common \
9+ unzip \
10+ curl \
11+ wget \
12+ xvfb
13+
14+ # Chrome browser to run the tests
15+ ARG CHROME_VERSION=65.0.3325.181
16+ RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add \
17+ && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
18+ && dpkg -i google-chrome-stable_current_amd64.deb || true
19+ RUN apt-get install -y -f \
20+ && rm -rf /var/lib/apt/lists/*
21+
22+ # Disable the SUID sandbox so that chrome can launch without being in a privileged container
23+ RUN dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome \
24+ && echo "#! /bin/bash\n exec /opt/google/chrome/google-chrome.real --no-sandbox --disable-setuid-sandbox \"\$ @\" " > /opt/google/chrome/google-chrome \
25+ && chmod 755 /opt/google/chrome/google-chrome
26+
27+ # Chrome Driver
28+ ARG CHROME_DRIVER_VERSION=2.37
29+ RUN mkdir -p /opt/selenium \
30+ && curl http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -o /opt/selenium/chromedriver_linux64.zip \
31+ && cd /opt/selenium; unzip /opt/selenium/chromedriver_linux64.zip; rm -rf chromedriver_linux64.zip; ln -fs /opt/selenium/chromedriver /usr/local/bin/chromedriver;
32+
33+ RUN useradd -ms /bin/bash ${USERNAME}
34+
35+ WORKDIR ${HOME}/time-tracker-ui
36+ COPY . .
37+ RUN rm -f .env
38+ RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
39+ RUN chmod -R 777 ${HOME}/time-tracker-ui
40+
41+ USER ${USERNAME}
42+ RUN npm cache clean --force && npm install
43+ EXPOSE 4200
44+ EXPOSE 9876
45+ CMD npm run config && npm run test
0 commit comments