Skip to content

Commit 32f7aa4

Browse files
committed
chore(e2e): add Dockerfile for e2e test runner
1 parent 6de797e commit 32f7aa4

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# This Dockerfile builds and image that allows you to run compass e2e tests
2+
# in a docker container without the need to do all the extra setup
3+
#
4+
# Usage:
5+
#
6+
# # build the image first, by default compass repo will by pulled from remote
7+
# docker build \
8+
# --platform=linux/amd64 \
9+
# -f ./packages/compass-e2e-tests/Dockerfile .
10+
#
11+
# # you can build from a specific compass repo revision
12+
# docker build \
13+
# --platform=linux/amd64 \
14+
# --build-arg="COMPASS_VERSION=#v1.45.0" \
15+
# -f ./packages/compass-e2e-tests/Dockerfile .
16+
#
17+
# # you can also build from local
18+
# docker build \
19+
# --platform=linux/amd64 \
20+
# --build-arg="COMPASS_REPO=./" \
21+
# -f ./packages/compass-e2e-tests/Dockerfile .
22+
#
23+
# # run all web tests (default command)
24+
# docker run --rm -it <image id>
25+
#
26+
# # run with a custom command (this runs filtered tests for desktop)
27+
# docker run --rm -it <image id> desktop --test-filter=time-to-first-query
28+
#
29+
# # e2e env configuration is also supported (this runs filtered web tests)
30+
# docker run -e COMPASS_E2E_TEST_FILTER="time-to-first-query" --rm -it <image id>
31+
32+
FROM ubuntu:20.04
33+
USER root
34+
35+
ARG NVM_VERSION="0.40.1"
36+
ARG NODE_VERSION="20.16.0"
37+
ENV NODE_VERSION=${NODE_VERSION}
38+
ARG NPM_VERSION="10.2.4"
39+
ENV NPM_VERSION=${NPM_VERSION}
40+
# By default will pull compass from git, can be overriden with a local path
41+
ARG COMPASS_REPO="https://github.com/mongodb-js/compass.git"
42+
# When COMPASS_REPO points to the git repository, can be used to fetch repo with
43+
# a certain tag / branch. Should start with #: `#v1.42.0`
44+
ARG COMPASS_VERSION=""
45+
46+
WORKDIR /tmp/compass
47+
48+
ADD ${COMPASS_REPO}${COMPASS_VERSION} .
49+
ADD https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh install_nvm.sh
50+
51+
ENV DEBIAN_FRONTEND=noninteractive
52+
# Default address, this will become available before we start running tests
53+
ENV DBUS_SESSION_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket
54+
# Required by some compass deps
55+
ENV CXX=gcc-11
56+
57+
RUN <<EOF
58+
# Add toolchain repo
59+
apt-get update
60+
apt-get install -y software-properties-common
61+
add-apt-repository -y ppa:ubuntu-toolchain-r/test
62+
# Update again so we can install build deps
63+
apt-get update
64+
apt-get upgrade -y
65+
# Now finally install the deps (build and electron / chromium runtime)
66+
bash .evergreen/retry-with-backoff.sh apt-get install -y \
67+
xvfb curl python3 build-essential libkrb5-dev libsecret-1-dev gcc-11 g++-11 \
68+
xorg dbus-x11 libgtk-3-0 libnss3-dev libxss-dev libgbm-dev libasound2
69+
EOF
70+
71+
ENV NVM_DIR=/root/.nvm
72+
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
73+
ENV NODE_OPTIONS="--max-old-space-size=4096"
74+
75+
RUN <<EOF
76+
# Install node, npm
77+
bash install_nvm.sh
78+
. "${NVM_DIR}/nvm.sh"
79+
nvm install ${NODE_VERSION}
80+
npm i -g npm@${NPM_VERSION}
81+
node --version
82+
npm --version
83+
# Install monorepo deps and bootstrap compass-e2e-tests package
84+
bash .evergreen/retry-with-backoff.sh .evergreen/npm_ci.sh
85+
npx lerna run bootstrap --scope compass-e2e-tests --include-dependencies
86+
# Prepare entrypoint file
87+
echo "#! /usr/bin/env bash\n" \
88+
"set -e\n" \
89+
"service dbus start\n" \
90+
"npm run -w compass-e2e-tests test -- \$@" >./entrypoint.sh
91+
chmod +x ./entrypoint.sh
92+
EOF
93+
94+
ENV DEBUG="compass-e2e-tests*,electron*,hadron*,mongo*"
95+
ENV MONGODB_VERSION="8.0.x-enterprise"
96+
ENV MONGODB_RUNNER_VERSION="8.0.x-enterprise"
97+
ENV COMPASS_E2E_WEBDRIVER_WAITFOR_TIMEOUT="240000"
98+
ENV COMPASS_E2E_WEBDRIVER_WAITFOR_INTERVAL="1000"
99+
100+
ENTRYPOINT ["./entrypoint.sh"]
101+
CMD ["web"]

0 commit comments

Comments
 (0)