-
Notifications
You must be signed in to change notification settings - Fork 38
/
Dockerfile
283 lines (256 loc) · 6.13 KB
/
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# Pull base image.
FROM ubuntu:bionic-20210416
COPY . /opt/Empirical
SHELL ["/bin/bash", "-c"]
# Prevent interactive time zone config.
# adapted from https://askubuntu.com/a/1013396
ENV DEBIAN_FRONTEND=noninteractive
RUN \
echo 'Acquire::http::Timeout "60";' >> "/etc/apt/apt.conf.d/99timeout" \
&& \
echo 'Acquire::ftp::Timeout "60";' >> "/etc/apt/apt.conf.d/99timeout" \
&& \
echo 'Acquire::Retries "100";' >> "/etc/apt/apt.conf.d/99timeout" \
&& \
echo "buffed apt-get resiliency"
# Install apt packages
# xvfb nonsense adapted from https://github.com/samgiles/docker-xvfb
# remove -backports, -updates, -proposed, -security repositories
# looks like we have to grab libxxhash0 from -updates now
RUN \
apt-get update -y \
&& \
apt-get install --no-install-recommends libxxhash0 \
&& \
apt-get clean \
&& \
rm -rf /var/lib/apt/lists/* \
&& \
find /etc/apt -type f -name '*.list' -exec sed -i 's/\(^deb.*-backports.*\)/#\1/; s/\(^deb.*-updates.*\)/#\1/; s/\(^deb.*-proposed.*\)/#\1/; s/\(^deb.*-security.*\)/#\1/' {} + \
&& \
apt-get update -y \
&& \
apt-get install -y software-properties-common=0.96.24.32.1 \
&& \
add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& \
apt-get update -y \
&& \
apt-get install --no-install-recommends --allow-downgrades -y \
dpkg-dev \
libc6=2.27-3ubuntu1 \
libc6-dev \
libc6-dbg \
build-essential \
xvfb \
x11vnc \
x11-xkb-utils \
xfonts-100dpi \
xfonts-75dpi \
xfonts-scalable \
xfonts-cyrillic \
x11-apps \
gtk2-engines-pixbuf \
firefox \
libnss3 \
lsb-release \
xdg-utils \
g++-8=8-20180414-1ubuntu2 \
gcc-8-base=8-20180414-1ubuntu2 \
cpp-8=8-20180414-1ubuntu2 \
gcc-8=8-20180414-1ubuntu2 \
gcc-8-base=8-20180414-1ubuntu2 \
libgcc-8-dev \
libstdc++-8-dev \
cmake \
python-virtualenv \
python-pip-whl \
python-pip \
python-setuptools \
python3-setuptools \
python3-virtualenv \
python3-pip \
nodejs \
npm \
tar \
gzip \
libpthread-stubs0-dev \
gdb \
doxygen \
curl \
perl \
perl-base=5.26.1-6 \
git \
htop \
man \
unzip \
vim-common \
vim-runtime \
vim \
nano \
wget \
ssh-client \
libasound2 \
gpg-agent \
&& \
apt-get clean \
&& \
rm -rf /var/lib/apt/lists/* \
&& \
echo "installed apt packages"
RUN \
echo $' \n\
XVFB=/usr/bin/Xvfb \n\
XVFBARGS="$DISPLAY -ac -screen 0 1024x768x16 +extension RANDR" \n\
PIDFILE=/var/xvfb_${DISPLAY:1}.pid \n\
case "$1" in \n\
start) \n\
echo -n "Starting virtual X frame buffer: Xvfb" \n\
/sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS \n\
echo "." \n\
;; \n\
stop) \n\
echo -n "Stopping virtual X frame buffer: Xvfb" \n\
/sbin/start-stop-daemon --stop --quiet --pidfile $PIDFILE \n\
echo "." \n\
;; \n\
restart) \n\
$0 stop \n\
$0 start \n\
;; \n\
*) \n\
echo "Usage: /etc/init.d/xvfb {start|stop|restart}" \n\
exit 1 \n\
esac \n\
exit 0 \n\
' > /etc/init.d/xvfb \
&& \
echo "write xvfb init.d script"
RUN \
chmod a+x /etc/init.d/xvfb \
&& \
echo "make xvfb init.d script executable"
RUN \
echo $'#!/bin/bash\n\
export DISPLAY=:99\n\
/etc/init.d/xvfb start\n\
sleep 1\n\
$@\n\
exit_value=$?\n\
/etc/init.d/xvfb stop\n\
exit $exit_value\n\
' > /usr/bin/xvfb-daemon-run \
&& \
echo "write xvfb daemon script"
RUN \
chmod a+x /usr/bin/xvfb-daemon-run \
&& \
echo "make xvfb daemon script executable"
ENV DISPLAY :99
# magic from https://github.com/puppeteer/puppeteer/issues/3451#issuecomment-523961368
RUN echo 'kernel.unprivileged_userns_clone=1' > /etc/sysctl.d/userns.conf
RUN \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90 \
&& \
npm install -g n \
&& \
n 12.18.2 \
&& \
export python="/usr/bin/python3" \
&& \
npm install source-map \
&& \
echo "finalized set up dependency versions"
RUN \
pip install wheel==0.30.0 \
&& \
pip3 install wheel==0.30.0 \
&& \
pip3 install -r /opt/Empirical/doc/requirements.txt \
&& \
echo "installed documentation build requirements"
RUN \
cd /opt/Empirical \
&& \
git submodule deinit -f . \
&& \
git submodule init \
&& \
git submodule update -f \
&& \
echo "initialized submodules"
RUN \
cd /opt/Empirical \
&& \
make install-test-dependencies \
&& \
echo "installed test dependencies"
RUN \
cd /opt/Empirical \
&& \
git remote set-url origin https://github.com/devosoft/Empirical.git \
&& \
echo "switched to https origin remote url"
RUN \
/etc/init.d/xvfb start \
&& \
cd /opt/Empirical/tests \
&& \
make test-web \
&& \
make test-base \
&& \
make clean \
&& \
echo "representative tests passed!"
# Define default working directory.
WORKDIR /opt/Empirical
RUN \
echo $'#!/bin/bash\n\
set -e\n\
/etc/init.d/xvfb start\n\
exec "$@"\n\
' > /opt/entrypoint.sh \
&& \
echo "write entrypoint script"
RUN \
chmod a+x /opt/entrypoint.sh \
&& \
echo "make entrypoint script executable"
# Adapted from https://github.com/karma-runner/karma-firefox-launcher/issues/93#issuecomment-519333245
# Maybe important for container compatability running on Windows?
RUN \
cd /opt/ \
&& \
npm install -g yarn \
&& \
git clone https://github.com/karma-runner/karma-firefox-launcher.git \
&& \
cd karma-firefox-launcher \
&& \
yarn install \
&& \
echo "installed karma-firefox-launcher"
RUN \
pip install -r /opt/Empirical/third-party/requirements.txt \
&& \
echo "installed documentation build requirements"
# Perform any further action as an unprivileged user.
# adapted from https://stackoverflow.com/a/27703359
# and https://superuser.com/a/235398
RUN \
useradd --create-home --shell /bin/bash user \
&& \
groupadd group \
&& \
gpasswd -a user group \
&& \
chgrp --recursive user /opt \
&& \
chmod --recursive g+rwx /opt \
&& \
echo "user added and granted permissions to /opt"
USER user
# Define default entrypoint.
ENTRYPOINT ["/opt/entrypoint.sh"]
CMD ["bash"]