From a207a8f24847b38f753972322ef86d799c3df4ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gilles?= <sebastien.gilles@inria.fr>
Date: Fri, 14 May 2021 18:03:31 +0200
Subject: [PATCH] Move and update the Dockerfile which provides the basis for
 the notebook related to third party warnings. This notebook is also added to
 CI.

---
 .gitlab-ci.yml                                | 15 ++++++-
 .../4b-Demo/1-ProblematicCase/CMakeLists.txt  |  6 +--
 .../4b-Demo/2-FixByBuildSystem/CMakeLists.txt |  6 +--
 .../3-FixByPragmas-clang/CMakeLists.txt       |  6 +--
 .../3-FixByPragmas-clang/simple_boost.cpp     |  1 +
 .../4-FixByPragmas-clang-gcc/CMakeLists.txt   |  6 +--
 .../4-FixByPragmas-clang-gcc/simple_boost.cpp |  1 +
 .../5-FixByPragmas-common/CMakeLists.txt      |  6 +--
 .../clean_boost_filesystem.hpp                |  2 +
 6-InRealEnvironment/4b-Demo/Dockerfile        | 24 -----------
 6-InRealEnvironment/4b-Demo/README.md         | 42 ++-----------------
 docker/Dockerfile.boost                       | 26 ++++++++++++
 docker/README.md                              |  2 +-
 13 files changed, 63 insertions(+), 80 deletions(-)
 delete mode 100644 6-InRealEnvironment/4b-Demo/Dockerfile
 create mode 100644 docker/Dockerfile.boost

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8842d5e..0bf3129 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -41,4 +41,17 @@ build_fedora:
         - docker build -f docker/Dockerfile_full -t $CI_REGISTRY/$CI_PROJECT_PATH/fedora_for_tp:${TAG} -t $CI_REGISTRY/$CI_PROJECT_PATH/fedora_for_tp:latest .
         - docker container prune
         - docker push $CI_REGISTRY/$CI_PROJECT_PATH/fedora_for_tp:${TAG}
-        - if [ "${UPDATE_LATEST_TAG}" == "True" ]; then docker push $CI_REGISTRY/$CI_PROJECT_PATH/fedora_for_tp:latest; fi        
\ No newline at end of file
+        - if [ "${UPDATE_LATEST_TAG}" == "True" ]; then docker push $CI_REGISTRY/$CI_PROJECT_PATH/fedora_for_tp:latest; fi        
+
+build_boost:
+    stage: build
+    retry: 2
+    only:
+        - web
+    script:
+        - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+        # Latest is always generated but not pushed if ${UPDATE_LATEST_TAG} is not "True"
+        - docker build -f docker/Dockerfile_full -t $CI_REGISTRY/$CI_PROJECT_PATH/with_boost:${TAG} -t $CI_REGISTRY/$CI_PROJECT_PATH/with_boost:latest .
+        - docker container prune
+        - docker push $CI_REGISTRY/$CI_PROJECT_PATH/with_boost:${TAG}
+        - if [ "${UPDATE_LATEST_TAG}" == "True" ]; then docker push $CI_REGISTRY/$CI_PROJECT_PATH/with_boost:latest; fi           
\ No newline at end of file
diff --git a/6-InRealEnvironment/4b-Demo/1-ProblematicCase/CMakeLists.txt b/6-InRealEnvironment/4b-Demo/1-ProblematicCase/CMakeLists.txt
index 3793468..cbc4757 100644
--- a/6-InRealEnvironment/4b-Demo/1-ProblematicCase/CMakeLists.txt
+++ b/6-InRealEnvironment/4b-Demo/1-ProblematicCase/CMakeLists.txt
@@ -28,8 +28,8 @@ add_cxx_compiler_flag("-Wsign-conversion") # a triggered warning in gcc (-Wall -
 add_executable(simple_boost simple_boost.cpp)
 
 # Not portable at all but not the point here!
-target_include_directories(simple_boost PUBLIC "/Codes/ThirdParty/opt/include")
+target_include_directories(simple_boost PUBLIC "/opt/include")
 
 target_link_libraries(simple_boost
-                      /Codes/ThirdParty/opt/lib/libboost_filesystem.a
-                      /Codes/ThirdParty/opt/lib/libboost_system.a)
\ No newline at end of file
+                      /opt/lib/libboost_filesystem.a
+                      /opt/lib/libboost_system.a)
\ No newline at end of file
diff --git a/6-InRealEnvironment/4b-Demo/2-FixByBuildSystem/CMakeLists.txt b/6-InRealEnvironment/4b-Demo/2-FixByBuildSystem/CMakeLists.txt
index 4e2f7aa..58cf778 100644
--- a/6-InRealEnvironment/4b-Demo/2-FixByBuildSystem/CMakeLists.txt
+++ b/6-InRealEnvironment/4b-Demo/2-FixByBuildSystem/CMakeLists.txt
@@ -29,8 +29,8 @@ add_cxx_compiler_flag("-Wsign-conversion") # a triggered warning in gcc (-Wall -
 add_executable(simple_boost simple_boost.cpp)
 
 # Not portable at all but not the point here!
