|
|
# Build docker image
|
|
|
|
|
|
https://github.com/GoogleChrome/puppeteer \
|
|
|
https://www.docker.com \
|
|
|
https://hub.docker.com/r/alekzonder/puppeteer/dockerfile
|
|
|
|
|
|
## Running tests on the server
|
|
|
|
|
|
Since front end tests require a web browser, it's difficult to run tests within usual browser on servers that usually have not graphics installed. Fortunately there is a headless (without user interface) Google Chrome named `puppeteer` that could be used for running in-browser tests on the server side.
|
|
|
|
|
|
There is a pre-built docker image `alekzonder/puppeteer` and it could be easily used for unit tests, but it does not contain `java` so it cannot run e2e tests. We need to build custom docker image based on `alekzonder/puppeteer` with java support. Also we will upgrade `puppeteer` version to Chrome 75, install some dependencies globally to avoid installation each time test running. Note that we are using `node:8` base image instead of `node:8-slim` as it's used in `alekzonder/puppeteer`. It's because java installation fails with `node:8-slim`. Additionally we will remove unnecessary tools.
|
|
|
|
|
|
1. Create a folder with file named `Dockerfile`:
|
|
|
|
|
|
Dockerfile
|
|
|
```
|
|
|
FROM node:8
|
|
|
|
|
|
MAINTAINER Taras Gaidukov <taras@faifly.com>
|
|
|
|
|
|
RUN apt-get update && \
|
|
|
apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
|
|
|
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
|
|
|
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
|
|
|
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
|
|
|
fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \
|
|
|
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget default-jre && \
|
|
|
wget https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64.deb && \
|
|
|
dpkg -i dumb-init_*.deb && rm -f dumb-init_*.deb && \
|
|
|
apt-get clean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
RUN yarn global add puppeteer@1.15.0 http-server protractor && yarn cache clean
|
|
|
|
|
|
ENV NODE_PATH="/usr/local/share/.config/yarn/global/node_modules:${NODE_PATH}"
|
|
|
|
|
|
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser
|
|
|
|
|
|
RUN mkdir /home/pptruser && chown -R pptruser:pptruser /home/pptruser \
|
|
|
&& chown -R pptruser:pptruser /usr/local/share/.config/yarn/global/node_modules
|
|
|
|
|
|
# Set language to UTF8
|
|
|
ENV LANG="C.UTF-8"
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
RUN webdriver-manager update
|
|
|
|
|
|
# Run everything after as non-privileged user.
|
|
|
USER pptruser
|
|
|
|
|
|
# --cap-add=SYS_ADMIN
|
|
|
# https://docs.docker.com/engine/reference/run/#additional-groups
|
|
|
|
|
|
ENTRYPOINT ["dumb-init", "--"]
|
|
|
|
|
|
CMD ["node", "index.js"]
|
|
|
```
|
|
|
|
|
|
2. Build the docker image (it could take several minutes):
|
|
|
|
|
|
```
|
|
|
docker build -t node-protractor .
|
|
|
``` |
|
|
\ No newline at end of file |