|
| 1 | +# TODO : avoid duplication in trying to use the same docker file for debian and ubuntu |
| 2 | +# 2 distinct files exist now because the releases for debian 12 are used for the remote drivers |
| 3 | +# Arguments |
| 4 | +ARG KHIOPSDEV_OS |
| 5 | +ARG SERVER_REVISION |
| 6 | +FROM ghcr.io/khiopsml/khiops/khiopsdev-${KHIOPSDEV_OS}:latest AS khiopsdev |
| 7 | +LABEL maintainer="khiops.team@orange.com" |
| 8 | +LABEL description="Container for the development of khiops-python" |
| 9 | + |
| 10 | +# Install dev tools and miniforge (for the unit tests); build and install Khiops |
| 11 | +ARG KHIOPS_REVISION |
| 12 | +RUN true \ |
| 13 | + # Install git (for khiops-python version calculation) and pip \ |
| 14 | + && apt-get -y update \ |
| 15 | + && apt-get -y --no-install-recommends install git python3-pip \ |
| 16 | + # On Debian/Ubuntu systems, python3-venv must be installed to provide ensurepip. |
| 17 | + # It is still possible to create venvs using the --without-pip flag but any subsequent |
| 18 | + # module installation with pip would be impossible |
| 19 | + python3-venv \ |
| 20 | + zip pandoc wget ruby-dev \ |
| 21 | + # Get Linux distribution codename \ |
| 22 | + && if [ -f /etc/os-release ]; then . /etc/os-release; fi \ |
| 23 | + # Obtain the Khiops native package \ |
| 24 | + && KHIOPS_PKG_FILE=$KHIOPS_REVISION/khiops-core-openmpi_$KHIOPS_REVISION-1-$VERSION_CODENAME.amd64.deb \ |
| 25 | + && wget -O KHIOPS_CORE.deb "https://github.com/KhiopsML/khiops/releases/download/${KHIOPS_PKG_FILE}" \ |
| 26 | + # Install the Khiops native package : make it always succeed. \ |
| 27 | + # If dpkg fails it is due to missing dependencies which will be installed by apt in the next line \ |
| 28 | + && (dpkg -i --force-all KHIOPS_CORE.deb || true) \ |
| 29 | + && apt-get -f -y install \ |
| 30 | + && rm -f KHIOPS_CORE.deb \ |
| 31 | + # Set python to python3 \ |
| 32 | + && update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \ |
| 33 | + # Install miniforge to have multiple Python versions via Conda \ |
| 34 | + && mkdir -p /root/miniforge3 && cd /root/miniforge3 \ |
| 35 | + && wget https://github.com/conda-forge/miniforge/releases/download/24.1.2-0/Miniforge3-24.1.2-0-Linux-x86_64.sh -O ./Miniforge3_24.1.2-0-Linux-x86_64.sh \ |
| 36 | + && echo "dbadb808edf4da00af35d888d3eeebbfdce71972b60bf4b16dbacaee2ab57f28 Miniforge3_24.1.2-0-Linux-x86_64.sh" | sha256sum --check \ |
| 37 | + && bash ./Miniforge3_24.1.2-0-Linux-x86_64.sh -b -u -p /root/miniforge3 \ |
| 38 | + && rm -rf /root/miniforge3/Miniforge3_24.1.2-0-Linux-x86_64.sh \ |
| 39 | + # Make sure that MPI is openmpi \ |
| 40 | + && update-alternatives --set mpirun /usr/bin/mpirun.openmpi \ |
| 41 | + # Clean build files \ |
| 42 | + && rm -fr /var/lib/apt/lists/* \ |
| 43 | + && apt-get clean \ |
| 44 | + && rm -rf ./khiops \ |
| 45 | + && true |
| 46 | + |
| 47 | +# set up all the supported Python environments under conda (for the unit tests) |
| 48 | +# relying on a variable containing all the versions |
| 49 | +ARG PYTHON_VERSIONS |
| 50 | +ARG KHIOPS_GCS_DRIVER_REVISION |
| 51 | +ARG KHIOPS_S3_DRIVER_REVISION |
| 52 | + |
| 53 | +# Install Conda packages |
| 54 | +# Use `rc` label for alpha or RC khiops-core pre-releases |
| 55 | +RUN true \ |
| 56 | + && export CONDA="/root/miniforge3/bin/conda" \ |
| 57 | + && /bin/bash -c 'if [[ $(echo ${KHIOPS_REVISION} | grep -E ".*-(a|rc)\.[0-9]+") ]]; then \ |
| 58 | + export RC_LABEL="conda-forge/label/rc::"; \ |
| 59 | + else \ |
| 60 | + export RC_LABEL=""; \ |
| 61 | + fi; \ |
| 62 | + for version in ${PYTHON_VERSIONS}; \ |
| 63 | + do \ |
| 64 | + CONDA_ENVS="py${version} py${version}_conda"; \ |
| 65 | + for CONDA_ENV in $CONDA_ENVS; \ |
| 66 | + do \ |
| 67 | + $CONDA create -y -n $CONDA_ENV python=${version}; \ |
| 68 | + done; \ |
| 69 | + # khiops core \ |
| 70 | + $CONDA install -y -n py${version}_conda ${RC_LABEL}khiops-core=$(echo ${KHIOPS_REVISION} | tr -d "-") ; \ |
| 71 | + # remote files drivers installed in the conda environment \ |
| 72 | + $CONDA install -y -n py${version}_conda -c conda-forge \ |
| 73 | + khiops-driver-s3=${KHIOPS_S3_DRIVER_REVISION} \ |
| 74 | + khiops-driver-gcs=${KHIOPS_GCS_DRIVER_REVISION}; \ |
| 75 | + done' \ |
| 76 | + && true |
| 77 | + |
| 78 | +RUN mkdir -p /scripts |
| 79 | +COPY ./run_service.sh ./run_fake_remote_file_servers.sh /scripts/ |
| 80 | +RUN chmod +x /scripts/run_service.sh /scripts/run_fake_remote_file_servers.sh && \ |
| 81 | + useradd -rm -d /home/ubuntu -s /bin/bash -g root -u 1000 ubuntu |
| 82 | + |
| 83 | +# remote files drivers installed system-wide |
| 84 | +RUN true \ |
| 85 | + # Get Linux distribution codename \ |
| 86 | + && if [ -f /etc/os-release ]; then . /etc/os-release; fi \ |
| 87 | + # Force the installation of the debian 12 versions (bookworm) |
| 88 | + && wget -O khiops-gcs.deb https://github.com/KhiopsML/khiopsdriver-gcs/releases/download/${KHIOPS_GCS_DRIVER_REVISION}/khiops-driver-gcs_${KHIOPS_GCS_DRIVER_REVISION}-1-bookworm.amd64.deb \ |
| 89 | + && wget -O khiops-s3.deb https://github.com/KhiopsML/khiopsdriver-s3/releases/download/${KHIOPS_S3_DRIVER_REVISION}/khiops-driver-s3_${KHIOPS_S3_DRIVER_REVISION}-1-bookworm.amd64.deb \ |
| 90 | + && (dpkg -i --force-all khiops-gcs.deb khiops-s3.deb || true) \ |
| 91 | + && apt-get -f -y install \ |
| 92 | + && rm -f khiops-gcs.deb khiops-s3.deb \ |
| 93 | + && true |
| 94 | + |
| 95 | +FROM ghcr.io/khiopsml/khiops-server:${SERVER_REVISION} AS server |
| 96 | + |
| 97 | +FROM khiopsdev AS base |
| 98 | +COPY --from=server /service /usr/bin/service |
| 99 | + |
| 100 | +# S3 fake file server (only in the ubuntu container) |
| 101 | +# Do not use the latest fakes3 version because starting from 1.3 a licence is required |
| 102 | +# if fakes3 is no longer compatible think about switching to an alternative and fully compatible server |
| 103 | +# (https://github.com/jamhall/s3rver:v3.7.1 is not yet for example) |
| 104 | +RUN gem install fakes3:1.2.1 sorted_set |
| 105 | +# Avoid resolving a fake s3-bucket.localhost hostname |
| 106 | +# Alternate builders (buildx via moby buildkit) mount /etc/hosts read-only, the following command will fail |
| 107 | +# echo "127.0.0.1 s3-bucket.localhost" >> /etc/hosts |
| 108 | +# You will have to add the `add-hosts` input instead (https://github.com/docker/build-push-action/#inputs) |
| 109 | + |
| 110 | +# Port on which fakes3 is listening |
| 111 | +EXPOSE 4569 |
| 112 | + |
0 commit comments