-target_include_directories(simple_boost SYSTEM PUBLIC "/Codes/ThirdParty/opt/include")
+target_include_directories(simple_boost SYSTEM PUBLIC "/opt/include")
 
 target_link_libraries(simple_boost
-                      /Codes/ThirdParty/opt/lib/libboost_filesystem.a
-                      /Codes/ThirdParty/opt/lib/libboost_system.a)
\ No newline at end of file
+                      /opt/lib/libboost_filesystem.a
+                      /opt/lib/libboost_system.a)
\ No newline at end of file
diff --git a/6-InRealEnvironment/4b-Demo/3-FixByPragmas-clang/CMakeLists.txt b/6-InRealEnvironment/4b-Demo/3-FixByPragmas-clang/CMakeLists.txt
index 0fd6382..b598872 100644
--- a/6-InRealEnvironment/4b-Demo/3-FixByPragmas-clang/CMakeLists.txt
+++ b/6-InRealEnvironment/4b-Demo/3-FixByPragmas-clang/CMakeLists.txt
@@ -28,8 +28,8 @@ add_cxx_compiler_flag("-Wsign-conversion") # a triggered warning in gcc (-Wall -
 add_executable(simple_boost simple_boost.cpp)
 
 # Not portable at all but not the point here!
-target_include_directories(simple_boost PUBLIC "/Codes/ThirdParty/opt/include")
+target_include_directories(simple_boost PUBLIC "/opt/include")
 
 target_link_libraries(simple_boost
-                      /Codes/ThirdParty/opt/lib/libboost_filesystem.a
-                      /Codes/ThirdParty/opt/lib/libboost_system.a)
\ No newline at end of file
+                      /opt/lib/libboost_filesystem.a
+                      /opt/lib/libboost_system.a)
\ No newline at end of file
diff --git a/6-InRealEnvironment/4b-Demo/3-FixByPragmas-clang/simple_boost.cpp b/6-InRealEnvironment/4b-Demo/3-FixByPragmas-clang/simple_boost.cpp
index 61ff100..563392d 100644
--- a/6-InRealEnvironment/4b-Demo/3-FixByPragmas-clang/simple_boost.cpp
+++ b/6-InRealEnvironment/4b-Demo/3-FixByPragmas-clang/simple_boost.cpp
@@ -22,6 +22,7 @@
 #pragma clang diagnostic ignored "-Wsuggest-override" // added in 2021!
 #pragma clang diagnostic ignored "-Wsuggest-destructor-override" // added in 2021!
 #pragma clang diagnostic ignored "-Wc11-extensions" // added in 2021!
+#pragma clang diagnostic ignored "-Winconsistent-missing-destructor-override"  // added in 2021!
 
 #include "boost/exception/diagnostic_information.hpp"
 #include "boost/filesystem.hpp"
diff --git a/6-InRealEnvironment/4b-Demo/4-FixByPragmas-clang-gcc/CMakeLists.txt b/6-InRealEnvironment/4b-Demo/4-FixByPragmas-clang-gcc/CMakeLists.txt
index 0fd6382..b598872 100644
--- a/6-InRealEnvironment/4b-Demo/4-FixByPragmas-clang-gcc/CMakeLists.txt
+++ b/6-InRealEnvironment/4b-Demo/4-FixByPragmas-clang-gcc/CMakeLists.txt
@@ -28,8 +28,8 @@ add_cxx_compiler_flag("-Wsign-conversion") # a triggered warning in gcc (-Wall -
 add_executable(simple_boost simple_boost.cpp)
 
 # Not portable at all but not the point here!
