Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/buildenv/docker/mkdocker.sh
12450 views
1
#!/bin/bash -
2
3
print_license() {
4
cat <<- EOF
5
# Copyright (c) 2019, 2022 IBM Corp. and others
6
#
7
# This program and the accompanying materials are made available under
8
# the terms of the Eclipse Public License 2.0 which accompanies this
9
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
10
# or the Apache License, Version 2.0 which accompanies this distribution and
11
# is available at https://www.apache.org/licenses/LICENSE-2.0.
12
#
13
# This Source Code may also be made available under the following
14
# Secondary Licenses when the conditions for such availability set
15
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
16
# General Public License, version 2 with the GNU Classpath
17
# Exception [1] and GNU General Public License, version 2 with the
18
# OpenJDK Assembly Exception [2].
19
#
20
# [1] https://www.gnu.org/software/classpath/license.html
21
# [2] http://openjdk.java.net/legal/assembly-exception.html
22
#
23
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
24
EOF
25
}
26
27
usage() {
28
echo "Usage: $0 [OPTION]..."
29
echo "Generate a Dockerfile for building OpenJ9"
30
echo ""
31
echo "Options:"
32
echo " --help|-h print this help, then exit"
33
echo " --arch=... specify the processor architecture (default: host architecture)"
34
echo " --build build the docker image (overrides '--print')"
35
echo " --cuda include CUDA header files"
36
echo " --dist=... specify the Linux distribution (e.g. centos, ubuntu)"
37
echo " --freemarker include freemarker.jar"
38
echo " --gitcache={yes|no} generate the git cache (default: yes)"
39
echo " --jdk=... specify which JDKs can be built (default: all)"
40
echo " --print write the Dockerfile to stdout (default; overrides '--build')"
41
echo " --tag=... specify a name for the docker image (may be repeated, default: none)"
42
echo " --user=... specify the user name (default: 'jenkins')"
43
echo " --version=... specify the distribution version (e.g. 6, 18.04)"
44
echo ""
45
local arch="$(uname -m)"
46
echo "Supported build patterns on this host ($arch):"
47
if [ $arch = x86_64 ] ; then
48
echo " bash mkdocker.sh --tag=openj9/cent6 --dist=centos --version=6 --build"
49
fi
50
if [ $arch = x86_64 -o $arch = ppc64le ] ; then
51
echo " bash mkdocker.sh --tag=openj9/cent7 --dist=centos --version=7 --build"
52
fi
53
echo " bash mkdocker.sh --tag=openj9/ub16 --dist=ubuntu --version=16 --build"
54
echo " bash mkdocker.sh --tag=openj9/ub18 --dist=ubuntu --version=18 --build"
55
echo " bash mkdocker.sh --tag=openj9/ub20 --dist=ubuntu --version=20 --build"
56
exit 1
57
}
58
59
# Global configuration variables.
60
action=print
61
all_versions=
62
arch=
63
cuda=no
64
dist=unspecified
65
freemarker=no
66
gen_git_cache=yes
67
jdk_versions=all
68
tags=()
69
user=jenkins
70
userid=1000
71
version=unspecified
72
73
# Frequently used commands.
74
wget_O="wget --progress=dot:mega -O"
75
76
parse_options() {
77
local arg
78
for arg in "$@" ; do
79
case "$arg" in
80
-h | --help)
81
usage
82
;;
83
--arch=*)
84
arch="${arg#*=}"
85
;;
86
--build)
87
action=build
88
;;
89
--cuda)
90
cuda=9.0
91
;;
92
--dist=*)
93
dist="${arg#*=}"
94
;;
95
--freemarker)
96
freemarker=yes
97
;;
98
--gitcache=*)
99
gen_git_cache="${arg#*=}"
100
;;
101
--jdk=*)
102
jdk_versions="${arg#*=}"
103
;;
104
--print)
105
action=print
106
;;
107
--tag=*)
108
tags+=("${arg#*=}")
109
;;
110
--user=*)
111
user="${arg#*=}"
112
;;
113
--version=*)
114
version="${arg#*=}"
115
;;
116
*) # bad option
117
echo "Unsupported option: '$arg'" >&2
118
usage
119
;;
120
esac
121
done
122
}
123
124
validate_options() {
125
if [ "x$arch" = x ] ; then
126
arch="$(uname -m)"
127
fi
128
129
case "$arch" in
130
ppc64le | s390x | x86_64)
131
;;
132
*)
133
echo "Unsupported architecture: '$arch'" >&2
134
exit 1
135
;;
136
esac
137
138
# Validate the distribution and version.
139
case "$dist" in
140
centos)
141
if [ $arch = s390x ] ; then
142
echo "CentOS is not supported on $arch" >&2
143
exit 1
144
fi
145
case $version in
146
6)
147
if [ $arch = ppc64le ] ; then
148
echo "CentOS version 6 is not supported on $arch" >&2
149
exit 1
150
fi
151
;;
152
7)
153
;;
154
unspecified)
155
echo "Unspecified CentOS version: use '--version' option" >&2
156
exit 1
157
;;
158
*)
159
echo "Unsupported CentOS version: '$version'" >&2
160
exit 1
161
;;
162
esac
163
;;
164
ubuntu)
165
case $version in
166
16 | 18 | 20)
167
version=$version.04
168
;;
169
16.04 | 18.04 | 20.04)
170
;;
171
unspecified)
172
echo "Unspecified Ubuntu version: use '--version' option" >&2
173
exit 1
174
;;
175
*)
176
echo "Unsupported Ubuntu version: '$version'" >&2
177
exit 1
178
;;
179
esac
180
;;
181
unspecified)
182
echo "Unspecified distribution: use '--dist' option" >&2
183
exit 1
184
;;
185
*)
186
echo "Unsupported distribution: '$dist'" >&2
187
exit 1
188
;;
189
esac
190
191
# If CUDA is requested, validate the architecture.
192
if [ $cuda != no ] ; then
193
case "$arch" in
194
ppc64le | x86_64)
195
;;
196
*)
197
echo "CUDA is not supported on architecture: '$arch'" >&2
198
exit 1
199
;;
200
esac
201
fi
202
203
all_versions="8 11 17 18 next"
204
local -A known_version
205
local version
206
for version in $all_versions ; do
207
known_version[$version]=yes
208
done
209
210
if [ "$jdk_versions" = all ] ; then
211
jdk_versions="$all_versions"
212
fi
213
214
for version in ${jdk_versions} ; do
215
if [ "${known_version[$version]}" != yes ] ; then
216
echo "Unsupported JDK version: '$version'" >&2
217
exit 1
218
fi
219
done
220
}
221
222
build_cmd() {
223
local cmd=build
224
local file=$1
225
local tag
226
for tag in ${tags[@]} ; do
227
cmd="$cmd --tag $tag"
228
done
229
echo $cmd --file $file .
230
}
231
232
preamble() {
233
local tag
234
echo ""
235
echo "# Generated by: mkdocker.sh $command_line"
236
echo ""
237
echo "# To use this docker file:"
238
echo "# First, copy your public ssh key into authorized_keys."
239
echo "# Then, in the directory containing the Dockerfile, authorized_keys"
240
echo "# file, and known_hosts file, run:"
241
echo "# docker $(build_cmd Dockerfile)"
242
echo "#"
243
if [ ${#tags[@]} -lt 2 ] ; then
244
echo "# To start a container based on the resulting image, run this command:"
245
else
246
echo "# To start a container based on the resulting image, run one of these commands:"
247
fi
248
if [ ${#tags[@]} -eq 0 ] ; then
249
echo "# docker run -it <image>"
250
else
251
for tag in ${tags[@]} ; do
252
echo "# docker run -it $tag"
253
done
254
fi
255
echo ""
256
if [ $cuda != no ] ; then
257
echo "FROM nvidia/cuda:${cuda}-devel-ubuntu16.04 AS cuda-dev"
258
echo ""
259
fi
260
echo "FROM $dist:$version"
261
}
262
263
install_centos_packages() {
264
if [ $version = 6 ] ; then
265
echo "RUN sed -i -e 's|mirrorlist|#mirrorlist|' \\"
266
echo " -e 's|#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=https://vault.centos.org/6.10|' \\"
267
echo " /etc/yum.repos.d/CentOS-Base.repo"
268
echo ""
269
fi
270
echo "RUN yum -y update \\"
271
echo " && yum install -y epel-release \\"
272
echo " && yum -y install \\"
273
echo " alsa-lib-devel \\"
274
echo " automake \\" # required to update make
275
echo " bind-utils \\"
276
echo " bison \\"
277
echo " bzip2 \\"
278
echo " ca-certificates \\"
279
echo " cpio \\"
280
echo " cups-devel \\"
281
echo " curl-devel \\" # required by git
282
echo " elfutils-libelf-devel \\"
283
echo " expat-devel \\" # required by git and the xml parser
284
echo " file-devel \\"
285
echo " file-libs \\"
286
echo " flex \\"
287
echo " fontconfig \\"
288
echo " fontconfig-devel \\"
289
echo " freetype-devel \\"
290
echo " gettext \\"
291
echo " gettext-devel \\" # required by git
292
echo " glibc \\"
293
echo " glibc-common \\"
294
echo " glibc-devel \\"
295
echo " gmp-devel \\"
296
echo " lbzip2 \\"
297
echo " libdwarf \\"
298
echo " libdwarf-devel \\"
299
echo " libffi-devel \\"
300
echo " libstdc++-static \\"
301
echo " libX11-devel \\"
302
echo " libXext-devel \\"
303
echo " libXi-devel \\"
304
echo " libXrandr-devel \\"
305
echo " libXrender-devel \\"
306
echo " libXt-devel \\"
307
echo " libXtst-devel \\"
308
echo " make \\"
309
echo " mesa-libGL-devel \\"
310
echo " mpfr-devel \\"
311
echo " ntp \\"
312
echo " numactl-devel \\"
313
echo " openssh-clients \\"
314
echo " openssh-server \\"
315
echo " openssl-devel \\" # required by git, etc.
316
echo " perl-CPAN \\"
317
echo " perl-DBI \\"
318
echo " perl-devel \\"
319
echo " perl-ExtUtils-MakeMaker \\" # required by git
320
echo " perl-GD \\"
321
echo " perl-libwww-perl \\"
322
echo " perl-Time-HiRes \\"
323
echo " systemtap-devel \\"
324
echo " texinfo \\" # required to update make
325
echo " unzip \\"
326
echo " vim \\"
327
echo " wget \\"
328
echo " xorg-x11-server-Xvfb \\"
329
echo " xz \\"
330
echo " zip \\"
331
echo " zlib-devel \\" # required by git, python
332
echo " && yum clean all"
333
echo ""
334
local autoconf_version=2.69
335
echo "# Install autoconf."
336
echo "RUN cd /tmp \\"
337
echo " && $wget_O autoconf.tar.gz https://ftp.gnu.org/gnu/autoconf/autoconf-$autoconf_version.tar.gz \\"
338
echo " && tar -xzf autoconf.tar.gz \\"
339
echo " && cd autoconf-$autoconf_version \\"
340
echo " && ./configure --build=\$(rpm --eval %{_host}) \\"
341
echo " && make \\"
342
echo " && make install \\"
343
echo " && cd .. \\"
344
echo " && rm -rf autoconf.tar.gz autoconf-$autoconf_version"
345
echo ""
346
echo "# Install gcc-7.5."
347
echo "RUN cd /usr/local \\"
348
echo " && $wget_O gcc-7.tar.xz 'https://ci.adoptopenjdk.net/userContent/gcc/gcc750+ccache.$arch.tar.xz' \\"
349
echo " && tar -xJf gcc-7.tar.xz --strip-components=1 \\"
350
echo " && ln -sf ../local/bin/gcc-7.5 /usr/bin/gcc \\"
351
echo " && ln -sf ../local/bin/g++-7.5 /usr/bin/g++ \\"
352
echo " && ln -sf gcc /usr/bin/cc \\"
353
echo " && ln -sf g++ /usr/bin/c++ \\"
354
echo " && rm -f gcc-7.tar.xz"
355
echo ""
356
local ant_version=1.10.5
357
echo "# Install ant."
358
echo "RUN cd /tmp \\"
359
echo " && $wget_O ant.zip https://archive.apache.org/dist/ant/binaries/apache-ant-$ant_version-bin.zip \\"
360
echo " && unzip -q ant.zip -d /opt \\"
361
echo " && ln -s apache-ant-$ant_version /opt/ant \\"
362
echo " && ln -s /opt/ant/bin/ant /usr/bin/ant \\"
363
echo " && $wget_O ant-contrib.tar.gz https://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.tar.gz \\"
364
echo " && tar -xzf ant-contrib.tar.gz \\"
365
echo " && mv ant-contrib/ant-contrib-1.0b3.jar /opt/ant/lib \\"
366
echo " && rm -rf ant-contrib ant.zip ant-contrib.tar.gz"
367
echo ""
368
local git_version=2.5.3
369
echo "# Install git."
370
echo "RUN cd /tmp \\"
371
echo " && $wget_O git.tar.gz https://www.kernel.org/pub/software/scm/git/git-$git_version.tar.gz \\"
372
echo " && tar -xzf git.tar.gz --no-same-owner \\"
373
echo " && cd git-$git_version \\"
374
echo " && make prefix=/usr/local all \\"
375
echo " && make prefix=/usr/local install \\"
376
echo " && cd .. \\"
377
echo " && rm -rf git.tar.gz git-$git_version"
378
# updating make requires automake 1.15
379
echo ""
380
local automake_version=1.15
381
echo "# Update automake."
382
echo "RUN cd /tmp \\"
383
echo " && $wget_O automake.tar.gz http://ftp.gnu.org/gnu/automake/automake-$automake_version.tar.gz \\"
384
echo " && tar -xzf automake.tar.gz \\"
385
echo " && cd automake-$automake_version \\"
386
echo " && ./configure \\"
387
echo " && make \\"
388
echo " && make install \\"
389
echo " && cd .. \\"
390
echo " && rm -rf automake.tar.gz automake-$automake_version"
391
if [ $arch = x86_64 ] ; then
392
echo ""
393
local gettext_version=0.20.1
394
echo "# Update gettext."
395
echo "RUN cd /tmp \\"
396
echo " && $wget_O gettext.tar.gz http://ftp.gnu.org/gnu/gettext/gettext-$gettext_version.tar.gz \\"
397
echo " && tar -xzf gettext.tar.gz \\"
398
echo " && cd gettext-$gettext_version \\"
399
echo " && ./autogen.sh --skip-gnulib \\"
400
echo " && ./configure --disable-nls \\"
401
echo " && make \\"
402
echo " && make install \\"
403
echo " && cd .. \\"
404
echo " && rm -rf gettext.tar.gz gettext-$gettext_version"
405
fi
406
echo ""
407
if [ $arch = ppc64le ] ; then
408
local make_version=4.2
409
else
410
local make_version=4.1
411
fi
412
echo "# Update make."
413
echo "RUN cd /tmp \\"
414
echo " && $wget_O make.tar.gz https://github.com/mirror/make/archive/$make_version.tar.gz \\"
415
echo " && tar -xzf make.tar.gz \\"
416
echo " && cd make-$make_version \\"
417
echo " && ACLOCAL_PATH=/usr/share/aclocal autoreconf -i \\"
418
echo " && ./configure \\"
419
echo " && make update \\"
420
echo " && make \\"
421
echo " && make install \\"
422
echo " && ln -s make /usr/local/bin/gmake \\"
423
echo " && cd .. \\"
424
echo " && rm -rf make.tar.gz make-$make_version"
425
if [ $arch = x86_64 ] ; then
426
echo ""
427
local nasm_version=2.13.03
428
echo "# Install nasm."
429
echo "RUN cd /tmp \\"
430
echo " && $wget_O nasm.tar.gz https://www.nasm.us/pub/nasm/releasebuilds/$nasm_version/nasm-$nasm_version.tar.gz \\"
431
echo " && tar -xzf nasm.tar.gz \\"
432
echo " && cd nasm-$nasm_version \\"
433
echo " && ./configure -prefix=/usr/local \\"
434
echo " && make install \\"
435
echo " && cd .. \\"
436
echo " && rm -rf nasm.tar.gz nasm-$nasm_version"
437
fi
438
}
439
440
install_ubuntu_packages() {
441
echo "RUN apt-get update \\"
442
echo " && apt-get install -qq -y --no-install-recommends \\"
443
echo " software-properties-common \\"
444
if [ $version = 16.04 ] ; then
445
echo " python-software-properties \\"
446
fi
447
echo " && add-apt-repository ppa:ubuntu-toolchain-r/test \\"
448
echo " && apt-get update \\"
449
echo " && apt-get install -qq -y --no-install-recommends \\"
450
echo " ant \\"
451
echo " ant-contrib \\"
452
echo " autoconf \\"
453
echo " build-essential \\"
454
echo " ca-certificates \\"
455
echo " cmake \\"
456
echo " cpio \\"
457
echo " curl \\"
458
echo " file \\"
459
if [ $arch != s390x ] ; then
460
echo " g++-7 \\"
461
echo " gcc-7 \\"
462
fi
463
echo " gdb \\"
464
echo " git \\"
465
echo " libasound2-dev \\"
466
echo " libcups2-dev \\"
467
echo " libdwarf-dev \\"
468
echo " libelf-dev \\"
469
echo " libexpat1-dev \\" # required by the xml parser
470
echo " libffi-dev \\"
471
echo " libfontconfig \\"
472
echo " libfontconfig1-dev \\"
473
echo " libfreetype6-dev \\"
474
if [ $arch != s390x ] ; then
475
echo " libnuma-dev \\"
476
fi
477
if [ $arch = s390x ] ; then
478
echo " libmpc3 \\"
479
fi
480
echo " libssl-dev \\"
481
echo " libx11-dev \\"
482
echo " libxext-dev \\"
483
echo " libxrandr-dev \\"
484
echo " libxrender-dev \\"
485
echo " libxt-dev \\"
486
echo " libxtst-dev \\"
487
echo " make \\"
488
if [ $arch = x86_64 ] ; then
489
echo " nasm \\"
490
fi
491
echo " openssh-client \\"
492
echo " openssh-server \\"
493
echo " perl \\"
494
echo " pkg-config \\"
495
if [ $version = 16.04 ] ; then
496
echo " realpath \\"
497
fi
498
echo " ssh \\"
499
echo " systemtap-sdt-dev \\"
500
echo " unzip \\"
501
echo " wget \\"
502
echo " xvfb \\"
503
echo " zip \\"
504
echo " zlib1g-dev \\"
505
echo " && rm -rf /var/lib/apt/lists/*"
506
}
507
508
install_packages() {
509
echo ""
510
echo "# Install required OS tools."
511
echo ""
512
if [ $dist = centos ] ; then
513
install_centos_packages
514
else
515
install_ubuntu_packages
516
fi
517
}
518
519
install_compilers() {
520
if [ $arch = s390x ] ; then
521
echo ""
522
local gcc_version=7.5
523
echo "# Install gcc."
524
echo "RUN cd /usr/local \\"
525
echo " && $wget_O gcc.tar.xz 'https://ci.adoptopenjdk.net/userContent/gcc/gcc750+ccache.$arch.tar.xz' \\"
526
echo " && tar -xJf gcc.tar.xz --strip-components=1 \\"
527
echo " && rm -f gcc.tar.xz"
528
echo ""
529
echo "# Create various symbolic links."
530
echo "RUN ln -s lib/$arch-linux-gnu /usr/lib64 \\"
531
if [ $dist:$version = ubuntu:18.04 ] ; then
532
# On s390x perl needs version 4 of mpfr, but we only have version 6.
533
echo " && ln -s libmpfr.so.6 /usr/lib64/libmpfr.so.4 \\"
534
fi
535
# /usr/local/include/c++ is a directory that already exists so we create these symbolic links in two steps.
536
echo " && ( cd /usr/local/include && for f in \$(ls /usr/include/s390x-linux-gnu/c++) ; do test -e \$f || ln -s /usr/include/s390x-linux-gnu/c++/\$f . ; done ) \\"
537
echo " && ln -s \$(ls -d /usr/include/s390x-linux-gnu/* | grep -v '/c++\$') /usr/local/include \\"
538
echo " && ln -sf ../local/bin/g++-$gcc_version /usr/bin/g++-7 \\"
539
echo " && ln -sf ../local/bin/gcc-$gcc_version /usr/bin/gcc-7"
540
fi
541
if [ $dist != centos ] ; then
542
echo ""
543
echo "ENV CC=gcc-7 CXX=g++-7"
544
fi
545
}
546
547
install_cmake() {
548
if [ $dist == centos ] ; then
549
echo ""
550
local cmake_version=3.11
551
local cmake_name=cmake-$cmake_version.4
552
echo "# Install cmake."
553
echo "RUN cd /tmp \\"
554
echo " && $wget_O cmake.tar.gz https://cmake.org/files/v$cmake_version/$cmake_name.tar.gz \\"
555
echo " && tar -xzf cmake.tar.gz \\"
556
echo " && cd $cmake_name \\"
557
echo " && export LDFLAGS='-static-libstdc++' \\"
558
echo " && ./configure \\"
559
echo " && make \\"
560
echo " && make install \\"
561
echo " && cd .. \\"
562
echo " && rm -rf cmake.tar.gz $cmake_name"
563
fi
564
}
565
566
prepare_user() {
567
# Ensure authorized_keys exists.
568
test -f authorized_keys || touch authorized_keys
569
# Ensure github.com is a known host.
570
( test -f known_hosts && grep -q '^github.com ' known_hosts ) \
571
|| ssh-keyscan github.com >> known_hosts
572
}
573
574
create_user() {
575
echo ""
576
echo "# Add user home and copy authorized_keys and known_hosts."
577
echo "RUN useradd -ms /bin/bash --uid $userid $user \\"
578
echo " && mkdir /home/$user/.ssh \\"
579
echo " && chmod 700 /home/$user/.ssh"
580
echo "COPY authorized_keys known_hosts /home/$user/.ssh/"
581
echo "RUN chmod -R go= /home/$user/.ssh \\"
582
echo " && echo "ulimit -u 32000 -n 2048" >> /home/$user/.bashrc"
583
}
584
585
adjust_user_directory_perms() {
586
echo "RUN chown -R $user:$user /home/$user"
587
}
588
589
install_freemarker() {
590
echo ""
591
local freemarker_version=2.3.8
592
echo "# Download and extract freemarker.jar to /home/$user/freemarker.jar."
593
echo "RUN cd /home/$user \\"
594
echo " && $wget_O freemarker.tar.gz https://sourceforge.net/projects/freemarker/files/freemarker/$freemarker_version/freemarker-$freemarker_version.tar.gz/download \\"
595
echo " && tar -xzf freemarker.tar.gz freemarker-$freemarker_version/lib/freemarker.jar --strip-components=2 \\"
596
echo " && rm -f freemarker.tar.gz"
597
}
598
599
bootjdk_dirs() {
600
local version
601
for version in $@ ; do
602
echo /home/$user/bootjdks/jdk$version
603
done
604
}
605
606
bootjdk_url() {
607
local jdk_arch=${arch/x86_64/x64}
608
local jdk_version=$1
609
if [ $jdk_version -lt 18 ] ; then
610
echo https://api.adoptopenjdk.net/v3/binary/latest/$jdk_version/ga/linux/$jdk_arch/jdk/openj9/normal/adoptopenjdk
611
else
612
echo https://api.adoptium.net/v3/binary/latest/$jdk_version/ga/linux/$jdk_arch/jdk/hotspot/normal/eclipse
613
fi
614
}
615
616
install_bootjdks() {
617
local bootjdk_versions=
618
local version
619
local -A wanted
620
for version in $jdk_versions ; do
621
if [ $version = next ] ; then
622
wanted[17]=yes
623
elif [ $version = 18 ] ; then
624
wanted[17]=yes
625
else
626
wanted[$version]=yes
627
fi
628
done
629
for version in ${all_versions/next/} ; do
630
if [ "${wanted[$version]}" = yes ] ; then
631
bootjdk_versions="$bootjdk_versions $version"
632
fi
633
done
634
echo ""
635
echo "# Download and install boot JDKs."
636
echo "RUN cd /tmp \\"
637
for version in $bootjdk_versions ; do
638
echo " && $wget_O jdk$version.tar.gz $(bootjdk_url $version) \\"
639
done
640
echo " && mkdir -p" $(bootjdk_dirs $bootjdk_versions) "\\"
641
for version in $bootjdk_versions ; do
642
echo " && tar -xzf jdk$version.tar.gz --directory=$(bootjdk_dirs $version)/ --strip-components=1 \\"
643
done
644
echo " && rm -f jdk*.tar.gz"
645
}
646
647
install_cuda() {
648
echo ""
649
echo "# Copy header files necessary to build a VM with CUDA support."
650
echo "RUN mkdir -p /usr/local/cuda-${cuda}/nvvm"
651
echo "COPY --from=cuda-dev /usr/local/cuda-${cuda}/include /usr/local/cuda-${cuda}/include"
652
echo "COPY --from=cuda-dev /usr/local/cuda-${cuda}/nvvm/include /usr/local/cuda-${cuda}/nvvm/include"
653
echo "ENV CUDA_HOME=/usr/local/cuda-${cuda}"
654
}
655
656
install_python() {
657
local python_version=3.7.3
658
echo ""
659
echo "# Install python."
660
echo "RUN cd /tmp \\"
661
echo " && $wget_O python.tar.xz https://www.python.org/ftp/python/$python_version/Python-$python_version.tar.xz \\"
662
echo " && tar -xJf python.tar.xz \\"
663
echo " && cd Python-$python_version \\"
664
echo " && ./configure --prefix=/usr/local \\"
665
echo " && make \\"
666
echo " && make install \\"
667
echo " && cd .. \\"
668
echo " && rm -rf python.tar.xz Python-$python_version"
669
}
670
671
adjust_ldconfig() {
672
echo ""
673
echo "# Run ldconfig to discover newly installed shared libraries."
674
echo "RUN for dir in lib lib64 ; do echo /usr/local/\$dir ; done > /etc/ld.so.conf.d/usr-local.conf \\"
675
echo " && ldconfig"
676
}
677
678
# called as: add_git_remote remote url
679
add_git_remote() {
680
echo " && git remote add ${1} ${2} \\"
681
# Like-named (and conflicting) tags exist in multiple repositories: don't fetch any tags.
682
echo " && git config remote.${1}.tagopt --no-tags \\"
683
}
684
685
create_git_cache() {
686
local git_cache_dir=/home/$user/openjdk_cache
687
local version
688
local -A wanted
689
for version in $jdk_versions ; do
690
wanted[$version]=yes
691
done
692
# The jdk17 remote is fetched first because that repository was subjected to
693
# 'git gc --aggressive --prune=all' before it was first published making it much
694
# smaller than some other jdk repositories. There is a large degree of overlap
695
# among the jdk repositories so a relatively small number of commits must be
696
# fetched from the others.
697
echo ""
698
echo "# Setup a reference repository cache for faster clones in containers."
699
echo "RUN mkdir $git_cache_dir \\"
700
echo " && cd $git_cache_dir \\"
701
echo " && git init --bare \\"
702
for version in $all_versions ; do
703
if [ "${wanted[$version]}" = yes ] ; then
704
add_git_remote jdk$version https://github.com/ibmruntimes/openj9-openjdk-jdk${version/next/}.git
705
fi
706
done
707
add_git_remote omr https://github.com/eclipse-openj9/openj9-omr.git
708
add_git_remote openj9 https://github.com/eclipse-openj9/openj9.git
709
echo " && echo Fetching repository cache... \\"
710
if [ "${wanted[17]}" = yes ] ; then
711
echo " && git fetch jdk17 \\"
712
fi
713
echo " && git fetch --all \\"
714
echo " && echo Shrinking repository cache... \\"
715
echo " && git gc --aggressive --prune=all"
716
}
717
718
configure_ssh() {
719
echo ""
720
echo "# Configure sshd."
721
echo "RUN mkdir /var/run/sshd \\"
722
echo " && sed -i -e 's|#PermitRootLogin|PermitRootLogin|' \\"
723
echo " -e 's|#RSAAuthentication.*|RSAAuthentication yes|' \\"
724
echo " -e 's|#PubkeyAuthentication.*|PubkeyAuthentication yes|' /etc/ssh/sshd_config"
725
echo ""
726
echo "# SSH login fix so user is not kicked off after login."
727
echo "RUN sed -i -e 's|session\s*required\s*pam_loginuid.so|session optional pam_loginuid.so|' /etc/pam.d/sshd"
728
echo ""
729
echo "# Expose SSH port."
730
echo "EXPOSE 22"
731
}
732
733
print_dockerfile() {
734
print_license
735
preamble
736
install_packages
737
create_user
738
if [ $cuda != no ] ; then
739
install_cuda
740
fi
741
if [ $freemarker = yes ] ; then
742
install_freemarker
743
fi
744
install_compilers
745
746
install_cmake
747
install_python
748
749
adjust_ldconfig
750
configure_ssh
751
752
install_bootjdks
753
if [ $gen_git_cache = yes ] ; then
754
create_git_cache
755
fi
756
adjust_user_directory_perms
757
}
758
759
main() {
760
if [ $action = build ] ; then
761
prepare_user
762
print_dockerfile | docker $(build_cmd -)
763
else
764
print_dockerfile
765
fi
766
}
767
768
command_line="$*"
769
parse_options "$@"
770
validate_options
771
main
772
773