diff --git a/.github/workflows/docker_publish.yml b/.github/workflows/docker_publish.yml index 573b0e6c09..ae4097a6a9 100644 --- a/.github/workflows/docker_publish.yml +++ b/.github/workflows/docker_publish.yml @@ -37,7 +37,8 @@ jobs: - name: Build and Export Dockerfile_0_base uses: docker/build-push-action@v2 with: - file: CI/Dockerfile_0_base + file: CI/Dockerfile + target: base push: true context: . build-args: | @@ -116,7 +117,8 @@ jobs: - name: Build and push Dockerfile_1_external_deps uses: docker/build-push-action@v2 with: - file: CI/Dockerfile_1_external_deps + file: CI/Dockerfile + target: external_deps context: . push: false build-args: | @@ -129,7 +131,8 @@ jobs: - name: Build and export Dockerfile_2_hdf5 uses: docker/build-push-action@v2 with: - file: CI/Dockerfile_2_hdf5 + file: CI/Dockerfile + target: hdf5 context: . push: true build-args: | @@ -184,7 +187,8 @@ jobs: - name: Build and push Dockerfile_3_moab uses: docker/build-push-action@v2 with: - file: CI/Dockerfile_3_moab + file: CI/Dockerfile + target: moab context: . push: true build-args: | diff --git a/CI/Dockerfile b/CI/Dockerfile index 3f23d0141d..2f25be054b 100644 --- a/CI/Dockerfile +++ b/CI/Dockerfile @@ -1,32 +1,93 @@ ARG UBUNTU_VERSION=18.04 -FROM ubuntu:${UBUNTU_VERSION} +FROM ubuntu:${UBUNTU_VERSION} AS base # Use bash as the default shell SHELL ["/bin/bash", "-c"] +# Ubuntu Setup +ENV TZ=America/Chicago +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # Update core packages -ARG UBUNTU_VERSION=18.04 RUN apt-get -y update; \ - apt-get -y install autoconf clang cmake g++ gcc gfortran git libblas-dev \ - libhdf5-dev liblapack-dev libpython2.7-dev libtool libeigen3-dev\ - python-numpy python-pip python-setuptools wget; \ - if [ "${UBUNTU_VERSION}" = "18.04" ]; then \ - pip install sphinx; \ - apt-get -y install astyle; \ - fi; \ - pip install cython + apt-get -y install autoconf \ + clang \ + cmake \ + g++ \ + gcc \ + gfortran \ + libhdf5-dev \ + libtool \ + libeigen3-dev\ + python3-numpy \ + python3 \ + python3-pip \ + python3-setuptools \ + python3-dev \ + libpython3-dev \ + wget \ + software-properties-common; \ + add-apt-repository ppa:git-core/ppa; \ + apt-get update; \ + apt-get install -y git; \ + update-alternatives --install /usr/bin/python python /usr/bin/python3 10; \ + update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10; \ + pip install cython; + # Copy scripts to docker image RUN mkdir -p /root/etc/ COPY CI/ /root/etc/CI +#TODO move sh file contents into this Dockerfile ENV docker_env=/root/etc/CI/env.sh -# Build HDF5 then Geant4 then MOAB 5.1.0 -RUN COMPILER=gcc HDF5_VERSION=1.10.4 /root/etc/CI/docker/build_hdf5.sh && \ - COMPILER=clang HDF5_VERSION=1.10.4 /root/etc/CI/docker/build_hdf5.sh && \ - COMPILER=gcc /root/etc/CI/docker/build_geant4.sh && \ - COMPILER=clang /root/etc/CI/docker/build_geant4.sh && \ - COMPILER=gcc HDF5_VERSION=system MOAB_VERSION=5.1.0 /root/etc/CI/docker/build_moab.sh && \ - COMPILER=clang HDF5_VERSION=system MOAB_VERSION=5.1.0 /root/etc/CI/docker/build_moab.sh && \ - COMPILER=gcc HDF5_VERSION=1.10.4 MOAB_VERSION=5.1.0 /root/etc/CI/docker/build_moab.sh && \ - COMPILER=clang HDF5_VERSION=1.10.4 MOAB_VERSION=5.1.0 /root/etc/CI/docker/build_moab.sh +ENV build_dir=/root/build_dir +ENV install_dir=/root/opt + + +FROM base as external_deps + +#setting the COMPILER variable +ARG COMPILER=gcc +ENV COMPILER=${COMPILER} + +# Set Geant4 env variable +ENV geant4_build_dir=${build_dir}/geant4 +ENV geant4_install_dir=${install_dir}/geant4 + +# Build Geant4 +#TODO move sh file contents into this Dockerfile +RUN /root/etc/CI/docker/build_geant4.sh + +ENV double_down_build_dir=${build_dir}/double-down/ +ENV double_down_install_dir=${install_dir}/double-down/ + +# Build Embree +#TODO move sh file contents into this Dockerfile +RUN /root/etc/CI/docker/build_embree.sh + +FROM external_deps AS hdf5 + +# Set HDF5 env variable +ENV hdf5_build_dir=${build_dir}/hdf5 +ENV hdf5_install_dir=${install_dir}/hdf5 + +# Build HDF5 +# HDF5 argument possible value: 1.10.4 or system +ARG HDF5=1.10.4 +ENV HDF5_VERSION=${HDF5} +#TODO move sh file contents into this Dockerfile +RUN /root/etc/CI/docker/build_hdf5.sh + +FROM hdf5 AS moab + +# Set MOAB env variable +ENV moab_build_dir=${build_dir}/moab +ENV moab_install_dir=${install_dir}/moab + +ARG MOAB=5.3.0 +ENV MOAB_VERSION ${MOAB} +#TODO move sh file contents into this Dockerfile +RUN if [ "${MOAB_VERSION}" != "master" ] && [ "${MOAB_VERSION}" != "develop" ]; then \ + /root/etc/CI/docker/build_moab.sh; \ + fi; + diff --git a/CI/Dockerfile_0_base b/CI/Dockerfile_0_base deleted file mode 100644 index bc18da2f5a..0000000000 --- a/CI/Dockerfile_0_base +++ /dev/null @@ -1,43 +0,0 @@ -ARG UBUNTU_VERSION=18.04 -FROM ubuntu:${UBUNTU_VERSION} - -# Use bash as the default shell -SHELL ["/bin/bash", "-c"] -# Ubuntu Setup -ENV TZ=America/Chicago -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -# Update core packages -RUN apt-get -y update; \ - apt-get -y install autoconf \ - clang \ - cmake \ - g++ \ - gcc \ - gfortran \ - libhdf5-dev \ - libtool \ - libeigen3-dev\ - python3-numpy \ - python3 \ - python3-pip \ - python3-setuptools \ - python3-dev \ - libpython3-dev \ - wget \ - software-properties-common; \ - add-apt-repository ppa:git-core/ppa; \ - apt-get update; \ - apt-get install -y git; \ - update-alternatives --install /usr/bin/python python /usr/bin/python3 10; \ - update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10; \ - pip install cython; - - -# Copy scripts to docker image -RUN mkdir -p /root/etc/ -COPY CI/ /root/etc/CI -ENV docker_env=/root/etc/CI/env.sh - -ENV build_dir=/root/build_dir -ENV install_dir=/root/opt diff --git a/CI/Dockerfile_1_external_deps b/CI/Dockerfile_1_external_deps deleted file mode 100644 index 9d0be56cb1..0000000000 --- a/CI/Dockerfile_1_external_deps +++ /dev/null @@ -1,21 +0,0 @@ -ARG UBUNTU_VERSION=18.04ARG -ARG OWNER=svalinn -ARG TAG=latest -FROM ghcr.io/${OWNER}/dagmc-ci-ubuntu-${UBUNTU_VERSION}:$TAG - -#setting the COMPILER variable -ARG COMPILER=gcc -ENV COMPILER=${COMPILER} - -# Set Geant4 env variable -ENV geant4_build_dir=${build_dir}/geant4 -ENV geant4_install_dir=${install_dir}/geant4 - -# Build Geant4 -RUN /root/etc/CI/docker/build_geant4.sh - -ENV double_down_build_dir=${build_dir}/double-down/ -ENV double_down_install_dir=${install_dir}/double-down/ - -# Build Embree -RUN /root/etc/CI/docker/build_embree.sh diff --git a/CI/Dockerfile_1_housekeeping b/CI/Dockerfile_1_housekeeping index de398652ed..43065975c4 100644 --- a/CI/Dockerfile_1_housekeeping +++ b/CI/Dockerfile_1_housekeeping @@ -5,4 +5,3 @@ FROM ghcr.io/${OWNER}/dagmc-ci-ubuntu-${UBUNTU_VERSION}:$TAG RUN pip install sphinx; \ apt-get -y install clang-format - diff --git a/CI/Dockerfile_2_hdf5 b/CI/Dockerfile_2_hdf5 deleted file mode 100644 index cf82e573fa..0000000000 --- a/CI/Dockerfile_2_hdf5 +++ /dev/null @@ -1,17 +0,0 @@ -ARG UBUNTU_VERSION=18.04 -ARG COMPILER=gcc -ARG OWNER=svalinn -ARG TAG=latest -FROM ghcr.io/${OWNER}/dagmc-ci-ubuntu-${UBUNTU_VERSION}-${COMPILER}-ext:$TAG - - - -# Set HDF5 env variable -ENV hdf5_build_dir=${build_dir}/hdf5 -ENV hdf5_install_dir=${install_dir}/hdf5 - -# Build HDF5 -# HDF5 argument possible value: 1.10.4 or system -ARG HDF5=1.10.4 -ENV HDF5_VERSION=${HDF5} -RUN /root/etc/CI/docker/build_hdf5.sh diff --git a/CI/Dockerfile_3_moab b/CI/Dockerfile_3_moab deleted file mode 100644 index 57427b0625..0000000000 --- a/CI/Dockerfile_3_moab +++ /dev/null @@ -1,16 +0,0 @@ -ARG UBUNTU_VERSION=18.04 -ARG COMPILER=gcc -ARG HDF5=1.10.4 -ARG OWNER=svalinn -ARG TAG=latest -FROM ghcr.io/${OWNER}/dagmc-ci-ubuntu-${UBUNTU_VERSION}-${COMPILER}-ext-hdf5_${HDF5}:$TAG - -# Set MOAB env variable -ENV moab_build_dir=${build_dir}/moab -ENV moab_install_dir=${install_dir}/moab - -ARG MOAB=5.3.0 -ENV MOAB_VERSION ${MOAB} -RUN if [ "${MOAB_VERSION}" != "master" ] && [ "${MOAB_VERSION}" != "develop" ]; then \ - /root/etc/CI/docker/build_moab.sh; \ - fi; diff --git a/CI/update_docker.sh b/CI/update_docker.sh index 1126eb7956..1558886dbf 100755 --- a/CI/update_docker.sh +++ b/CI/update_docker.sh @@ -22,20 +22,23 @@ moab_versions="5.3.0 develop master" for ubuntu_version in ${ubuntu_versions}; do image_name="svalinn/dagmc-ci-ubuntu-${ubuntu_version}" docker build -t ${image_name} --build-arg UBUNTU_VERSION=${ubuntu_version} \ - -f CI/Dockerfile_0_base . + -f CI/Dockerfile \ + --target base . if [ "$PUSH" = true ]; then docker push ${image_name}; fi for compiler in $compilers; do image_name="svalinn/dagmc-ci-ubuntu-${ubuntu_version}-${compiler}-ext" docker build -t ${image_name} --build-arg UBUNTU_VERSION=${ubuntu_version} \ --build-arg COMPILER=${compiler} \ - -f CI/Dockerfile_1_external_deps . + -f CI/Dockerfile \ + --target external_deps . if [ "$PUSH" = true ]; then docker push ${image_name}; fi for hdf5 in $hdf5_versions; do image_name="svalinn/dagmc-ci-ubuntu-${ubuntu_version}-${compiler}-ext-hdf5_${hdf5}" docker build -t ${image_name} --build-arg UBUNTU_VERSION=${ubuntu_version} \ --build-arg COMPILER=${compiler} \ --build-arg HDF5=${hdf5} \ - -f CI/Dockerfile_2_hdf5 . + -f CI/Dockerfile \ + --target hdf5 . if [ "$PUSH" = true ]; then docker push ${image_name}; fi for moab in $moab_versions; do image_name="svalinn/dagmc-ci-ubuntu-${ubuntu_version}-${compiler}-ext-hdf5_${hdf5}-moab_${moab}" @@ -43,7 +46,8 @@ for ubuntu_version in ${ubuntu_versions}; do --build-arg COMPILER=${compiler} \ --build-arg HDF5=${hdf5} \ --build-arg MOAB=${moab} \ - -f CI/Dockerfile_3_moab . + -f CI/Dockerfile \ + --target moab . if [ "$PUSH" = true ]; then docker push ${image_name}; fi done done diff --git a/doc/CHANGELOG.rst b/doc/CHANGELOG.rst index 3b404dce8d..0cbcc6a5e1 100644 --- a/doc/CHANGELOG.rst +++ b/doc/CHANGELOG.rst @@ -7,6 +7,11 @@ DAGMC Changelog Next version ==================== +**Changed:** + + * Using multi stage Dockerfile to reduce the number of Dockerfile (#813) + + v3.2.2 ====================