|
| 1 | +# Copyright (c) 2023 Oracle and/or its affiliates. |
| 2 | +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ |
| 3 | + |
| 4 | +# Used OL8 because miniconda required a higher version of glibc that was unavoidable |
| 5 | +FROM ghcr.io/oracle/oraclelinux:8-slim |
| 6 | + |
| 7 | +# Configure environment |
| 8 | +ENV DATASCIENCE_USER datascience |
| 9 | +ENV DATASCIENCE_UID 1000 |
| 10 | +ENV HOME /home/$DATASCIENCE_USER |
| 11 | +ENV DATASCIENCE_INSTALL_DIR /etc/datascience |
| 12 | + |
| 13 | +ARG release=19 |
| 14 | +ARG update=10 |
| 15 | + |
| 16 | +RUN microdnf install yum yum-utils && yum clean all && rm -rf /var/cache/yum |
| 17 | + |
| 18 | +RUN \ |
| 19 | + yum -y -q install \ |
| 20 | + oracle-release-el8 && \ |
| 21 | + yum-config-manager --enable ol8_addons --enable ol8_oracle_instantclient > /dev/null && \ |
| 22 | + yum groupinstall -y -q 'Development Tools' && \ |
| 23 | + yum update -y && \ |
| 24 | + yum install -y --setopt=skip_missing_names_on_install=False \ |
| 25 | + bzip2 \ |
| 26 | + curl \ |
| 27 | + git \ |
| 28 | + gcc-gfortran \ |
| 29 | + libcurl-devel \ |
| 30 | + libxml2-devel \ |
| 31 | + oracle-instantclient${release}.${update}-basic \ |
| 32 | + oracle-instantclient${release}.${update}-sqlplus \ |
| 33 | + openssl \ |
| 34 | + openssl-devel \ |
| 35 | + patch \ |
| 36 | + sudo \ |
| 37 | + unzip \ |
| 38 | + zip \ |
| 39 | + gcc-c++ \ |
| 40 | + wget \ |
| 41 | + gcc \ |
| 42 | + && yum clean all \ |
| 43 | + && rm -rf /var/cache/yum/* |
| 44 | + |
| 45 | +# setup user |
| 46 | +RUN \ |
| 47 | + mkdir -p /home/$DATASCIENCE_USER && \ |
| 48 | + useradd -m -s /bin/bash -N -u $DATASCIENCE_UID $DATASCIENCE_USER && \ |
| 49 | + chown -R $DATASCIENCE_USER /home/$DATASCIENCE_USER && \ |
| 50 | + chown -R $DATASCIENCE_USER:users /usr/local/ && \ |
| 51 | + touch /etc/sudoers.d/$DATASCIENCE_USER && echo "$DATASCIENCE_USER ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/$DATASCIENCE_USER && \ |
| 52 | + mkdir -p $DATASCIENCE_INSTALL_DIR && chown $DATASCIENCE_USER $DATASCIENCE_INSTALL_DIR |
| 53 | + |
| 54 | +RUN mkdir -p /etc/datascience/build |
| 55 | +RUN mkdir -p $DATASCIENCE_INSTALL_DIR/{pre-build-ds,post-build-ds,pre-run-ds,pre-run-user} |
| 56 | + |
| 57 | +#conda |
| 58 | +# set a default language for localization. necessary for oci cli |
| 59 | +ARG LANG=en_US.utf8 |
| 60 | +ENV LANG=$LANG |
| 61 | +ENV SHELL=/bin/bash |
| 62 | + |
| 63 | +# set /opt folder permissions for $DATASCIENCE_USER. Conda is going to live in this folder. |
| 64 | +RUN chown -R $DATASCIENCE_USER /opt |
| 65 | + |
| 66 | +USER $DATASCIENCE_USER |
| 67 | +WORKDIR /home/datascience |
| 68 | +# Note in order to run sudo commands as a non root user, you must specify --credential yes if using qemu static to build the image |
| 69 | +ARG MINICONDA_VER=23.5.2-0 |
| 70 | +RUN wget -nv https://repo.anaconda.com/miniconda/Miniconda3-py38_${MINICONDA_VER}-Linux-aarch64.sh -O /home/datascience/Miniconda3.sh \ |
| 71 | + && /bin/bash /home/datascience/Miniconda3.sh -f -b -p /opt/conda \ |
| 72 | + && rm /home/datascience/Miniconda3.sh \ |
| 73 | + && /opt/conda/bin/conda clean -yaf |
| 74 | + |
| 75 | +WORKDIR / |
| 76 | +USER root |
| 77 | +RUN printf "#!/bin/bash\nsource /opt/conda/bin/activate\n" > /etc/profile.d/enableconda.sh \ |
| 78 | + && chmod +x /etc/profile.d/enableconda.sh |
| 79 | + |
| 80 | +USER $DATASCIENCE_USER |
| 81 | +ENV PATH="/opt/conda/bin:${PATH}" |
| 82 | +WORKDIR /home/datascience |
| 83 | + |
| 84 | +COPY docker/base-env.yaml /opt/base-env.yaml |
| 85 | +RUN conda env update -q -n root -f /opt/base-env.yaml && conda clean -yaf && rm -rf /home/datascience/.cache/pip |
| 86 | + |
| 87 | +USER $DATASCIENCE_USER |
| 88 | + |
| 89 | +####### WRAP UP ############################### |
| 90 | +RUN python -c 'import sys; assert(sys.version_info[:2]) == (3, 8), "Python 3.8 is not detected"' |
| 91 | +WORKDIR / |
| 92 | + |
| 93 | +RUN conda list |
| 94 | + |
| 95 | +############# Setup Conda environment tools ########################### |
| 96 | +USER root |
| 97 | +ARG RAND=1 |
| 98 | + |
| 99 | +ARG RUN_WORKING_DIR="/home/datascience" |
| 100 | +WORKDIR $RUN_WORKING_DIR |
| 101 | + |
| 102 | +# clean tmp folder |
| 103 | +RUN rm -rf /tmp/* |
| 104 | + |
| 105 | +RUN mkdir -p /etc/datascience/operators |
| 106 | + |
| 107 | +USER datascience |
0 commit comments