From 795d41194f3de8f1778f14191cb17342e6ba9747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Dutheillet-Lamonth=C3=A9zie?= Date: Mon, 2 Sep 2024 17:04:14 +0200 Subject: [PATCH] #97: refactor dockerfile for ubuntu base image build --- .github/workflows/pushbasedockerimage.yml | 5 +- .github/workflows/pushbasedockerimage_tmp.yml | 2 +- ci/docker/make-base-ubuntu-24.04.dockerfile | 103 ------------------ ...dockerfile => make-base-ubuntu.dockerfile} | 8 +- 4 files changed, 8 insertions(+), 110 deletions(-) delete mode 100644 ci/docker/make-base-ubuntu-24.04.dockerfile rename ci/docker/{make-base-ubuntu-22.04.dockerfile => make-base-ubuntu.dockerfile} (88%) diff --git a/.github/workflows/pushbasedockerimage.yml b/.github/workflows/pushbasedockerimage.yml index e8f01e483..ff4202508 100644 --- a/.github/workflows/pushbasedockerimage.yml +++ b/.github/workflows/pushbasedockerimage.yml @@ -10,7 +10,7 @@ on: - ubuntu_22.04-gcc_11-vtk_9.2.2-py_3.8 - ubuntu_22.04-clang_11-vtk_9.2.2-py_3.8 - ubuntu_22.04-gcc_12-vtk_9.3.0-py_3.8 - - ubuntu_24.04-gcc_12-vtk_9.3.1-py_3.8 + - ubuntu_24.04-gcc_13-vtk_9.3.1-py_3.8 default: ubuntu_22.04-gcc_12-vtk_9.3.0-py_3.8 jobs: @@ -28,7 +28,6 @@ jobs: run: | IFS='_-' read -r -a CONFIG <<< "${{ inputs.image }}" echo "BASE_IMAGE=${CONFIG[0]}:${CONFIG[1]}" >> $GITHUB_ENV - echo "BASE_DOCKERFILE=make-base-${CONFIG[0]}-${CONFIG[1]}.dockerfile" >> $GITHUB_ENV echo "CC=${CONFIG[2]}-${CONFIG[3]}" >> $GITHUB_ENV if [[ "${CONFIG[2]}" == "gcc" ]]; then echo "CXX=g++-${CONFIG[3]}" >> $GITHUB_ENV @@ -70,6 +69,6 @@ jobs: GCOV=${{ env.GCOV }} VTK_VERSION=${{ env.VTK_VERSION }} PYTHON_VERSION=${{ env.PYTHON_VERSION }} - file: ci/docker/${{ env.BASE_DOCKERFILE }} + file: ci/docker/make-base-ubuntu.dockerfile push: true tags: "${{ env.DOCKER_REPOSITORY }}:${{ env.DOCKER_TAG }}" diff --git a/.github/workflows/pushbasedockerimage_tmp.yml b/.github/workflows/pushbasedockerimage_tmp.yml index c69bdb44d..af126efec 100644 --- a/.github/workflows/pushbasedockerimage_tmp.yml +++ b/.github/workflows/pushbasedockerimage_tmp.yml @@ -64,6 +64,6 @@ jobs: GCOV=${{ env.GCOV }} VTK_VERSION=${{ env.VTK_VERSION }} PYTHON_VERSION=${{ env.PYTHON_VERSION }} - file: ci/docker/make-base.dockerfile + file: ci/docker/make-base-ubuntu.dockerfile push: true tags: "${{ env.DOCKER_REPOSITORY }}:${{ env.DOCKER_TAG }}" diff --git a/ci/docker/make-base-ubuntu-24.04.dockerfile b/ci/docker/make-base-ubuntu-24.04.dockerfile deleted file mode 100644 index 703cef654..000000000 --- a/ci/docker/make-base-ubuntu-24.04.dockerfile +++ /dev/null @@ -1,103 +0,0 @@ -# Docker instructions to build an image with some arguments to specify compilers, python and VTK versions. -# @see .github/workflows/pushbasedockerimage.yml - -ARG BASE_IMAGE=ubuntu:24.04 - -# Base image & requirements -FROM ${BASE_IMAGE} AS base - -# Arguments -ARG VTK_VERSION=v9.2.2 -ARG PYTHON_VERSION=3.8 -ARG CC=gcc-11 -ARG CXX=g++-11 -ARG GCOV=gcov-11 - -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update -y -q && \ - apt-get install -y -q --no-install-recommends \ - ${CC} \ - ${CXX} \ - git \ - xz-utils \ - bzip2 \ - zip \ - gpg \ - wget \ - gpgconf \ - software-properties-common \ - libsigsegv2 \ - libsigsegv-dev \ - pkg-config \ - zlib1g \ - zlib1g-dev \ - m4 \ - gfortran-11 \ - make \ - cmake-data \ - cmake \ - pkg-config \ - libncurses5-dev \ - m4 \ - libgl1-mesa-dev \ - libglu1-mesa-dev \ - mesa-common-dev \ - libosmesa6-dev \ - perl \ - curl \ - xvfb \ - lcov \ - && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Share environment variables for use in images based on this. -ENV CC=/usr/bin/$CC -ENV CXX=/usr/bin/$CXX -ENV GCOV=/usr/bin/$GCOV -ENV VTK_DIR=/opt/build/vtk - -# Setup python 3.8 with conda - -# Download and install Miniconda -RUN curl -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ - bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda && \ - rm Miniconda3-latest-Linux-x86_64.sh - -# Update PATH so that conda and the installed packages are usable -ENV PATH="/opt/conda/bin:${PATH}" - -# Create a new environment and install necessary packages -RUN conda create -y -n deves python=${PYTHON_VERSION} && \ - echo "source activate deves" > ~/.bashrc && \ - /bin/bash -c ". /opt/conda/etc/profile.d/conda.sh && conda activate deves && pip install nanobind" - -# Set the environment to deves on container run -ENV CONDA_DEFAULT_ENV=deves -ENV CONDA_PREFIX=/opt/conda/envs/$CONDA_DEFAULT_ENV -ENV PATH=$PATH:$CONDA_PREFIX/bin -ENV CONDA_AUTO_UPDATE_CONDA=false - -# Clone VTK source -RUN mkdir -p /opt/src/vtk -RUN git clone --recursive --branch v${VTK_VERSION} https://gitlab.kitware.com/vtk/vtk.git /opt/src/vtk - -# Build VTK -# Note: use X not OSMESA because of glew build error on ubuntu 24.04 -RUN mkdir -p ${VTK_DIR} -WORKDIR ${VTK_DIR} -RUN if [ "${BASE_IMAGE}" ] cmake \ - -DCMAKE_BUILD_TYPE:STRING=Release \ - -DBUILD_TESTING:BOOL=OFF \ - -DVTK_OPENGL_HAS_OSMESA:BOOL=OFF \ - -DVTK_DEFAULT_RENDER_WINDOW_OFFSCREEN:BOOL=ON \ - -DVTK_USE_X:BOOL=ON \ - -DVTK_USE_WIN32_OPENGL:BOOL=OFF \ - -DVTK_USE_COCOA:BOOL=OFF \ - -DVTK_USE_SDL2:BOOL=OFF \ - -DVTK_Group_Rendering:BOOL=OFF \ - -DBUILD_SHARED_LIBS:BOOL=ON \ - -S /opt/src/vtk -B ${VTK_DIR} -RUN cmake --build ${VTK_DIR} -j$(nproc) - -RUN echo "Base creation success" diff --git a/ci/docker/make-base-ubuntu-22.04.dockerfile b/ci/docker/make-base-ubuntu.dockerfile similarity index 88% rename from ci/docker/make-base-ubuntu-22.04.dockerfile rename to ci/docker/make-base-ubuntu.dockerfile index b0f876017..03fb96f95 100644 --- a/ci/docker/make-base-ubuntu-22.04.dockerfile +++ b/ci/docker/make-base-ubuntu.dockerfile @@ -83,14 +83,16 @@ RUN mkdir -p /opt/src/vtk RUN git clone --recursive --branch v${VTK_VERSION} https://gitlab.kitware.com/vtk/vtk.git /opt/src/vtk # Build VTK +# Note: Ubuntu 24.04 currently encounters inner glew build error when OPENGL_HAS_OSMESA is true. +# but successfully build using X. RUN mkdir -p ${VTK_DIR} WORKDIR ${VTK_DIR} -RUN if [ "${BASE_IMAGE}" ] cmake \ +RUN cmake \ -DCMAKE_BUILD_TYPE:STRING=Release \ -DBUILD_TESTING:BOOL=OFF \ - -DVTK_OPENGL_HAS_OSMESA:BOOL=ON \ + -DVTK_OPENGL_HAS_OSMESA:BOOL=$([ "${BASE_IMAGE}" == "ubuntu:24.04" ] && echo "OFF" || echo "ON") \ -DVTK_DEFAULT_RENDER_WINDOW_OFFSCREEN:BOOL=ON \ - -DVTK_USE_X:BOOL=OFF \ + -DVTK_USE_X:BOOL=$([ "${BASE_IMAGE}" == "ubuntu:24.04" ] && echo "ON" || echo "OFF") \ -DVTK_USE_WIN32_OPENGL:BOOL=OFF \ -DVTK_USE_COCOA:BOOL=OFF \ -DVTK_USE_SDL2:BOOL=OFF \