Path: blob/master/buildenv/docker/mkdocker.sh
12450 views
#!/bin/bash -12print_license() {3cat <<- EOF4# Copyright (c) 2019, 2022 IBM Corp. and others5#6# This program and the accompanying materials are made available under7# the terms of the Eclipse Public License 2.0 which accompanies this8# distribution and is available at https://www.eclipse.org/legal/epl-2.0/9# or the Apache License, Version 2.0 which accompanies this distribution and10# is available at https://www.apache.org/licenses/LICENSE-2.0.11#12# This Source Code may also be made available under the following13# Secondary Licenses when the conditions for such availability set14# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU15# General Public License, version 2 with the GNU Classpath16# Exception [1] and GNU General Public License, version 2 with the17# OpenJDK Assembly Exception [2].18#19# [1] https://www.gnu.org/software/classpath/license.html20# [2] http://openjdk.java.net/legal/assembly-exception.html21#22# 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-exception23EOF24}2526usage() {27echo "Usage: $0 [OPTION]..."28echo "Generate a Dockerfile for building OpenJ9"29echo ""30echo "Options:"31echo " --help|-h print this help, then exit"32echo " --arch=... specify the processor architecture (default: host architecture)"33echo " --build build the docker image (overrides '--print')"34echo " --cuda include CUDA header files"35echo " --dist=... specify the Linux distribution (e.g. centos, ubuntu)"36echo " --freemarker include freemarker.jar"37echo " --gitcache={yes|no} generate the git cache (default: yes)"38echo " --jdk=... specify which JDKs can be built (default: all)"39echo " --print write the Dockerfile to stdout (default; overrides '--build')"40echo " --tag=... specify a name for the docker image (may be repeated, default: none)"41echo " --user=... specify the user name (default: 'jenkins')"42echo " --version=... specify the distribution version (e.g. 6, 18.04)"43echo ""44local arch="$(uname -m)"45echo "Supported build patterns on this host ($arch):"46if [ $arch = x86_64 ] ; then47echo " bash mkdocker.sh --tag=openj9/cent6 --dist=centos --version=6 --build"48fi49if [ $arch = x86_64 -o $arch = ppc64le ] ; then50echo " bash mkdocker.sh --tag=openj9/cent7 --dist=centos --version=7 --build"51fi52echo " bash mkdocker.sh --tag=openj9/ub16 --dist=ubuntu --version=16 --build"53echo " bash mkdocker.sh --tag=openj9/ub18 --dist=ubuntu --version=18 --build"54echo " bash mkdocker.sh --tag=openj9/ub20 --dist=ubuntu --version=20 --build"55exit 156}5758# Global configuration variables.59action=print60all_versions=61arch=62cuda=no63dist=unspecified64freemarker=no65gen_git_cache=yes66jdk_versions=all67tags=()68user=jenkins69userid=100070version=unspecified7172# Frequently used commands.73wget_O="wget --progress=dot:mega -O"7475parse_options() {76local arg77for arg in "$@" ; do78case "$arg" in79-h | --help)80usage81;;82--arch=*)83arch="${arg#*=}"84;;85--build)86action=build87;;88--cuda)89cuda=9.090;;91--dist=*)92dist="${arg#*=}"93;;94--freemarker)95freemarker=yes96;;97--gitcache=*)98gen_git_cache="${arg#*=}"99;;100--jdk=*)101jdk_versions="${arg#*=}"102;;103--print)104action=print105;;106--tag=*)107tags+=("${arg#*=}")108;;109--user=*)110user="${arg#*=}"111;;112--version=*)113version="${arg#*=}"114;;115*) # bad option116echo "Unsupported option: '$arg'" >&2117usage118;;119esac120done121}122123validate_options() {124if [ "x$arch" = x ] ; then125arch="$(uname -m)"126fi127128case "$arch" in129ppc64le | s390x | x86_64)130;;131*)132echo "Unsupported architecture: '$arch'" >&2133exit 1134;;135esac136137# Validate the distribution and version.138case "$dist" in139centos)140if [ $arch = s390x ] ; then141echo "CentOS is not supported on $arch" >&2142exit 1143fi144case $version in1456)146if [ $arch = ppc64le ] ; then147echo "CentOS version 6 is not supported on $arch" >&2148exit 1149fi150;;1517)152;;153unspecified)154echo "Unspecified CentOS version: use '--version' option" >&2155exit 1156;;157*)158echo "Unsupported CentOS version: '$version'" >&2159exit 1160;;161esac162;;163ubuntu)164case $version in16516 | 18 | 20)166version=$version.04167;;16816.04 | 18.04 | 20.04)169;;170unspecified)171echo "Unspecified Ubuntu version: use '--version' option" >&2172exit 1173;;174*)175echo "Unsupported Ubuntu version: '$version'" >&2176exit 1177;;178esac179;;180unspecified)181echo "Unspecified distribution: use '--dist' option" >&2182exit 1183;;184*)185echo "Unsupported distribution: '$dist'" >&2186exit 1187;;188esac189190# If CUDA is requested, validate the architecture.191if [ $cuda != no ] ; then192case "$arch" in193ppc64le | x86_64)194;;195*)196echo "CUDA is not supported on architecture: '$arch'" >&2197exit 1198;;199esac200fi201202all_versions="8 11 17 18 next"203local -A known_version204local version205for version in $all_versions ; do206known_version[$version]=yes207done208209if [ "$jdk_versions" = all ] ; then210jdk_versions="$all_versions"211fi212213for version in ${jdk_versions} ; do214if [ "${known_version[$version]}" != yes ] ; then215echo "Unsupported JDK version: '$version'" >&2216exit 1217fi218done219}220221build_cmd() {222local cmd=build223local file=$1224local tag225for tag in ${tags[@]} ; do226cmd="$cmd --tag $tag"227done228echo $cmd --file $file .229}230231preamble() {232local tag233echo ""234echo "# Generated by: mkdocker.sh $command_line"235echo ""236echo "# To use this docker file:"237echo "# First, copy your public ssh key into authorized_keys."238echo "# Then, in the directory containing the Dockerfile, authorized_keys"239echo "# file, and known_hosts file, run:"240echo "# docker $(build_cmd Dockerfile)"241echo "#"242if [ ${#tags[@]} -lt 2 ] ; then243echo "# To start a container based on the resulting image, run this command:"244else245echo "# To start a container based on the resulting image, run one of these commands:"246fi247if [ ${#tags[@]} -eq 0 ] ; then248echo "# docker run -it <image>"249else250for tag in ${tags[@]} ; do251echo "# docker run -it $tag"252done253fi254echo ""255if [ $cuda != no ] ; then256echo "FROM nvidia/cuda:${cuda}-devel-ubuntu16.04 AS cuda-dev"257echo ""258fi259echo "FROM $dist:$version"260}261262install_centos_packages() {263if [ $version = 6 ] ; then264echo "RUN sed -i -e 's|mirrorlist|#mirrorlist|' \\"265echo " -e 's|#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=https://vault.centos.org/6.10|' \\"266echo " /etc/yum.repos.d/CentOS-Base.repo"267echo ""268fi269echo "RUN yum -y update \\"270echo " && yum install -y epel-release \\"271echo " && yum -y install \\"272echo " alsa-lib-devel \\"273echo " automake \\" # required to update make274echo " bind-utils \\"275echo " bison \\"276echo " bzip2 \\"277echo " ca-certificates \\"278echo " cpio \\"279echo " cups-devel \\"280echo " curl-devel \\" # required by git281echo " elfutils-libelf-devel \\"282echo " expat-devel \\" # required by git and the xml parser283echo " file-devel \\"284echo " file-libs \\"285echo " flex \\"286echo " fontconfig \\"287echo " fontconfig-devel \\"288echo " freetype-devel \\"289echo " gettext \\"290echo " gettext-devel \\" # required by git291echo " glibc \\"292echo " glibc-common \\"293echo " glibc-devel \\"294echo " gmp-devel \\"295echo " lbzip2 \\"296echo " libdwarf \\"297echo " libdwarf-devel \\"298echo " libffi-devel \\"299echo " libstdc++-static \\"300echo " libX11-devel \\"301echo " libXext-devel \\"302echo " libXi-devel \\"303echo " libXrandr-devel \\"304echo " libXrender-devel \\"305echo " libXt-devel \\"306echo " libXtst-devel \\"307echo " make \\"308echo " mesa-libGL-devel \\"309echo " mpfr-devel \\"310echo " ntp \\"311echo " numactl-devel \\"312echo " openssh-clients \\"313echo " openssh-server \\"314echo " openssl-devel \\" # required by git, etc.315echo " perl-CPAN \\"316echo " perl-DBI \\"317echo " perl-devel \\"318echo " perl-ExtUtils-MakeMaker \\" # required by git319echo " perl-GD \\"320echo " perl-libwww-perl \\"321echo " perl-Time-HiRes \\"322echo " systemtap-devel \\"323echo " texinfo \\" # required to update make324echo " unzip \\"325echo " vim \\"326echo " wget \\"327echo " xorg-x11-server-Xvfb \\"328echo " xz \\"329echo " zip \\"330echo " zlib-devel \\" # required by git, python331echo " && yum clean all"332echo ""333local autoconf_version=2.69334echo "# Install autoconf."335echo "RUN cd /tmp \\"336echo " && $wget_O autoconf.tar.gz https://ftp.gnu.org/gnu/autoconf/autoconf-$autoconf_version.tar.gz \\"337echo " && tar -xzf autoconf.tar.gz \\"338echo " && cd autoconf-$autoconf_version \\"339echo " && ./configure --build=\$(rpm --eval %{_host}) \\"340echo " && make \\"341echo " && make install \\"342echo " && cd .. \\"343echo " && rm -rf autoconf.tar.gz autoconf-$autoconf_version"344echo ""345echo "# Install gcc-7.5."346echo "RUN cd /usr/local \\"347echo " && $wget_O gcc-7.tar.xz 'https://ci.adoptopenjdk.net/userContent/gcc/gcc750+ccache.$arch.tar.xz' \\"348echo " && tar -xJf gcc-7.tar.xz --strip-components=1 \\"349echo " && ln -sf ../local/bin/gcc-7.5 /usr/bin/gcc \\"350echo " && ln -sf ../local/bin/g++-7.5 /usr/bin/g++ \\"351echo " && ln -sf gcc /usr/bin/cc \\"352echo " && ln -sf g++ /usr/bin/c++ \\"353echo " && rm -f gcc-7.tar.xz"354echo ""355local ant_version=1.10.5356echo "# Install ant."357echo "RUN cd /tmp \\"358echo " && $wget_O ant.zip https://archive.apache.org/dist/ant/binaries/apache-ant-$ant_version-bin.zip \\"359echo " && unzip -q ant.zip -d /opt \\"360echo " && ln -s apache-ant-$ant_version /opt/ant \\"361echo " && ln -s /opt/ant/bin/ant /usr/bin/ant \\"362echo " && $wget_O ant-contrib.tar.gz https://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.tar.gz \\"363echo " && tar -xzf ant-contrib.tar.gz \\"364echo " && mv ant-contrib/ant-contrib-1.0b3.jar /opt/ant/lib \\"365echo " && rm -rf ant-contrib ant.zip ant-contrib.tar.gz"366echo ""367local git_version=2.5.3368echo "# Install git."369echo "RUN cd /tmp \\"370echo " && $wget_O git.tar.gz https://www.kernel.org/pub/software/scm/git/git-$git_version.tar.gz \\"371echo " && tar -xzf git.tar.gz --no-same-owner \\"372echo " && cd git-$git_version \\"373echo " && make prefix=/usr/local all \\"374echo " && make prefix=/usr/local install \\"375echo " && cd .. \\"376echo " && rm -rf git.tar.gz git-$git_version"377# updating make requires automake 1.15378echo ""379local automake_version=1.15380echo "# Update automake."381echo "RUN cd /tmp \\"382echo " && $wget_O automake.tar.gz http://ftp.gnu.org/gnu/automake/automake-$automake_version.tar.gz \\"383echo " && tar -xzf automake.tar.gz \\"384echo " && cd automake-$automake_version \\"385echo " && ./configure \\"386echo " && make \\"387echo " && make install \\"388echo " && cd .. \\"389echo " && rm -rf automake.tar.gz automake-$automake_version"390if [ $arch = x86_64 ] ; then391echo ""392local gettext_version=0.20.1393echo "# Update gettext."394echo "RUN cd /tmp \\"395echo " && $wget_O gettext.tar.gz http://ftp.gnu.org/gnu/gettext/gettext-$gettext_version.tar.gz \\"396echo " && tar -xzf gettext.tar.gz \\"397echo " && cd gettext-$gettext_version \\"398echo " && ./autogen.sh --skip-gnulib \\"399echo " && ./configure --disable-nls \\"400echo " && make \\"401echo " && make install \\"402echo " && cd .. \\"403echo " && rm -rf gettext.tar.gz gettext-$gettext_version"404fi405echo ""406if [ $arch = ppc64le ] ; then407local make_version=4.2408else409local make_version=4.1410fi411echo "# Update make."412echo "RUN cd /tmp \\"413echo " && $wget_O make.tar.gz https://github.com/mirror/make/archive/$make_version.tar.gz \\"414echo " && tar -xzf make.tar.gz \\"415echo " && cd make-$make_version \\"416echo " && ACLOCAL_PATH=/usr/share/aclocal autoreconf -i \\"417echo " && ./configure \\"418echo " && make update \\"419echo " && make \\"420echo " && make install \\"421echo " && ln -s make /usr/local/bin/gmake \\"422echo " && cd .. \\"423echo " && rm -rf make.tar.gz make-$make_version"424if [ $arch = x86_64 ] ; then425echo ""426local nasm_version=2.13.03427echo "# Install nasm."428echo "RUN cd /tmp \\"429echo " && $wget_O nasm.tar.gz https://www.nasm.us/pub/nasm/releasebuilds/$nasm_version/nasm-$nasm_version.tar.gz \\"430echo " && tar -xzf nasm.tar.gz \\"431echo " && cd nasm-$nasm_version \\"432echo " && ./configure -prefix=/usr/local \\"433echo " && make install \\"434echo " && cd .. \\"435echo " && rm -rf nasm.tar.gz nasm-$nasm_version"436fi437}438439install_ubuntu_packages() {440echo "RUN apt-get update \\"441echo " && apt-get install -qq -y --no-install-recommends \\"442echo " software-properties-common \\"443if [ $version = 16.04 ] ; then444echo " python-software-properties \\"445fi446echo " && add-apt-repository ppa:ubuntu-toolchain-r/test \\"447echo " && apt-get update \\"448echo " && apt-get install -qq -y --no-install-recommends \\"449echo " ant \\"450echo " ant-contrib \\"451echo " autoconf \\"452echo " build-essential \\"453echo " ca-certificates \\"454echo " cmake \\"455echo " cpio \\"456echo " curl \\"457echo " file \\"458if [ $arch != s390x ] ; then459echo " g++-7 \\"460echo " gcc-7 \\"461fi462echo " gdb \\"463echo " git \\"464echo " libasound2-dev \\"465echo " libcups2-dev \\"466echo " libdwarf-dev \\"467echo " libelf-dev \\"468echo " libexpat1-dev \\" # required by the xml parser469echo " libffi-dev \\"470echo " libfontconfig \\"471echo " libfontconfig1-dev \\"472echo " libfreetype6-dev \\"473if [ $arch != s390x ] ; then474echo " libnuma-dev \\"475fi476if [ $arch = s390x ] ; then477echo " libmpc3 \\"478fi479echo " libssl-dev \\"480echo " libx11-dev \\"481echo " libxext-dev \\"482echo " libxrandr-dev \\"483echo " libxrender-dev \\"484echo " libxt-dev \\"485echo " libxtst-dev \\"486echo " make \\"487if [ $arch = x86_64 ] ; then488echo " nasm \\"489fi490echo " openssh-client \\"491echo " openssh-server \\"492echo " perl \\"493echo " pkg-config \\"494if [ $version = 16.04 ] ; then495echo " realpath \\"496fi497echo " ssh \\"498echo " systemtap-sdt-dev \\"499echo " unzip \\"500echo " wget \\"501echo " xvfb \\"502echo " zip \\"503echo " zlib1g-dev \\"504echo " && rm -rf /var/lib/apt/lists/*"505}506507install_packages() {508echo ""509echo "# Install required OS tools."510echo ""511if [ $dist = centos ] ; then512install_centos_packages513else514install_ubuntu_packages515fi516}517518install_compilers() {519if [ $arch = s390x ] ; then520echo ""521local gcc_version=7.5522echo "# Install gcc."523echo "RUN cd /usr/local \\"524echo " && $wget_O gcc.tar.xz 'https://ci.adoptopenjdk.net/userContent/gcc/gcc750+ccache.$arch.tar.xz' \\"525echo " && tar -xJf gcc.tar.xz --strip-components=1 \\"526echo " && rm -f gcc.tar.xz"527echo ""528echo "# Create various symbolic links."529echo "RUN ln -s lib/$arch-linux-gnu /usr/lib64 \\"530if [ $dist:$version = ubuntu:18.04 ] ; then531# On s390x perl needs version 4 of mpfr, but we only have version 6.532echo " && ln -s libmpfr.so.6 /usr/lib64/libmpfr.so.4 \\"533fi534# /usr/local/include/c++ is a directory that already exists so we create these symbolic links in two steps.535echo " && ( 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 ) \\"536echo " && ln -s \$(ls -d /usr/include/s390x-linux-gnu/* | grep -v '/c++\$') /usr/local/include \\"537echo " && ln -sf ../local/bin/g++-$gcc_version /usr/bin/g++-7 \\"538echo " && ln -sf ../local/bin/gcc-$gcc_version /usr/bin/gcc-7"539fi540if [ $dist != centos ] ; then541echo ""542echo "ENV CC=gcc-7 CXX=g++-7"543fi544}545546install_cmake() {547if [ $dist == centos ] ; then548echo ""549local cmake_version=3.11550local cmake_name=cmake-$cmake_version.4551echo "# Install cmake."552echo "RUN cd /tmp \\"553echo " && $wget_O cmake.tar.gz https://cmake.org/files/v$cmake_version/$cmake_name.tar.gz \\"554echo " && tar -xzf cmake.tar.gz \\"555echo " && cd $cmake_name \\"556echo " && export LDFLAGS='-static-libstdc++' \\"557echo " && ./configure \\"558echo " && make \\"559echo " && make install \\"560echo " && cd .. \\"561echo " && rm -rf cmake.tar.gz $cmake_name"562fi563}564565prepare_user() {566# Ensure authorized_keys exists.567test -f authorized_keys || touch authorized_keys568# Ensure github.com is a known host.569( test -f known_hosts && grep -q '^github.com ' known_hosts ) \570|| ssh-keyscan github.com >> known_hosts571}572573create_user() {574echo ""575echo "# Add user home and copy authorized_keys and known_hosts."576echo "RUN useradd -ms /bin/bash --uid $userid $user \\"577echo " && mkdir /home/$user/.ssh \\"578echo " && chmod 700 /home/$user/.ssh"579echo "COPY authorized_keys known_hosts /home/$user/.ssh/"580echo "RUN chmod -R go= /home/$user/.ssh \\"581echo " && echo "ulimit -u 32000 -n 2048" >> /home/$user/.bashrc"582}583584adjust_user_directory_perms() {585echo "RUN chown -R $user:$user /home/$user"586}587588install_freemarker() {589echo ""590local freemarker_version=2.3.8591echo "# Download and extract freemarker.jar to /home/$user/freemarker.jar."592echo "RUN cd /home/$user \\"593echo " && $wget_O freemarker.tar.gz https://sourceforge.net/projects/freemarker/files/freemarker/$freemarker_version/freemarker-$freemarker_version.tar.gz/download \\"594echo " && tar -xzf freemarker.tar.gz freemarker-$freemarker_version/lib/freemarker.jar --strip-components=2 \\"595echo " && rm -f freemarker.tar.gz"596}597598bootjdk_dirs() {599local version600for version in $@ ; do601echo /home/$user/bootjdks/jdk$version602done603}604605bootjdk_url() {606local jdk_arch=${arch/x86_64/x64}607local jdk_version=$1608if [ $jdk_version -lt 18 ] ; then609echo https://api.adoptopenjdk.net/v3/binary/latest/$jdk_version/ga/linux/$jdk_arch/jdk/openj9/normal/adoptopenjdk610else611echo https://api.adoptium.net/v3/binary/latest/$jdk_version/ga/linux/$jdk_arch/jdk/hotspot/normal/eclipse612fi613}614615install_bootjdks() {616local bootjdk_versions=617local version618local -A wanted619for version in $jdk_versions ; do620if [ $version = next ] ; then621wanted[17]=yes622elif [ $version = 18 ] ; then623wanted[17]=yes624else625wanted[$version]=yes626fi627done628for version in ${all_versions/next/} ; do629if [ "${wanted[$version]}" = yes ] ; then630bootjdk_versions="$bootjdk_versions $version"631fi632done633echo ""634echo "# Download and install boot JDKs."635echo "RUN cd /tmp \\"636for version in $bootjdk_versions ; do637echo " && $wget_O jdk$version.tar.gz $(bootjdk_url $version) \\"638done639echo " && mkdir -p" $(bootjdk_dirs $bootjdk_versions) "\\"640for version in $bootjdk_versions ; do641echo " && tar -xzf jdk$version.tar.gz --directory=$(bootjdk_dirs $version)/ --strip-components=1 \\"642done643echo " && rm -f jdk*.tar.gz"644}645646install_cuda() {647echo ""648echo "# Copy header files necessary to build a VM with CUDA support."649echo "RUN mkdir -p /usr/local/cuda-${cuda}/nvvm"650echo "COPY --from=cuda-dev /usr/local/cuda-${cuda}/include /usr/local/cuda-${cuda}/include"651echo "COPY --from=cuda-dev /usr/local/cuda-${cuda}/nvvm/include /usr/local/cuda-${cuda}/nvvm/include"652echo "ENV CUDA_HOME=/usr/local/cuda-${cuda}"653}654655install_python() {656local python_version=3.7.3657echo ""658echo "# Install python."659echo "RUN cd /tmp \\"660echo " && $wget_O python.tar.xz https://www.python.org/ftp/python/$python_version/Python-$python_version.tar.xz \\"661echo " && tar -xJf python.tar.xz \\"662echo " && cd Python-$python_version \\"663echo " && ./configure --prefix=/usr/local \\"664echo " && make \\"665echo " && make install \\"666echo " && cd .. \\"667echo " && rm -rf python.tar.xz Python-$python_version"668}669670adjust_ldconfig() {671echo ""672echo "# Run ldconfig to discover newly installed shared libraries."673echo "RUN for dir in lib lib64 ; do echo /usr/local/\$dir ; done > /etc/ld.so.conf.d/usr-local.conf \\"674echo " && ldconfig"675}676677# called as: add_git_remote remote url678add_git_remote() {679echo " && git remote add ${1} ${2} \\"680# Like-named (and conflicting) tags exist in multiple repositories: don't fetch any tags.681echo " && git config remote.${1}.tagopt --no-tags \\"682}683684create_git_cache() {685local git_cache_dir=/home/$user/openjdk_cache686local version687local -A wanted688for version in $jdk_versions ; do689wanted[$version]=yes690done691# The jdk17 remote is fetched first because that repository was subjected to692# 'git gc --aggressive --prune=all' before it was first published making it much693# smaller than some other jdk repositories. There is a large degree of overlap694# among the jdk repositories so a relatively small number of commits must be695# fetched from the others.696echo ""697echo "# Setup a reference repository cache for faster clones in containers."698echo "RUN mkdir $git_cache_dir \\"699echo " && cd $git_cache_dir \\"700echo " && git init --bare \\"701for version in $all_versions ; do702if [ "${wanted[$version]}" = yes ] ; then703add_git_remote jdk$version https://github.com/ibmruntimes/openj9-openjdk-jdk${version/next/}.git704fi705done706add_git_remote omr https://github.com/eclipse-openj9/openj9-omr.git707add_git_remote openj9 https://github.com/eclipse-openj9/openj9.git708echo " && echo Fetching repository cache... \\"709if [ "${wanted[17]}" = yes ] ; then710echo " && git fetch jdk17 \\"711fi712echo " && git fetch --all \\"713echo " && echo Shrinking repository cache... \\"714echo " && git gc --aggressive --prune=all"715}716717configure_ssh() {718echo ""719echo "# Configure sshd."720echo "RUN mkdir /var/run/sshd \\"721echo " && sed -i -e 's|#PermitRootLogin|PermitRootLogin|' \\"722echo " -e 's|#RSAAuthentication.*|RSAAuthentication yes|' \\"723echo " -e 's|#PubkeyAuthentication.*|PubkeyAuthentication yes|' /etc/ssh/sshd_config"724echo ""725echo "# SSH login fix so user is not kicked off after login."726echo "RUN sed -i -e 's|session\s*required\s*pam_loginuid.so|session optional pam_loginuid.so|' /etc/pam.d/sshd"727echo ""728echo "# Expose SSH port."729echo "EXPOSE 22"730}731732print_dockerfile() {733print_license734preamble735install_packages736create_user737if [ $cuda != no ] ; then738install_cuda739fi740if [ $freemarker = yes ] ; then741install_freemarker742fi743install_compilers744745install_cmake746install_python747748adjust_ldconfig749configure_ssh750751install_bootjdks752if [ $gen_git_cache = yes ] ; then753create_git_cache754fi755adjust_user_directory_perms756}757758main() {759if [ $action = build ] ; then760prepare_user761print_dockerfile | docker $(build_cmd -)762else763print_dockerfile764fi765}766767command_line="$*"768parse_options "$@"769validate_options770main771772773