-target_include_directories(simple_boost PUBLIC "/Codes/ThirdParty/opt/include")
+target_include_directories(simple_boost PUBLIC "/opt/include")
 
 target_link_libraries(simple_boost
-                      /Codes/ThirdParty/opt/lib/libboost_filesystem.a
-                      /Codes/ThirdParty/opt/lib/libboost_system.a)
\ No newline at end of file
+                      /opt/lib/libboost_filesystem.a
+                      /opt/lib/libboost_system.a)
\ No newline at end of file
diff --git a/6-InRealEnvironment/4b-Demo/4-FixByPragmas-clang-gcc/simple_boost.cpp b/6-InRealEnvironment/4b-Demo/4-FixByPragmas-clang-gcc/simple_boost.cpp
index 6c352fc..ac26d6e 100644
--- a/6-InRealEnvironment/4b-Demo/4-FixByPragmas-clang-gcc/simple_boost.cpp
+++ b/6-InRealEnvironment/4b-Demo/4-FixByPragmas-clang-gcc/simple_boost.cpp
@@ -23,6 +23,7 @@
 #pragma clang diagnostic ignored "-Wsuggest-override" // added in 2021!
 #pragma clang diagnostic ignored "-Wsuggest-destructor-override" // added in 2021!
 #pragma clang diagnostic ignored "-Wc11-extensions" // added in 2021!
+#pragma clang diagnostic ignored "-Winconsistent-missing-destructor-override"  // added in 2021!
 
 #include "boost/exception/diagnostic_information.hpp"
 #include "boost/filesystem.hpp"
diff --git a/6-InRealEnvironment/4b-Demo/5-FixByPragmas-common/CMakeLists.txt b/6-InRealEnvironment/4b-Demo/5-FixByPragmas-common/CMakeLists.txt
index 0fd6382..b598872 100644
--- a/6-InRealEnvironment/4b-Demo/5-FixByPragmas-common/CMakeLists.txt
+++ b/6-InRealEnvironment/4b-Demo/5-FixByPragmas-common/CMakeLists.txt
@@ -28,8 +28,8 @@ add_cxx_compiler_flag("-Wsign-conversion") # a triggered warning in gcc (-Wall -
 add_executable(simple_boost simple_boost.cpp)
 
 # Not portable at all but not the point here!
-target_include_directories(simple_boost PUBLIC "/Codes/ThirdParty/opt/include")
+target_include_directories(simple_boost PUBLIC "/opt/include")
 
 target_link_libraries(simple_boost
-                      /Codes/ThirdParty/opt/lib/libboost_filesystem.a
-                      /Codes/ThirdParty/opt/lib/libboost_system.a)
\ No newline at end of file
+                      /opt/lib/libboost_filesystem.a
+                      /opt/lib/libboost_system.a)
\ No newline at end of file
diff --git a/6-InRealEnvironment/4b-Demo/5-FixByPragmas-common/clean_boost_filesystem.hpp b/6-InRealEnvironment/4b-Demo/5-FixByPragmas-common/clean_boost_filesystem.hpp
index e06a4fe..1c5e0ba 100644
--- a/6-InRealEnvironment/4b-Demo/5-FixByPragmas-common/clean_boost_filesystem.hpp
+++ b/6-InRealEnvironment/4b-Demo/5-FixByPragmas-common/clean_boost_filesystem.hpp
@@ -26,6 +26,8 @@ PRAGMA_DIAGNOSTIC(ignored "-Wnon-virtual-dtor")
     PRAGMA_DIAGNOSTIC(ignored "-Wc++98-compat")
     PRAGMA_DIAGNOSTIC(ignored "-Wc++98-compat-pedantic")
     PRAGMA_DIAGNOSTIC(ignored "-Wexit-time-destructors")
+    PRAGMA_DIAGNOSTIC(ignored "-Winconsistent-missing-destructor-override")
+    PRAGMA_DIAGNOSTIC(ignored "-Wsuggest-destructor-override")
 #endif // __clang__
 
 #include "boost/exception/diagnostic_information.hpp"
diff --git a/6-InRealEnvironment/4b-Demo/Dockerfile b/6-InRealEnvironment/4b-Demo/Dockerfile
deleted file mode 100644
index ec188e2..0000000
--- a/6-InRealEnvironment/4b-Demo/Dockerfile
+++ /dev/null
@@ -1,24 +0,0 @@
-# See Config /Dockerfile at the root of the project to generate this base image.
-FROM formation_cpp_docker_base 
-LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
-
-RUN (dnf update -y && dnf upgrade -y -q)
-
-RUN dnf install -y wget && dnf clean packages
-
-RUN mkdir -p Codes/ThirdPartyWarning && mkdir -p Codes/ThirdParty
-
-WORKDIR Codes/ThirdParty
-
-RUN wget https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.gz \
- && tar xzf boost_1_72_0.tar.gz \
- && rm -f boost_1_72_0.tar.gz
- 
-WORKDIR boost_1_72_0
-
-RUN ./bootstrap.sh cxxstd=14,17 --prefix=../opt --with-toolset=clang --with-libraries=filesystem,system
-RUN ./b2 install link=static toolset=clang variant=debug
-
-WORKDIR /Codes/ThirdPartyWarning 
-
-ENTRYPOINT ["zsh"]
\ No newline at end of file
diff --git a/6-InRealEnvironment/4b-Demo/README.md b/6-InRealEnvironment/4b-Demo/README.md
index e2a6670..c976b3e 100644
--- a/6-InRealEnvironment/4b-Demo/README.md
+++ b/6-InRealEnvironment/4b-Demo/README.md
@@ -1,49 +1,13 @@
 # How to use Docker for this example?
 
