From c3a1e837176b0251c313f55174fb380247219567 Mon Sep 17 00:00:00 2001 From: agwhittle Date: Thu, 27 Jun 2024 16:51:52 +0100 Subject: [PATCH 1/3] Add new docker build script and copy build_ubuntu script in docker directory. --- docker/Dockerfile | 95 +++++++++++++++++++++++++++++++++------- docker/install_ubuntu.sh | 69 +++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+), 15 deletions(-) create mode 100755 docker/install_ubuntu.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index 745981f..74e266c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,19 +1,84 @@ -# To build the Docker container, run the following lines from your proteus root directory: -# cd docker -# docker build --rm -t proteus:latest . +# Use Ubuntu as the base image +FROM ubuntu:22.04 -# Get latest base MOOSE image -FROM idaholab/moose:latest +# Set environment variables +ENV DEBIAN_FRONTEND=noninteractive +ENV PROTEUS_DIR=/proteus +ENV MOOSE_DIR=/opt/moose +ENV MOOSE_JOBS=1 -# By default, two cores are used to compile -ARG compile_cores=2 +# Copy the build script into the container +COPY install_ubuntu.sh /opt/proteus/scripts/install_ubuntu.sh + +# Update and install dependencies +RUN apt-get update && \ + apt-get install -y \ + gcc \ + g++ \ + gfortran \ + cmake \ + bison \ + flex \ + git \ + python3 \ + python3-dev \ + python-is-python3 \ + python3-packaging \ + openmpi-bin \ + libopenmpi-dev \ + libboost-all-dev \ + libtirpc-dev \ + autoconf \ + automake \ + python3-yaml \ + libtool && \ + # Set up the Proteus profile + echo "export CC=mpicc" > /root/.proteus_profile && \ + echo "export CXX=mpicxx" >> /root/.proteus_profile && \ + echo "export F90=mpif90" >> /root/.proteus_profile && \ + echo "export F77=mpif77" >> /root/.proteus_profile && \ + echo "export FC=mpif90" >> /root/.proteus_profile && \ + echo "export MOOSE_DIR=$MOOSE_DIR" >> /root/.proteus_profile && \ + echo "export PATH=\$PATH:$PROTEUS_DIR" >> /root/.proteus_profile && \ + . /root/.proteus_profile + +# Increase git buffer size and clone MOOSE repository +RUN git config --global http.postBuffer 524288000 && \ + git config --global http.lowSpeedLimit 0 && \ + git config --global http.lowSpeedTime 999999 && \ + git clone --depth 1 https://github.com/idaholab/moose.git $MOOSE_DIR || \ + { echo "Retrying..."; sleep 5; git clone --depth 1 https://github.com/idaholab/moose.git $MOOSE_DIR; } + +# Build PETSc +RUN cd $MOOSE_DIR && \ + unset PETSC_DIR PETSC_ARCH && \ + ./scripts/update_and_rebuild_petsc.sh \ + --CXXOPTFLAGS="-O3 -march=native" \ + --COPTFLAGS="-O3 -march=native" \ + --FOPTFLAGS="-O3 -march=native" + +# Build libMesh +RUN cd $MOOSE_DIR && \ + ./scripts/update_and_rebuild_libmesh.sh --with-mpi + +# Build WASP +RUN cd $MOOSE_DIR && \ + ./scripts/update_and_rebuild_wasp.sh + +# Configure AD +RUN cd $MOOSE_DIR && \ + ./configure --with-derivative-size=81 + +# Copy Proteus source code +RUN git clone https://github.com/aurora-multiphysics/proteus.git # Build Proteus -RUN cd /$WORKDIR && \ - git clone https://github.com/aurora-multiphysics/proteus.git && \ - cd proteus && \ - make -j"$compile_cores" - -# Run tests -RUN cd /proteus && \ - ./run_tests +RUN cd $PROTEUS_DIR && \ + make -j $MOOSE_JOBS + +# Set working directory +WORKDIR /opt/proteus + +# Set entrypoint +ENTRYPOINT ["/bin/bash"] + diff --git a/docker/install_ubuntu.sh b/docker/install_ubuntu.sh new file mode 100755 index 0000000..cb81fcc --- /dev/null +++ b/docker/install_ubuntu.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# This script installs Proteus on Ubuntu, +# including a MOOSE framework build in the $HOME directory. +# Optimised to the native system architecture. +# A .proteus_profile script is added to the $HOME directory. +# This script is intended to be used from the proteus directory +# ./scripts/install_ubuntu.sh +# Use the installation by typing: +# source $HOME/.proteus_profile + +export PROTEUS_DIR=`pwd` + +# If MOOSE_JOBS is unset, set to 1 +if [ -z $MOOSE_JOBS ]; then + export MOOSE_JOBS=1 +fi +export METHODS="opt" + +# Install pre-requisites + +sudo apt install -y gcc g++ gfortran cmake bison flex git +sudo apt install -y python3 python3-dev python-is-python3 python3-packaging +sudo apt install -y openmpi-bin libopenmpi-dev libboost-all-dev + +# Make Proteus profile + +echo "export CC=mpicc" > $HOME/.proteus_profile +echo "export CXX=mpicxx" >> $HOME/.proteus_profile +echo "export F90=mpif90" >> $HOME/.proteus_profile +echo "export F77=mpif77" >> $HOME/.proteus_profile +echo "export FC=mpif90" >> $HOME/.proteus_profile +echo "export MOOSE_DIR="$HOME"/moose" >> $HOME/.proteus_profile +echo "export PATH=\$PATH:"$PROTEUS_DIR >> $HOME/.proteus_profile +source $HOME/.proteus_profile + +# Clone MOOSE from git + +cd $HOME +git clone https://github.com/idaholab/moose.git + +# Build PETSc + +cd $MOOSE_DIR +unset PETSC_DIR PETSC_ARCH +./scripts/update_and_rebuild_petsc.sh \ +--CXXOPTFLAGS="-O3 -march=native" \ +--COPTFLAGS="-O3 -march=native" \ +--FOPTFLAGS="-O3 -march=native" + +# Build libMesh + +./scripts/update_and_rebuild_libmesh.sh --with-mpi + +# Build WASP + +./scripts/update_and_rebuild_wasp.sh + +# Configure AD +# Derivative size should be the total of +# 8 for each first order variable +# 27 for each second order variable + +./configure --with-derivative-size=81 + +cd $PROTEUS_DIR +make -j $MOOSE_JOBS + +echo "Installation complete." From 2077f0d96179e4dd9432ed19015d49b6c7b38b8e Mon Sep 17 00:00:00 2001 From: agwhittle Date: Fri, 28 Jun 2024 10:13:35 +0100 Subject: [PATCH 2/3] Clean up docker directory. --- docker/Dockerfile | 5 +-- docker/install_ubuntu.sh | 69 ---------------------------------------- 2 files changed, 1 insertion(+), 73 deletions(-) delete mode 100755 docker/install_ubuntu.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index 74e266c..8881a81 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,10 +5,7 @@ FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive ENV PROTEUS_DIR=/proteus ENV MOOSE_DIR=/opt/moose -ENV MOOSE_JOBS=1 - -# Copy the build script into the container -COPY install_ubuntu.sh /opt/proteus/scripts/install_ubuntu.sh +ENV MOOSE_JOBS=4 # Update and install dependencies RUN apt-get update && \ diff --git a/docker/install_ubuntu.sh b/docker/install_ubuntu.sh deleted file mode 100755 index cb81fcc..0000000 --- a/docker/install_ubuntu.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# This script installs Proteus on Ubuntu, -# including a MOOSE framework build in the $HOME directory. -# Optimised to the native system architecture. -# A .proteus_profile script is added to the $HOME directory. -# This script is intended to be used from the proteus directory -# ./scripts/install_ubuntu.sh -# Use the installation by typing: -# source $HOME/.proteus_profile - -export PROTEUS_DIR=`pwd` - -# If MOOSE_JOBS is unset, set to 1 -if [ -z $MOOSE_JOBS ]; then - export MOOSE_JOBS=1 -fi -export METHODS="opt" - -# Install pre-requisites - -sudo apt install -y gcc g++ gfortran cmake bison flex git -sudo apt install -y python3 python3-dev python-is-python3 python3-packaging -sudo apt install -y openmpi-bin libopenmpi-dev libboost-all-dev - -# Make Proteus profile - -echo "export CC=mpicc" > $HOME/.proteus_profile -echo "export CXX=mpicxx" >> $HOME/.proteus_profile -echo "export F90=mpif90" >> $HOME/.proteus_profile -echo "export F77=mpif77" >> $HOME/.proteus_profile -echo "export FC=mpif90" >> $HOME/.proteus_profile -echo "export MOOSE_DIR="$HOME"/moose" >> $HOME/.proteus_profile -echo "export PATH=\$PATH:"$PROTEUS_DIR >> $HOME/.proteus_profile -source $HOME/.proteus_profile - -# Clone MOOSE from git - -cd $HOME -git clone https://github.com/idaholab/moose.git - -# Build PETSc - -cd $MOOSE_DIR -unset PETSC_DIR PETSC_ARCH -./scripts/update_and_rebuild_petsc.sh \ ---CXXOPTFLAGS="-O3 -march=native" \ ---COPTFLAGS="-O3 -march=native" \ ---FOPTFLAGS="-O3 -march=native" - -# Build libMesh - -./scripts/update_and_rebuild_libmesh.sh --with-mpi - -# Build WASP - -./scripts/update_and_rebuild_wasp.sh - -# Configure AD -# Derivative size should be the total of -# 8 for each first order variable -# 27 for each second order variable - -./configure --with-derivative-size=81 - -cd $PROTEUS_DIR -make -j $MOOSE_JOBS - -echo "Installation complete." From 74dc256df744b48129e4e867c961d34bcbbaa75d Mon Sep 17 00:00:00 2001 From: agwhittle Date: Mon, 8 Jul 2024 11:58:28 +0100 Subject: [PATCH 3/3] Fix Dockerfile. --- docker/Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 8881a81..18c146d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,3 +1,7 @@ +# To build the Docker container, run the following lines from your proteus root directory: +# cd docker +# docker build --rm -t proteus:latest . + # Use Ubuntu as the base image FROM ubuntu:22.04 @@ -74,8 +78,11 @@ RUN cd $PROTEUS_DIR && \ make -j $MOOSE_JOBS # Set working directory -WORKDIR /opt/proteus +WORKDIR /proteus # Set entrypoint ENTRYPOINT ["/bin/bash"] +# Run tests +RUN cd /proteus && \ + ./run_tests