Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced number of Dockerfiles #813

Merged
merged 5 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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: |
Expand All @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down
99 changes: 80 additions & 19 deletions CI/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put 2 line breaks between stages

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also add a comment before the FROM to explain what the stage is about


# 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;

43 changes: 0 additions & 43 deletions CI/Dockerfile_0_base

This file was deleted.

21 changes: 0 additions & 21 deletions CI/Dockerfile_1_external_deps

This file was deleted.

1 change: 0 additions & 1 deletion CI/Dockerfile_1_housekeeping
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ FROM ghcr.io/${OWNER}/dagmc-ci-ubuntu-${UBUNTU_VERSION}:$TAG

RUN pip install sphinx; \
apt-get -y install clang-format

17 changes: 0 additions & 17 deletions CI/Dockerfile_2_hdf5

This file was deleted.

16 changes: 0 additions & 16 deletions CI/Dockerfile_3_moab

This file was deleted.

12 changes: 8 additions & 4 deletions CI/update_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,32 @@ 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}"
docker build -t ${image_name} --build-arg UBUNTU_VERSION=${ubuntu_version} \
--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
Expand Down
5 changes: 5 additions & 0 deletions doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ DAGMC Changelog
Next version
====================

**Changed:**

* Using multi stage Dockerfile to reduce the number of Dockerfile (#813)


v3.2.2
====================

Expand Down