Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
js-frontend-tutorial js-frontend-tutorial
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ci-general
  • js-frontend-tutorialjs-frontend-tutorial
  • Wiki
  • Build docker image

Build docker image · Changes

Page history
Create docker image authored Jul 11, 2019 by Taras Gaidukov's avatar Taras Gaidukov
Hide whitespace changes
Inline Side-by-side
Showing with 63 additions and 0 deletions
+63 -0
  • Build-docker-image.md Build-docker-image.md +63 -0
  • No files found.
Build-docker-image.md 0 → 100644
View page @ cb60a121
# 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
Clone repository
  • A sample project
  • Build docker image
  • Configure GitLab CI
  • Configure e2e tests for gitlab runner
  • Configure e2e tests on local machine
  • Configure unit tests on local machine
  • Confirure unit tests for gitlab runner
  • Register gitlab runner
  • What is Continuous Integration
  • Home