|
| 1 | +source /opt/utils/script-utils.sh |
| 2 | + |
| 3 | + |
| 4 | +setup_conda() { |
| 5 | + wget -qO- "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-$(arch).sh" -O /tmp/conda.sh \ |
| 6 | + && bash /tmp/conda.sh -f -b -p /opt/conda \ |
| 7 | + && conda config --system --prepend channels conda-forge \ |
| 8 | + && conda config --system --set auto_update_conda false \ |
| 9 | + && conda config --system --set show_channel_urls true \ |
| 10 | + && conda config --set channel_priority strict \ |
| 11 | + && conda update --all --quiet --yes |
| 12 | + |
| 13 | + # These conda pkgs shouldn't be removed (otherwise will cause RemoveError) since they are directly reqiuired by conda: pip setuptools pycosat pyopenssl requests ruamel_yaml |
| 14 | + CONDA_PY_PKGS=`conda list | grep "py3" | cut -d " " -f 1 | sed "/#/d;/conda/d;/pip/d;/setuptools/d;/pycosat/d;/pyopenssl/d;/requests/d;/ruamel_yaml/d;"` \ |
| 15 | + && conda remove --force -yq $CONDA_PY_PKGS \ |
| 16 | + && pip install -UIq pip setuptools $CONDA_PY_PKGS |
| 17 | + |
| 18 | + # Print Conda and Python packages information in the docker build log |
| 19 | + echo "@ Version of Conda & Python:" && conda info && conda list | grep -v "<pip>" |
| 20 | +} |
| 21 | + |
| 22 | + |
| 23 | +setup_java_base() { |
| 24 | + # VERSION_OPENJDK=16 && VERSION_OPENJDK_EA=8 \ |
| 25 | + # && URL_OPENJDK="https://download.java.net/java/early_access/jdk${VERSION_OPENJDK}/${VERSION_OPENJDK_EA}/GPL/openjdk-${VERSION_OPENJDK}-ea+${VERSION_OPENJDK_EA}_linux-x64_bin.tar.gz" \ |
| 26 | + URL_OPENJDK="https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_linux-x64_bin.tar.gz" \ |
| 27 | + && install_tar_gz ${URL_OPENJDK} && mv /opt/jdk-* /opt/jdk \ |
| 28 | + && ln -s /opt/jdk/bin/* /usr/bin/ \ |
| 29 | + && echo "@ Version of Java (java/javac):" && java -version && javac -version |
| 30 | +} |
| 31 | + |
| 32 | +setup_java_maven() { |
| 33 | + MAVEN_VERSION="3.6.3" \ |
| 34 | + && install_zip "http://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.zip" \ |
| 35 | + && mv /opt/apache-maven-${MAVEN_VERSION} /opt/maven \ |
| 36 | + && ln -s /opt/maven/bin/mvn* /usr/bin/ \ |
| 37 | + && echo "@ Version of Maven:" && mvn --version |
| 38 | +} |
| 39 | + |
| 40 | + |
| 41 | +setup_node() { |
| 42 | + # NODEJS_VERSION_MAJOR="v14" && grep "v${NODEJS_VERSION_MAJOR}." |
| 43 | + ARCH="x64" \ |
| 44 | + && NODEJS_VERSION=$(curl -sL https://github.com/nodejs/node/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[.\d]+') \ |
| 45 | + && NODEJS_VERSION_MAJOR=$(echo ${NODEJS_VERSION} | cut -d '.' -f1 ) \ |
| 46 | + && install_tar_gz "https://nodejs.org/download/release/latest-v${NODEJS_VERSION_MAJOR}.x/node-v${NODEJS_VERSION}-linux-${ARCH}.tar.gz" \ |
| 47 | + && mv /opt/node* /opt/node \ |
| 48 | + && echo "PATH=/opt/node/bin:$PATH" >> /etc/bash.bashrc \ |
| 49 | + && export PATH=/opt/node/bin:$PATH \ |
| 50 | + && npm install -g npm yarn \ |
| 51 | + && ln -s /opt/node/bin/* /usr/bin/ \ |
| 52 | + && echo "@ Version of Node, npm, and yarn:" `node -v` `npm -v` `yarn -v` |
| 53 | +} |
| 54 | + |
| 55 | + |
| 56 | +setup_R_base() { |
| 57 | + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \ |
| 58 | + && echo "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/" > /etc/apt/sources.list.d/cran.list \ |
| 59 | + && install_apt /opt/utils/install_list_R_base.apt \ |
| 60 | + && echo "options(repos=structure(c(CRAN=\"https://cloud.r-project.org\")))" >> /etc/R/Rprofile.site \ |
| 61 | + && R -e "install.packages(c('devtools'),clean=T,quiet=T);" \ |
| 62 | + && ( type java && type R && R CMD javareconf || true ) \ |
| 63 | + && echo "@ Version of R:" && R --version |
| 64 | +} |
| 65 | + |
| 66 | + |
| 67 | +setup_R_rstudio() { |
| 68 | + RSTUDIO_VERSION=`curl -sL https://dailies.rstudio.com/rstudioserver/oss/ubuntu/x86_64/ | grep -Po "(?<=rstudio-server-)[0-9]\.[0-9]\.[0-9]+" | sort | tail -n 1` \ |
| 69 | + && wget -qO- "https://s3.amazonaws.com/rstudio-ide-build/server/bionic/amd64/rstudio-server-${RSTUDIO_VERSION}-amd64.deb" -O /tmp/rstudio.deb \ |
| 70 | + && dpkg -x /tmp/rstudio.deb /tmp && mv /tmp/usr/lib/rstudio-server/ /opt/ \ |
| 71 | + && ln -s /opt/rstudio-server /usr/lib/ \ |
| 72 | + && ln -s /opt/rstudio-server/bin/rs* /usr/bin/ |
| 73 | + |
| 74 | + # Allow RStudio server run as root user |
| 75 | + # Configuration to make RStudio server disable authentication and do not run as daemon |
| 76 | + mkdir -p /etc/rstudio \ |
| 77 | + && echo "server-daemonize=0" >> /etc/rstudio/rserver.conf \ |
| 78 | + && echo "server-user=root" >> /etc/rstudio/rserver.conf \ |
| 79 | + && echo "auth-none=1" >> /etc/rstudio/rserver.conf \ |
| 80 | + && echo "auth-minimum-user-id=0" >> /etc/rstudio/rserver.conf \ |
| 81 | + && echo "auth-validate-users=0" >> /etc/rstudio/rserver.conf \ |
| 82 | + && printf "#!/bin/bash\nexport USER=root\nrserver --www-port=8888" > /usr/local/bin/start-rstudio.sh \ |
| 83 | + && chmod u+x /usr/local/bin/start-rstudio.sh |
| 84 | + |
| 85 | + # Remove RStudio's pandoc and pandoc-proc to reduce size if they are already installed in the jpy-latex step. |
| 86 | + ( which pandoc && rm /opt/rstudio-server/bin/pandoc/pandoc || true ) \ |
| 87 | + && ( which pandoc-citeproc && rm /opt/rstudio-server/bin/pandoc/pandoc-citeproc || true ) \ |
| 88 | + && echo "@ Version of rstudio-server:" && rstudio-server version |
| 89 | +} |
| 90 | + |
| 91 | + |
| 92 | +setup_R_rshiny() { |
| 93 | + RSHINY_VERSION=$(curl -sL https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-14.04/x86_64/VERSION) \ |
| 94 | + && wget -qO- "https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-${RSHINY_VERSION}-amd64.deb" -O /tmp/rshiny.deb \ |
| 95 | + && dpkg -i /tmp/rshiny.deb \ |
| 96 | + && sed -i "s/run_as shiny;/run_as root;/g" /etc/shiny-server/shiny-server.conf \ |
| 97 | + && sed -i "s/3838/8888/g" /etc/shiny-server/shiny-server.conf \ |
| 98 | + && printf "#!/bin/bash\nexport USER=root\nshiny-server" > /usr/local/bin/start-shiny-server.sh \ |
| 99 | + && chmod u+x /usr/local/bin/start-shiny-server.sh |
| 100 | + |
| 101 | + # Remove shiny's pandoc and pandoc-proc to reduce size if they are already installed in the jpy-latex step. |
| 102 | + ( which pandoc && rm /opt/shiny-server/ext/pandoc/pandoc || true ) \ |
| 103 | + && ( which pandoc-citeproc && rm /opt/shiny-server/ext/pandoc/pandoc-citeproc || true ) \ |
| 104 | + && rm /opt/shiny-server/ext/node/bin/shiny-server \ |
| 105 | + && ln -s /opt/shiny-server/ext/node/bin/node /opt/shiny-server/ext/node/bin/shiny-server |
| 106 | + |
| 107 | + # hack shiny-server to allow run in root user: https://github.com/rstudio/shiny-server/pull/391 |
| 108 | + sed -i "s/throw new Error/logger.warn/g" /opt/shiny-server/lib/worker/app-worker.js \ |
| 109 | + && echo "@ Version of shiny-server:" && shiny-server --version |
| 110 | +} |
| 111 | + |
| 112 | + |
| 113 | +setup_R_datascience() { |
| 114 | + # firstly install rgl stub to work around, which has too many deps, but required by some libs |
| 115 | + R -e "devtools::install_git(\"git://github.com/sorhawell/rgl.git\",quiet=T,clean=T)" |
| 116 | + |
| 117 | + install_apt /opt/utils/install_list_R_datascience.apt \ |
| 118 | + && install_R /opt/utils/install_list_R_datascience.R |
| 119 | +} |
| 120 | + |
| 121 | + |
| 122 | +setup_GO() { |
| 123 | + GO_VERSION=$(curl -sL https://github.com/golang/go/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+') \ |
| 124 | + && GO_URL="https://dl.google.com/go/go$GO_VERSION.linux-$(dpkg --print-architecture).tar.gz" \ |
| 125 | + && install_tar_gz $GO_URL go \ |
| 126 | + && ln -s /opt/go/bin/go /usr/bin/ \ |
| 127 | + && echo "@ Version of golang and packages:" && go version |
| 128 | +} |
| 129 | + |
| 130 | + |
| 131 | +setup_julia() { |
| 132 | + JULIA_URL="https://julialangnightlies-s3.julialang.org/bin/linux/x64/julia-latest-linux64.tar.gz" \ |
| 133 | + && install_tar_gz $JULIA_URL \ |
| 134 | + && mv /opt/julia-* /opt/julia \ |
| 135 | + && ln -fs /opt/julia/bin/julia /usr/bin/julia \ |
| 136 | + && mkdir -p /opt/julia/pkg \ |
| 137 | + && echo "import Libdl; push!(Libdl.DL_LOAD_PATH, \"/opt/conda/lib\")" >> /opt/julia/etc/julia/startup.jl \ |
| 138 | + && echo "DEPOT_PATH[1]=\"/opt/julia/pkg\"" >> /opt/julia/etc/julia/startup.jl \ |
| 139 | + && echo "@ Version of Julia" && julia --version |
| 140 | +} |
| 141 | + |
| 142 | + |
| 143 | +setup_octave() { |
| 144 | + # TEMPFIX: javac version |
| 145 | + # && OCTAVE_VERSION="5.2.0" \ |
| 146 | + # && install_tar_xz "https://ftp.gnu.org/gnu/octave/octave-${OCTAVE_VERSION}.tar.xz" \ |
| 147 | + # && cd /opt/octave-* \ |
| 148 | + # && sed -i "s/1.6/11/g" ./Makefile.in \ |
| 149 | + # && sed -i "s/1.6/11/g" ./scripts/java/module.mk \ |
| 150 | + # && ./configure --prefix=/opt/octave --disable-docs --without-opengl \ |
| 151 | + # && make -j8 && make install -j8 \ |
| 152 | + # && cd /opt/utils && rm -rf /opt/octave-* |
| 153 | + |
| 154 | + install_apt /opt/utils/install_list_octave.apt \ |
| 155 | + && install_octave /opt/utils/install_list_octave.pkg \ |
| 156 | + && echo "@ Version of Octave and installed packages:" \ |
| 157 | + && /opt/octave/bin/octave --version |
| 158 | +} |
0 commit comments