-
Notifications
You must be signed in to change notification settings - Fork 376
/
factory.Dockerfile
127 lines (104 loc) · 4.68 KB
/
factory.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Set base image arg to allow easy testing of other debian versions.
ARG BASE_IMAGE
FROM ${BASE_IMAGE} as factory
# "fake" dbus address to prevent errors
# https://github.com/SeleniumHQ/docker-selenium/issues/87
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null \
# a few environment variables to make NPM installs easier
# good colors for most applications
TERM=xterm \
# avoid million NPM install messages
npm_config_loglevel=warn \
# avoid too many progress messages
# https://github.com/cypress-io/cypress/issues/1243
CI=1 \
# disable shared memory X11 affecting Cypress v4 and Chrome
# https://github.com/cypress-io/cypress-docker-images/issues/270
QT_X11_NO_MITSHM=1 \
_X11_NO_MITSHM=1 \
_MITSHM=0 \
# point Cypress at the /root/cache no matter what user account is used
# see https://on.cypress.io/caching
CYPRESS_CACHE_FOLDER=/root/.cache/Cypress
# give every user read access to the "/root" folder where the binary is cached
# we really only need to worry about the top folder, fortunately
# TODO: there are other folders that need permissions but I don't know what they are yet, See: https://github.com/cypress-io/cypress/issues/23962
RUN ls -la /root \
&& chmod 777 /root \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
# Always install: Needed to run Cypress
xvfb \
libglib2.0-0 \
libnss3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libgtk-3-0 \
libgbm1 \
libasound2 \
# Needed to support the ps command, while not used by cypress directly it is used by some of our examples and the dependency is small (~1mb).
procps \
# Needed to support curl, similar to ps, it's not directly used by cypress but leaving it in the container is practically free.
curl \
# Always install: Needed for dashboard integration
git \
# Install ssh client to enable git cloning via ssh without falling back to CI's native git client.
openssh-client\
# Chrome and Edge require wget even after installation. We could do more work to dynamically remove it, but I doubt it's worth it.
wget \
# Needed to make https calls from the docker container
openssl \
ca-certificates \
# build only dependancies: removed in onbuild step
bzip2 \
gnupg \
dirmngr \
# Needed by cypress installation 'unzip.js' script
unzip
# Copy install scripts into container, these will be deleted in an onbuild step later.
COPY ./installScripts /opt/installScripts
# Set the default node version, node is required.
ARG FACTORY_DEFAULT_NODE_VERSION
# Set the default node version to an env to allow us to access it in the onbuild step.
ENV CYPRESS_FACTORY_DEFAULT_NODE_VERSION=${FACTORY_DEFAULT_NODE_VERSION}
# Install Node: Node MUST be installed, so the default lives here
ONBUILD ARG NODE_VERSION
# Don't rely on the docker arg default, if we do the default won't be overriden if the arg is declared in the dockerfile.
ONBUILD ENV APPLIED_FACTORY_DEFAULT_NODE_VERSION=${NODE_VERSION:-${CYPRESS_FACTORY_DEFAULT_NODE_VERSION}}
# Node is installed via a bash script because node isn't installed yet!
ONBUILD RUN bash /opt/installScripts/node/install-node-version.sh ${APPLIED_FACTORY_DEFAULT_NODE_VERSION}
# Install Yarn: Optional
ONBUILD ARG YARN_VERSION
# Installed using a node script to handle conditionals since we all know javascript
ONBUILD RUN node /opt/installScripts/yarn/install-yarn-version.js ${YARN_VERSION}
# Install Chrome: optional
ONBUILD ARG CHROME_VERSION
ONBUILD RUN node /opt/installScripts/chrome/install-chrome-version.js ${CHROME_VERSION}
# Install Edge: optional
ONBUILD ARG EDGE_VERSION
ONBUILD RUN node /opt/installScripts/edge/install-edge-version.js ${EDGE_VERSION}
# Install Firefox: optional
ONBUILD ARG FIREFOX_VERSION
ONBUILD RUN node /opt/installScripts/firefox/install-firefox-version.js ${FIREFOX_VERSION}
# TODO: Globally installed webkit currently isn't found, see issue https://github.com/cypress-io/cypress/issues/25344
# Install Webkit: optional
# ONBUILD ARG WEBKIT_VERSION
# ONBUILD RUN node /opt/installScripts/webkit/install-webkit-version.js ${WEBKIT_VERSION}
# Install Cypress: optional
ONBUILD ARG CYPRESS_VERSION
# Allow projects to reference globally installed cypress
# This is only set if the cypress version is passed in (thats what the + syntax stuff does.)
ONBUILD ENV NODE_PATH=${CYPRESS_VERSION:+/usr/local/lib/node_modules}
ONBUILD RUN node /opt/installScripts/cypress/install-cypress-version.js ${CYPRESS_VERSION}
# Global Cleanup
ONBUILD RUN apt-get purge -y --auto-remove \
curl \
bzip2 \
gnupg \
dirmngr\
&& rm -rf /usr/share/doc \
&& rm -rf /usr/share/man \
&& rm -rf /var/lib/apt/lists/* \
# Remove cypress install scripts
&& rm -rf /opt/installScripts