-First of all, make sure [Docker](https://www.docker.com/) is properly installed and running.
+The image is based on Fedora and is created through this [Dockerfile](../docker/Dockerfile.boost). 
 
-## Getting the image
-
-Then to get the relevant image you may either:
-
-### Build the image from the provided Dockerfile
-
-Make sure to have first built the image in Config directory (at the root of the project).
-
-Then type in a terminal:
-
-````
-docker build -t demo_third_party_warning .
-````
-
-This may take few minutes.
-
-### Or fetching it from the gitlab registry
-
-Type in a terminal (provided you have an account on the [Inria gitlab](https://gitlab.inria.fr) - if not you may create one easily):
+To run it type:
 
 ````
-docker login registry.gitlab.inria.fr
-docker pull registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/demo_third_party_warning:latest
+docker run -it -v $PWD:/home/formation/gettingstartedwithmoderncpp --cap-drop=all registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/with_boost:latest
 ````
 
-## Running the image
-
-Go in the _Docker/ThirdPartyWarning_ folder and type:
-
-````
-docker run -v $PWD:/Codes/ThirdPartyWarning --cap-drop=all -it demo_third_party_warning
-````
-
-For those of you not familiar with Docker:
-
-* `-v` creates a mapping between local folder and the /Codes/ThirdPartyWarning folder in the container; this enables you to edit the file from your comfy environment and see the file edited this way in the Docker container.
-* `--cap-drop=all` is a safety when you're running a Docker image not built by yourself: you're essentially blocking the few remaining operations that might impact your own environment that Docker lets by default open with the run command.
-* `-it` tells we want an interactive session: your terminal session will place you inside the container (here a Fedora environment).
-
-`third_party_warning` is a Docker **image**; the instantiation of this image obtained after the run command is a **container**.
-
-
 # Step by step: illustrating the issue
 
 After run, the container is opened and you are in a folder (inside the container) named `/Codes/ThirdPartyWarning`.
diff --git a/docker/Dockerfile.boost b/docker/Dockerfile.boost
new file mode 100644
index 0000000..a23b04a
--- /dev/null
+++ b/docker/Dockerfile.boost
@@ -0,0 +1,26 @@
+FROM fedora:latest
+LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
+
+RUN (dnf update -y && dnf upgrade -y -q)
+
+RUN dnf install -y git cmake clang gcc gcc-c++ ninja-build which hostname make && dnf clean packages
+# wget is kept separated as the previous line is in commin with Dockerfile.fedora: so cache may be used if both are built on the same machine.
+RUN dnf install -y wget && dnf clean packages
+
+RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz \
+ && tar xzf boost_1_76_0.tar.gz \
+ && rm -f boost_1_76_0.tar.gz
+
+WORKDIR boost_1_76_0
+
+RUN ./bootstrap.sh cxxstd=14,17 --prefix=../opt --with-toolset=clang --with-libraries=filesystem,system
+RUN ./b2 install link=static toolset=clang variant=debug
+
+# Create non root user
+ENV USER "formation"
+RUN useradd --create-home ${USER}
+USER ${USER}
+
+WORKDIR /home/${USER}/gettingstartedwithmoderncpp
+
+
diff --git a/docker/README.md b/docker/README.md
index d989730..61dbfe4 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -11,4 +11,4 @@ There are several Dockerfiles here:
 - [Dockerfile], which creates an image with a Conda environment to run properly Xeus-cling.
 - [Dockerfile-full], which creates an image with a Conda environment to run properly Xeus-cling and installs as well local compilers so that they may be invoked from the notebooks (for the 6-InRealEnvironment part).
 - [Dockerfile.fedora] which provides an environment with both clang and gcc installed. This notebook is not intended to run the notebooks but may be used to run the TPs.
-
+- [Dockerfile.boost] is used along with [the notebook about third party warnings](../6-InRealEnvironment/4-ThirdParty.ipynb).
-- 
GitLab