Commit 084c56f3 authored by GILLES Sebastien's avatar GILLES Sebastien

#1460 Reintroduce proper way to create Docker images.

New way to create the Docker images uses up only one Dockerfile, and the call to `docker build` must occur within standard MoReFEM directory.

A README in Docker directory explains precisely how to create images.
parent 67bbb955
# Just keep Sources, cmake, Scripts and Data folders and CMakeLists.txt file.
build*
Changelog.md
Docker/
Documentation/
ExternalTools/
Home.md
MoReFEM.xcodeproj/
QuickAndDirtyScripts/
README.md
ThirdPartyXCodeProjects/
XCodeConfig/
XCodeTemplates/
......@@ -5,10 +5,25 @@ Starting from v18.47, the ticket numbers in bold are those that might break comp
# Development
## Documentation
- Documentation #1459: Move the introduction talks in a [separate project](https://gitlab.inria.fr/MoReFEM/CoreLibrary/introductiontalks.git).
## Tests
- Bug #1461: Due to a git mishap, test about PetscVectorIO was buggy (the fix to the bug was unwittingly overwritten...)
## External tools
- Feature #1460: Reintroduce proper way to generate easily Docker images of MoReFEM.
- Feature #1463: Add configure_cmake_external_model.py to the MoReFEM installation.
- Bug #1462: Add in PreCacheFile the values of CMAKE_C_COMPILER and CMAKE_CXX_COMPILER.
# v19.29
## Outputs
......
# ================================================================================================================
# This Dockerfile assumes a local image onto which third party libraries are built properly is available.
# See https://gitlab.inria.fr/MoReFEM/ThirdPartyCompilationFactory to see how it was generated.
# ================================================================================================================
ARG os
ARG mode
ARG compiler
ARG is_single_library
ARG library_type
FROM registry.gitlab.inria.fr/morefem/thirdpartycompilationfactory/${os}-${compiler}-${mode} AS third_party_container
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
# Repeat is mandatory here - see https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG os
ARG mode
ARG compiler
ARG is_single_library
ARG library_type
USER root
WORKDIR MoReFEM
RUN mkdir -p build_docker
RUN chmod 777 build_docker /opt
USER ${USER}
COPY Sources Sources
COPY cmake cmake
COPY Scripts Scripts
COPY CMakeLists.txt CMakeLists.txt
COPY Data Data
WORKDIR build_docker
RUN python ../cmake/Scripts/configure_cmake.py --cache_file=../cmake/PreCache/linux.cmake --cmake_args="-G Ninja" --install_directory=/opt --third_party_directory=/opt --morefem_as_single_library=${is_single_library} --mode=${mode} --library_type=${library_type}
RUN ninja
RUN ctest
RUN ninja install
WORKDIR /home/non_root_user/Codes
USER root
RUN rm -rf MoReFEM /tmp/*
USER ${USER}
FROM registry.gitlab.inria.fr/morefem/thirdpartycompilationfactory/${os}-${compiler}-${mode}
COPY --from=third_party_container /opt/MoReFEM /opt/MoReFEM
\ No newline at end of file
# ================================================================================================================
# This Dockerfile assumes a local image onto which third party libraries are built properly is available.
# See https://gitlab.inria.fr/MoReFEM/ThirdPartyCompilationFactory to see how it was generated.
# ================================================================================================================
FROM third_party_4_morefem_fedora_clang_debug
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
ARG branch
# ================================================================================================================
# Install required tools
# ================================================================================================================
USER root
RUN dnf install -y ninja-build
# Adapted from https://askubuntu.com/questions/952429/is-there-are-good-ppa-for-cmake-backports
# We need cmake >= 3.8 and Ubuntu ships 3.5...
RUN curl -O https://cmake.org/files/v3.12/cmake-3.12.1-Linux-x86_64.sh \
&& sh cmake-3.12.1-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir \
&& rm -f cmake-3.12.1-Linux-x86_64.sh
# ================================================================================================================
# Clone the MoReFEM repository.
# ================================================================================================================
USER ${USER}
# Check 'branch' has properly be transmitted to the Dockerfile.
# See https://stackoverflow.com/questions/38438933/how-to-make-a-build-arg-mandatory-during-docker-build.
RUN test -n "${branch}"
RUN git clone -b ${branch} https://gitlab.inria.fr/MoReFEM/CoreLibrary/MoReFEM
WORKDIR MoReFEM
# ================================================================================================================
# Build all the targets in the project.
# Tests should be run to be sure in a container (through ctest in the build directory) but are not here to save
# space in the generated image.
# ================================================================================================================
RUN mkdir build
WORKDIR build
RUN python ../cmake/Scripts/configure_cmake.py --cache_file=../cmake/PreCache/linux.cmake --cmake_args="-G Ninja" --install_directory=/opt/MoReFEM --third_party_directory=/opt --morefem_as_single_library=False --mode="Debug"
RUN ninja -j 4
# The two lines below should be run in a container but are not in the image creation to save space (tests do
# generate outputs and installation basically duplicates libraries and executables generated).
#RUN ninja install
#RUN ninja test
# ================================================================================================================
# This Dockerfile assumes a local image onto which third party libraries are built properly is available.
# See https://gitlab.inria.fr/MoReFEM/ThirdPartyCompilationFactory to see how it was generated.
# ================================================================================================================
FROM third_party_4_morefem_fedora_clang_release
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
ARG branch
# ================================================================================================================
# Install required tools
# ================================================================================================================
USER root
RUN dnf install -y ninja-build
# Adapted from https://askubuntu.com/questions/952429/is-there-are-good-ppa-for-cmake-backports
# We need cmake >= 3.8 and Ubuntu ships 3.5...
RUN curl -O https://cmake.org/files/v3.12/cmake-3.12.1-Linux-x86_64.sh \
&& sh cmake-3.12.1-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir \
&& rm -f cmake-3.12.1-Linux-x86_64.sh
# ================================================================================================================
# Clone the MoReFEM repository.
# ================================================================================================================
USER ${USER}
# Check 'branch' has properly be transmitted to the Dockerfile.
# See https://stackoverflow.com/questions/38438933/how-to-make-a-build-arg-mandatory-during-docker-build.
RUN test -n "${branch}"
RUN git clone -b ${branch} https://gitlab.inria.fr/MoReFEM/CoreLibrary/MoReFEM
WORKDIR MoReFEM
# ================================================================================================================
# Build all the targets in the project.
# Tests should be run to be sure in a container (through ctest in the build directory) but are not here to save
# space in the generated image.
# ================================================================================================================
RUN mkdir build
WORKDIR build
RUN python ../cmake/Scripts/configure_cmake.py --cache_file=../cmake/PreCache/linux.cmake --cmake_args="-G Ninja" --install_directory=/opt/MoReFEM --third_party_directory=/opt --morefem_as_single_library=False --mode="Release"
RUN ninja -j 4
# The two lines below should be run in a container but are not in the image creation to save space (tests do
# generate outputs and installation basically duplicates libraries and executables generated).
#RUN ninja install
#RUN ninja test
# ================================================================================================================
# This Dockerfile assumes a local image onto which third party libraries are built properly is available.
# See https://gitlab.inria.fr/MoReFEM/ThirdPartyCompilationFactory to see how it was generated.
# ================================================================================================================
FROM third_party_4_morefem_fedora_gcc_release
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
ARG branch
# ================================================================================================================
# Install required tools
# ================================================================================================================
USER root
RUN dnf install -y ninja-build
# Adapted from https://askubuntu.com/questions/952429/is-there-are-good-ppa-for-cmake-backports
# We need cmake >= 3.8 and Ubuntu ships 3.5...
RUN curl -O https://cmake.org/files/v3.12/cmake-3.12.1-Linux-x86_64.sh \
&& sh cmake-3.12.1-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir \
&& rm -f cmake-3.12.1-Linux-x86_64.sh
# ================================================================================================================
# Clone the MoReFEM repository.
# ================================================================================================================
USER ${USER}
# Check 'branch' has properly be transmitted to the Dockerfile.
# See https://stackoverflow.com/questions/38438933/how-to-make-a-build-arg-mandatory-during-docker-build.
RUN test -n "${branch}"
RUN git clone -b ${branch} https://gitlab.inria.fr/MoReFEM/CoreLibrary/MoReFEM
WORKDIR MoReFEM
# ================================================================================================================
# Build all the targets in the project.
# Tests should be run to be sure in a container (through ctest in the build directory) but are not here to save
# space in the generated image.
# ================================================================================================================
RUN mkdir build
WORKDIR build
RUN python ../cmake/Scripts/configure_cmake.py --cache_file=../cmake/PreCache/linux.cmake --cmake_args="-G Ninja" --install_directory=/opt/MoReFEM --third_party_directory=/opt --morefem_as_single_library=False --mode="Debug"
RUN ninja -j 4
# The two lines below should be run in a container but are not in the image creation to save space (tests do
# generate outputs and installation basically duplicates libraries and executables generated).
#RUN ninja install
#RUN ninja test
# ================================================================================================================
# This Dockerfile assumes a local image onto which third party libraries are built properly is available.
# See https://gitlab.inria.fr/MoReFEM/ThirdPartyCompilationFactory to see how it was generated.
# ================================================================================================================
FROM third_party_4_morefem_fedora_gcc_release
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
ARG branch
# ================================================================================================================
# Install required tools
# ================================================================================================================
USER root
RUN dnf install -y ninja-build
# Adapted from https://askubuntu.com/questions/952429/is-there-are-good-ppa-for-cmake-backports
# We need cmake >= 3.8 and Ubuntu ships 3.5...
RUN curl -O https://cmake.org/files/v3.12/cmake-3.12.1-Linux-x86_64.sh \
&& sh cmake-3.12.1-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir \
&& rm -f cmake-3.12.1-Linux-x86_64.sh
# ================================================================================================================
# Clone the MoReFEM repository.
# ================================================================================================================
USER ${USER}
# Check 'branch' has properly be transmitted to the Dockerfile.
# See https://stackoverflow.com/questions/38438933/how-to-make-a-build-arg-mandatory-during-docker-build.
RUN test -n "${branch}"
RUN git clone -b ${branch} https://gitlab.inria.fr/MoReFEM/CoreLibrary/MoReFEM
WORKDIR MoReFEM
# ================================================================================================================
# Build all the targets in the project.
# Tests should be run to be sure in a container (through ctest in the build directory) but are not here to save
# space in the generated image.
# ================================================================================================================
RUN mkdir build
WORKDIR build
RUN python ../cmake/Scripts/configure_cmake.py --cache_file=../cmake/PreCache/linux.cmake --cmake_args="-G Ninja" --install_directory=/opt/MoReFEM --third_party_directory=/opt --morefem_as_single_library=False --mode="Release"
RUN ninja -j 4
# The two lines below should be run in a container but are not in the image creation to save space (tests do
# generate outputs and installation basically duplicates libraries and executables generated).
#RUN ninja install
#RUN ninja test
# Docker images
# Purpose of the Dockerfile
## Proposed builds
The provided Dockerfile aims to build images of tag versions of MoReFEM that will be saved in the registry of the [Gitlab project](https://gitlab.inria.fr/MoReFEM/CoreLibrary/MoReFEM).
The idea is to provide basic Docker images that enable to play directly with MoReFEM in several basic configurations:
- Ubuntu build with gcc in debug mode
- Ubuntu build with gcc in release mode.
- Fedora build with gcc in debug mode.
- Fedora build with gcc in release mode.
- Fedora build with clang in debug mode.
- Fedora build with clang in release mode.
A generated image is an extension of an image from [third party compilation project](https://gitlab.inria.fr/MoReFEM/ThirdPartyCompilationFactory) for which the installed MoReFEM has been added.
## Prerequisites
As the purpose is to provide a functioning MoReFEM at a minimal storge cost, only the installed libraries and executables are kept; source files are not (but of course you're free to get them back with git on a contained based on the provided image).
Creating these Docker images is clearly a developer level task; it is expected said developer already built in his Docker the following images:
- third_party_4_morefem_ubuntu_debug
- third_party_4_morefem_ubuntu_release
- third_party_4_morefem_fedora_gcc_debug
- third_party_4_morefem_fedora_gcc_release
- third_party_4_morefem_fedora_clang_debug
- third_party_4_morefem_fedora_clang_release
# Generation of the images
## Commands
The Dockerfile in _Docker/Dockerfile_ is used to generate the image with dedicated args.
For instance (when run from the root of the project):
````
DOCKER_BUILDKIT=1 docker build -t registry.gitlab.inria.fr/morefem/corelibrary/morefem/ubuntu_gcc_debug_shared --progress=plain -f Docker/Dockerfile --build-arg os=fedora --build-arg mode=debug --build-arg compiler=gcc --build-arg is_single_library=False --build-arg library_type=shared .
DOCKER_BUILDKIT=1 docker build -t registry.gitlab.inria.fr/morefem/corelibrary/morefem/fedora_clang_release_static --progress=plain -f Docker/Dockerfile --build-arg os=fedora --build-arg mode=release --build-arg compiler=clang --build-arg is_single_library=True --build-arg library_type=static .
DOCKER_BUILDKIT=1 docker build -t registry.gitlab.inria.fr/morefem/corelibrary/morefem/fedora_clang_debug_shared --progress=plain -f Docker/Dockerfile --build-arg os=fedora --build-arg mode=debug --build-arg compiler=clang --build-arg is_single_library=False --build-arg library_type=shared .
````
# Putting images on registry
For instance:
````
docker login registry.gitlab.inria.fr
docker push registry.gitlab.inria.fr/morefem/corelibrary/morefem/fedora_clang_debug_shared
````
# Example of using an image
````
docker run -it registry.gitlab.inria.fr/morefem/corelibrary/morefem/fedora_clang_debug_shared
````
cd Ubuntu
docker build -t morefem_ubuntu_gcc_debug -f Dockerfile.debug --build-arg branch=master .
docker build -t morefem_ubuntu_gcc_release -f Dockerfile.release --build-arg branch=master .
cd ../Fedora
docker build -t morefem_fedora_gcc_debug -f Dockerfile.gcc.debug --build-arg branch=master --build-arg compiler=gcc .
docker build -t morefem_fedora_gcc_release -f Dockerfile.gcc.release --build-arg branch=master --build-arg compiler=gcc .
And inside the container clone a model and run its tests:
````
git clone https://gitlab.inria.fr/MoReFEM/Models/AcousticWave
cd AcousticWave
mkdir build
cd build
python /opt/MoReFEM/cmake/configure_cmake_external_model.py --morefem_install_dir=/opt/MoReFEM --cmake_args="-G Ninja"
ninja
ctest
````
docker build -t morefem_fedora_clang_debug -f Dockerfile.clang.debug --build-arg branch=master --build-arg compiler=clang .
docker build -t morefem_fedora_clang_release -f Dockerfile.clang.release --build-arg branch=master --build-arg compiler=clang .
````
\ No newline at end of file
# ================================================================================================================
# This Dockerfile assumes a local image onto which third party libraries are built properly is available.
# See https://gitlab.inria.fr/MoReFEM/ThirdPartyCompilationFactory to see how it was generated.
# ================================================================================================================
FROM third_party_4_morefem_ubuntu_debug
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
ARG branch
# Check 'branch' has properly be transmitted to the Dockerfile.
# See https://stackoverflow.com/questions/38438933/how-to-make-a-build-arg-mandatory-during-docker-build.
RUN test -n "${branch}"
# ================================================================================================================
# Install required tools
# ================================================================================================================
USER root
RUN apt-get install --no-install-recommends -y ninja-build nano less
# Adapted from https://askubuntu.com/questions/952429/is-there-are-good-ppa-for-cmake-backports
# We need cmake >= 3.8 and Ubuntu ships 3.5...
RUN curl -O https://cmake.org/files/v3.12/cmake-3.12.1-Linux-x86_64.sh \
&& sh cmake-3.12.1-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir \
&& rm -f cmake-3.12.1-Linux-x86_64.sh
# ================================================================================================================
# Clone the MoReFEM repository.
# ================================================================================================================
USER ${USER}
RUN git clone --branch ${branch} https://gitlab.inria.fr/MoReFEM/CoreLibrary/MoReFEM
WORKDIR MoReFEM
# ================================================================================================================
# Build all the targets in the project.
# Tests should be run to be sure in a container (through ctest in the build directory) but are not here to save
# space in the generated image.
# ================================================================================================================
RUN mkdir build
WORKDIR build
RUN python ../cmake/Scripts/configure_cmake.py --cache_file=../cmake/PreCache/linux.cmake --cmake_args="-G Ninja" --install_directory=/opt/MoReFEM --third_party_directory=/opt --morefem_as_single_library=False --mode="Debug"
RUN ninja -j 4
# The two lines below should be run in a container but are not in the image creation to save space (tests do
# generate outputs and installation basically duplicates libraries and executables generated).
#RUN ninja install
#RUN ninja test
# ================================================================================================================
# This Dockerfile assumes a local image onto which third party libraries are built properly is available.
# See https://gitlab.inria.fr/MoReFEM/ThirdPartyCompilationFactory to see how it was generated.
# ================================================================================================================
FROM third_party_4_morefem_ubuntu_release
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
ARG branch
# Check 'branch' has properly be transmitted to the Dockerfile.
# See https://stackoverflow.com/questions/38438933/how-to-make-a-build-arg-mandatory-during-docker-build.
RUN test -n "${branch}"
# ================================================================================================================
# Install required tools
# ================================================================================================================
USER root
RUN apt-get install --no-install-recommends -y ninja-build nano less
# Adapted from https://askubuntu.com/questions/952429/is-there-are-good-ppa-for-cmake-backports
# We need cmake >= 3.8 and Ubuntu ships 3.5...
RUN curl -O https://cmake.org/files/v3.12/cmake-3.12.1-Linux-x86_64.sh \
&& sh cmake-3.12.1-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir \
&& rm -f cmake-3.12.1-Linux-x86_64.sh
# ================================================================================================================
# Clone the MoReFEM repository.
# ================================================================================================================
USER ${USER}
RUN git clone --branch ${branch} https://gitlab.inria.fr/MoReFEM/CoreLibrary/MoReFEM
WORKDIR MoReFEM
# ================================================================================================================
# Build all the targets in the project.
# Tests should be run to be sure in a container (through ctest in the build directory) but are not here to save
# space in the generated image.
# ================================================================================================================
RUN mkdir build
WORKDIR build
RUN python ../cmake/Scripts/configure_cmake.py --cache_file=../cmake/PreCache/linux.cmake --cmake_args="-G Ninja" --install_directory=/opt/MoReFEM --third_party_directory=/opt --morefem_as_single_library=False --mode="Release"
RUN ninja -j 4
# The two lines below should be run in a container but are not in the image creation to save space (tests do
# generate outputs and installation basically duplicates libraries and executables generated).
#RUN ninja install
#RUN ninja test
......@@ -4731,6 +4731,7 @@
BEEABA4C1A49BC8700A875C6 /* Ensight6.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Ensight6.hpp; sourceTree = "<group>"; };
BEEABA4D1A49BC8700A875C6 /* Ensight6.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Ensight6.hxx; sourceTree = "<group>"; };
BEEBEAD722A7C03800D56393 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
BEEDD06222E5A346004BD728 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
BEEF00D81CE4D021002EF0C6 /* GeometricEltList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeometricEltList.cpp; sourceTree = "<group>"; };
BEEF00D91CE4D021002EF0C6 /* GeometricEltList.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GeometricEltList.hpp; sourceTree = "<group>"; };
BEEFEF72196ECCC000C80FF1 /* Matrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Matrix.cpp; sourceTree = "<group>"; };
......@@ -6562,6 +6563,7 @@
BEDFFB7B204EE4F400A52F86 /* TypeName */,
BECEF93222DF63CA00D0DDE7 /* Now */,
BE2457AB1E005B0B00677AEF /* InputData */,
BEEDD06322E5A6E8004BD728 /* WriteLuaFile */,
);
path = Utilities;
sourceTree = "<group>";
......@@ -9856,6 +9858,7 @@
BEBFCE9D205919640033C4C1 /* VariationalInstances */ = {
isa = PBXGroup;
children = (
BEEDD06222E5A346004BD728 /* CMakeLists.txt */,
BE964C1F206E555A00B9ED1E /* Mass */,
BEFEA12C206F867800BF7B35 /* GradGrad */,
BE7E68642065615100AA2FB3 /* NonlinearMembrane */,
......@@ -10339,6 +10342,13 @@
path = OutputFormat;
sourceTree = "<group>";
};
BEEDD06322E5A6E8004BD728 /* WriteLuaFile */ = {
isa = PBXGroup;
children = (
);
path = WriteLuaFile;
sourceTree = "<group>";
};
BEEFEF71196ECCC000C80FF1 /* Matrix */ = {
isa = PBXGroup;
children = (
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment