Commit b1859008 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

Merge branch 'feature/docker' into 'master'

[docker] add Dockerfile

See merge request tools/frackit!182
parents 7fc92fd8 ede20481
Pipeline #2461 passed with stages
in 20 minutes and 52 seconds
default:
image: git.iws.uni-stuttgart.de:4567/tools/frackit/ubuntu18.04_occ7.3:latest
# base for merge requests that affect the core/tests
.testbeforemerge:
script: ./.ci_run_tests
only:
refs:
- merge_requests
except:
changes:
- "*.md"
- doc/*
# build pipeline for docu
builddoc:
script: ./.ci_build_doc
only:
refs:
- merge_requests
changes:
- doc/*
# noop pipeline for changes to markdown files
markdownedits:
script: echo "Only markdown files edited. Skipping pipelines."
only:
refs:
- merge_requests
changes:
- "*.md"
......@@ -2,8 +2,30 @@
echo "Compiling doxygen documentation"
# set default compiler settings
C_COMPILER=gcc
OCC_VERSION=7.3
COMPILER_VERSION=7
# maybe overwrite defaults
if [ "${CI_COMPILER}" ]; then C_COMPILER="${CI_COMPILER}"; fi
if [ "${CI_COMPILER_VERSION}" ]; then COMPILER_VERSION="${CI_COMPILER_VERSION}"; fi
if [ "${C_COMPILER}" == "gcc" ]; then CXX_COMPILER="g++";
elif [ "${C_COMPILER}" == "clang" ]; then CXX_COMPILER="clang++";
else
echo "Unsupported compiler specification. Aborting."
exit 1
fi
if [ "${CI_OCC_VERSION}" ]; then OCC_VERSION="${CI_OCC_VERSION}"; fi
OCC_INSTALL_DIR="/home/opencascade-${OCC_VERSION}/install"
# create build directory & configure
mkdir build && cd build && cmake ../
mkdir build && cd build
cmake -DCMAKE_C_COMPILER="${C_COMPILER}-${COMPILER_VERSION}" \
-DCMAKE_CXX_COMPILER="${CXX_COMPILER}-${COMPILER_VERSION}" \
-DOCC_INSTALL_DIR="${OCC_INSTALL_DIR}" ../
# build docu
make doc_doxygen
#!/bin/bash
# determine compiler to be used
if [ "${CI_COMPILER}" == "gcc" ]; then
CI_CXX_COMPILER="g++"
elif [ "${CI_COMPILER}" == "clang" ]; then
CI_CXX_COMPILER="clang++"
else
echo "Unsupported compiler specification. Aborting."
exit 1
fi
echo "Using the following C/C++ compilers:" \
"${CI_COMPILER}-${CI_COMPILER_VERSION} /" \
"${CI_CXX_COMPILER}-${CI_COMPILER_VERSION}"
# check input on occ version
if [ "${CI_OCC_VERSION}" ]; then
OCC_INSTALL_DIR="/home/opencascade-${CI_OCC_VERSION}/install"
else
echo "OpenCASCADE version must be specified via CI_OCC_VERSION"
exit 1
fi
echo "Using OpenCASCADE version ${CI_OCC_VERSION}"
# create build directory & configure
BUILD_DIR="build-${CI_COMPILER}-${CI_COMPILER_VERSION}-occ-${CI_OCC_VERSION}"
mkdir ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DCMAKE_C_COMPILER="${CI_COMPILER}-${CI_COMPILER_VERSION}" \
-DCMAKE_CXX_COMPILER="${CI_CXX_COMPILER}-${CI_COMPILER_VERSION}" \
-DOCC_INSTALL_DIR="${OCC_INSTALL_DIR}" ../
# make python bindings
make -j4 && make install_python
# build tests
make -j4 build_tests
#!/bin/bash
# check if gcc or clang is to be used
CI_CXX_COMPILER=""
if [ "${CI_COMPILER}"=="gcc" ]; then
CI_CXX_COMPILER="g++"
elif [ "${CI_COMPILER}"=="clang" ]; then
CI_CXX_COMPILER="clang++"
else
echo "Unsupported compiler. Aborting."
exit 1
fi
echo "Compiling all tests with ${CI_COMPILER}-${CI_COMPILER_VERSION} " \
"/ ${CI_CXX_COMPILER}-${CI_COMPILER_VERSION}"
# create build directory & configure
mkdir build && cd build && cmake -DCMAKE_C_COMPILER="${CI_COMPILER}-${CI_COMPILER_VERSION}" \
-DCMAKE_CXX_COMPILER="${CI_CXX_COMPILER}-${CI_COMPILER_VERSION}" ../
# make python bindings
make -j4 && make install_python
# build tests
make -j4 build_tests
# run them
ctest -j4 -V
include:
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
- local: .ci_base.yml
template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
# using OpenCascade 7.3
ubuntu18.04 gcc-7 occ7.3:
extends: .testbeforemerge
default:
image: git.iws.uni-stuttgart.de:4567/tools/frackit/ubuntu18.04:latest
stages:
- build
- test
.testrules:
rules:
- changes:
- "**/*.hh"
- "**/*.cc"
- "**/CMakeLists.txt"
- "**/*.cmake"
- "**/*.yml"
when: always
.build_tests:
extends: .testrules
stage: build
script: ./.ci_build_tests
artifacts:
expire_in: 30 minutes
when: on_success
.run_tests:
extends: .testrules
stage: test
script: ctest -j4 --no-tests=error --output-on-failure
###########################
# build pipeline for docu #
###########################
build_doc:
script: ./.ci_build_doc
rules:
- changes:
- "doc/*"
when: always
#####################################################
# build jobs for different compilers / occ versions #
#####################################################
build gcc-7 occ-7.3:
extends: .build_tests
variables:
CI_COMPILER: gcc
CI_COMPILER_VERSION: 7
CI_COMPILER_VERSION: "7"
CI_OCC_VERSION: "7.3"
artifacts:
paths:
- build-gcc-7-occ-7.3
ubuntu18.04 gcc-8 occ7.3:
extends: .testbeforemerge
build gcc-8 occ-7.5:
extends: .build_tests
variables:
CI_COMPILER: gcc
CI_COMPILER_VERSION: 8
CI_COMPILER_VERSION: "8"
CI_OCC_VERSION: "7.5"
artifacts:
paths:
- build-gcc-8-occ-7.5
ubuntu18.04 clang-6 occ7.3:
extends: .testbeforemerge
build clang-6 occ-7.3:
extends: .build_tests
variables:
CI_COMPILER: clang
CI_COMPILER_VERSION: 6
CI_COMPILER_VERSION: "6.0"
CI_OCC_VERSION: "7.3"
artifacts:
paths:
- build-clang-6.0-occ-7.3
build clang-7 occ-7.5:
extends: .build_tests
variables:
CI_COMPILER: clang
CI_COMPILER_VERSION: "7"
CI_OCC_VERSION: "7.5"
artifacts:
paths:
- build-clang-7-occ-7.5
####################################################
# test jobs for different compilers / occ versions #
####################################################
test gcc-7 occ-7.3:
extends: .run_tests
needs:
- job: build gcc-7 occ-7.3
artifacts: true
before_script:
- cd build-gcc-7-occ-7.3
test gcc-8 occ-7.5:
extends: .run_tests
needs:
- job: build gcc-8 occ-7.5
artifacts: true
before_script:
- cd build-gcc-8-occ-7.5
test clang-6 occ-7.3:
extends: .run_tests
needs:
- job: build clang-6 occ-7.3
artifacts: true
before_script:
- cd build-clang-6.0-occ-7.3
test clang-7 occ-7.5:
extends: .run_tests
needs:
- job: build clang-7 occ-7.5
artifacts: true
before_script:
- cd build-clang-7-occ-7.5
......@@ -120,7 +120,12 @@ implementations for all examples are also available in the respective example fo
Installation
============
Please note that the following requirements need to be installed:
Please note that a number of packages are required in order to install Frackit on your
system. However, you can also run Frackit inside a [docker container](https://www.docker.com/)
using the image provided in this repository. For more details, please have a look at
the description in [docker/README.md](https://git.iws.uni-stuttgart.de/tools/frackit/tree/master/docker/README.md).
For a manual installation, the following requirements need to be installed:
* OpenCASCADE (>= 7.3.0) (Note: Testing occurs with 7.3.0 and 7.5.0, issues have been experienced with 7.4.0)
* CMake (>3.0)
......
frackit_add_application(NAME example1
SOURCES example1.cc
LABELS example)
frackit_add_test(NAME example1
SOURCES example1.cc
LABELS example)
frackit_symlink_or_copy(FILES example1.py)
......
frackit_add_application(NAME example2
SOURCES example2.cc
LABELS example)
frackit_add_test(NAME example2
SOURCES example2.cc
LABELS example)
frackit_symlink_or_copy(FILES example2.py)
......
frackit_add_application(NAME example3
SOURCES example3.cc
COMPILE_DEFINITIONS BREPFILE="layers.brep"
LABELS example)
frackit_add_test(NAME example3
SOURCES example3.cc
COMPILE_DEFINITIONS BREPFILE="layers.brep"
LABELS example
CMD_ARGS 3)
frackit_symlink_or_copy(FILES example3.py layers.brep)
......
......@@ -159,9 +159,12 @@ int main(int argc, char** argv)
// Helper class for terminal output of the creation
// progress and definition of stop criterion etc
// Check if a value has been passed via the command line,
// otherwise use the defaults. This is used in the test suite
// to speed up testing time.
SamplingStatus status;
status.setTargetCount(diskSetId, 12); // we want 11 entities of orientation 1
status.setTargetCount(quadSetId, 16); // we want 13 entities of orientation 2
status.setTargetCount(diskSetId, (argc > 1 ? std::stoi(argv[1]) : 12)); // we want 11 entities of orientation 1
status.setTargetCount(quadSetId, (argc > 1 ? std::stoi(argv[1]) : 16)); // we want 13 entities of orientation 2
// The actual network generation loop
ctype containedNetworkArea = 0.0;
......
frackit_add_application(NAME example4
SOURCES example4.cc
LABELS example)
frackit_add_test(NAME example4
SOURCES example4.cc
LABELS example
COMMAND ./example4
CMD_ARGS 5)
frackit_symlink_or_copy(FILES example4.py)
......
......@@ -5,6 +5,7 @@
#include <vector>
#include <cmath>
#include <chrono>
#include <string>
// utility functions
#include <frackit/common/math.hh>
......@@ -198,7 +199,9 @@ int main(int argc, char** argv)
///////////////////////////
// 4. Network generation //
///////////////////////////
const std::size_t numTargetEntities = 75;
// allow passing number of entities via command line. This is used in the
// test suite in order to speed up testing time
const std::size_t numTargetEntities = argc > 1 ? std::stoi(argv[1]) : 75;
std::vector<TopoDS_Face> entitiesSet1; entitiesSet1.reserve(numTargetEntities);
std::vector<TopoDS_Face> entitiesSet2; entitiesSet2.reserve(numTargetEntities);
std::vector<TopoDS_Face> entitiesSet3; entitiesSet3.reserve(numTargetEntities);
......
install(FILES
FrackitApplicationMacros.cmake
FrackitMacros.cmake
FrackitTestMacros.cmake
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cmake/modules)
# includes all relevant macros
include(FrackitTestMacros)
include(FrackitApplicationMacros)
include(FrackitCopyOrSymlink)
# Dockerfile for building the basic requirements for Frackit, without OpenCascade
# Other dockerfiles handle the installation of OpenCascade using different versions
# see https://github.com/phusion/baseimage-docker for information on the base image
# It is Ubuntu LTS customized for better Docker compatibility
FROM phusion/baseimage:18.04-1.0.0
MAINTAINER dennis.glaeser@iws.uni-stuttgart.de
# run Ubuntu update as advised on https://github.com/phusion/baseimage-docker
RUN apt-get update \
&& apt-get upgrade -y -o Dpkg::Options::="--force-confold" \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install the basic dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
ca-certificates \
vim \
build-essential \
gcc-6 g++-6 gcc-7 g++-7 gcc-8 g++-8 \
clang-5.0 clang-6.0 clang-7 \
clang \
python3-dev \
python3-pip \
git \
pkg-config \
wget \
cmake \
gmsh \
paraview \
doxygen \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install setup tools & pytest for installation python bindings
RUN python3 -m pip install setuptools
RUN python3 -m pip install pytest
# install pybind11-2.6 for python bindings
WORKDIR /home
RUN git clone -b v2.6 https://github.com/pybind/pybind11.git
WORKDIR /home/pybind11
RUN mkdir build
WORKDIR /home/pybind11/build
RUN cmake ../ && make && make install
# extract OpenCascade 7.3 & 7.5 into container
# TODO: This expects the tarballs to present in the
# scope of the docker build and with the given
# file names. It seems that occ precents automatic
# retrieval of snapshots with wget or curl from their portal at
# http://git.dev.opencascade.org/gitweb/?p=occt.git;a=summary
# TODO: Moreover, the folder names should be deduced automatically and
# changed accordingly.
WORKDIR /home
COPY occ_7_3_p3.tar.gz .
RUN tar -xf occ_7_3_p3.tar.gz && rm *.tar.gz
RUN mv /home/occt-e1c1585 /home/opencascade-7.3
COPY occ_7_5_0.tar.gz .
RUN tar -xf occ_7_5_0.tar.gz && rm *.tar.gz
RUN mv /home/occt-628c021 /home/opencascade-7.5
# install both libraries
WORKDIR /home/opencascade-7.3/
RUN mkdir build
RUN mkdir install
WORKDIR /home/opencascade-7.3/build
RUN cmake -DBUILD_MODULE_ApplicationFramework=0 \
-DBUILD_MODULE_DataExchange=0 \
-DBUILD_MODULE_Draw=0 \
-DBUILD_MODULE_Visualization=0 \
-DINSTALL_DIR=/home/opencascade-7.3/install \
-DCMAKE_INSTALL_RPATH=/home/opencascade-7.3/install/lib \
../
RUN make
RUN make install
WORKDIR /home/opencascade-7.5/
RUN mkdir build
RUN mkdir install
WORKDIR /home/opencascade-7.5/build
RUN cmake -DBUILD_MODULE_ApplicationFramework=0 \
-DBUILD_MODULE_DataExchange=0 \
-DBUILD_MODULE_Draw=0 \
-DBUILD_MODULE_Visualization=0 \
-DINSTALL_DIR=/home/opencascade-7.5/install \
-DCMAKE_INSTALL_RPATH=/home/opencascade-7.5/install/lib \
../
RUN make
RUN make install
# define frackit user and group
RUN groupadd -r frackit && useradd -r -g frackit -m -d /frackit frackit
# copy convenience install/update script
WORKDIR /frackit
COPY install_or_update.sh .
RUN chmod +x install_or_update.sh
RUN chown frackit install_or_update.sh
# copy the permission helper script to set permissions for shared folder
COPY setpermissions.sh /etc/my_init.d/setpermissions.sh
RUN chmod +x /etc/my_init.d/setpermissions.sh
# switch to frackit user and define shared folder
USER frackit
VOLUME /home/frackit/shared
# switch back to root
USER root
# set entry point like advised https://github.com/phusion/baseimage-docker
ENTRYPOINT ["/sbin/my_init", "--", "/sbin/setuser", "frackit"]
# per default, start interactive shell
CMD ["/bin/bash","-i"]
# Run Frackit inside docker
If you have [docker](https://www.docker.com/) installed on your system, you can
use the image hosted in this repository to run Frackit inside a docker container
without the need to install anything on your system. Type
```sh
docker run -it git.iws.uni-stuttgart.de:4567/tools/frackit/ubuntu18.04:latest
```
to start a terminal inside the docker container interactively (`-it`). This will
bring you to the folder `/frackit` inside the container. Therein, you can find a
convenience script `install_or_update.sh`, which installs Frackit in-place
(or updates it in case you had run the script already before). The script also
builds the python bindings for you to use anywhere inside the container and it
precompiles all examples. To run the precomiled examples, for instance `example1`,
go to the respective folder in the build tree and run the example by typing
```sh
cd frackit/build/appl/example1
./example1
```
into the terminal.
## Using a shared folder
The docker container is set up for you to define a shared folder in `/frackit/shared`.
For example, let us define the folder `/home/username/tmp` on the host machine
to be shared with the container. To realize this, start the container with the
`-v` flag as follows:
```sh
docker run -it -v /home/username/tmp:/frackit/shared git.iws.uni-stuttgart.de:4567/tools/frackit/ubuntu18.04:latest
```
Any data that you now place within `/home/username/tmp` on the host machine will
be accessible, although read-only (!), from within the container inside the folder `/frackit/shared`.
In the sequel, it will be explained how to achieve read and write access to the data in the shared
folder from both the host machine and from within the container.
Upon startup, a helper script is executed that manages the permissions for the
shared folder in `/frackit/shared` inside the container. In order to setup the
shared folder such that you have read and write permission both from within the
container as well as from the host machine, define the environment variables
`HOST_UID` and `HOST_GID` by using the following command to startup the container:
```sh
docker run -it -v /home/username/tmp:/frackit/shared -e HOST_UID="$(id -u ${USER})" -e HOST_GID="$(id -g ${USER})" git.iws.uni-stuttgart.de:4567/tools/frackit/ubuntu18.04:latest
```
This will internally set the user and group ids of the frackit user inside the container
to those of the user of the host machine. In the above command, "$(id -u ${USER})" and
"$(id -g ${USER})" are Linux commands that are used to extract the ids of the user that is
starting the container on the host machine. If you know your ids you can also pass them
directly. In particular, you should substitute these if you are running the container
from Windows (execution from windows has not been tested yet).
#!/bin/bash
# Convenience script for users to install or update frackit.
# You can pass the opencascade version you would like to use,
# e.g., by calling ./install_or_update.sh -occ 7.3. Default is version 7.3.
OCC_VERSION="7.3"
if [ "$1" == "-occ" ]; then
OCC_VERSION="$2"
elif [ $# -gt 0 ]; then
echo "WARNING: Could not parse command line arguments. Falling back to defaults."
fi
OCC_INSTALL_DIR="/home/opencascade-${OCC_VERSION}/install"
if [ -d "${OCC_INSTALL_DIR}" ]; then
echo "Using OpenCASCADE version ${OCC_VERSION}."
else
echo "Could not find OpenCASCADE installation at ${OCC_INSTALL_DIR}."
echo "If you are trying to use a manually installed version, please adjust"
echo "the installation path in this script accordingly."
exit 1
fi
# if folder exists already, do not clone
if [ -d "$(pwd)/frackit" ]; then
cd frackit
else
git clone https://git.iws.uni-stuttgart.de/tools/frackit.git
cd frackit
fi
# enter build directory
if [ -d "build" ]; then
if git pull --rebase origin master; then
echo "Sucessfully updated master branch. If you are currently working"
echo "on another branch you should consider rebasing or switching to master."
else
echo "Could not update master branch. Do you have incompatible local changes?"
exit 1
fi
cd build
else
mkdir build
cd build
fi
echo ""
echo "######################"
echo "# Configuring project"
echo "######################"
echo ""
rm -rf CMakeFiles CMakeCache.txt
cmake -DCONFIG_FOR_DOCKER=1 -DOCC_INSTALL_DIR="${OCC_INSTALL_DIR}" ../
# install python bindings & precompile example applications
echo ""
echo "############################"
echo "# Installing python bindings"
echo "############################"
echo ""
make && make install_python
echo ""
echo "###################################"
echo "# Precompiling example applications"
echo "###################################"
echo ""
make build_example_applications
echo ""
echo "Frackit and the example applications have been installed successfully."
echo "To run the first example, go to /home/frackit/build/appl/example1"
echo "and type ./example1 or python example1.py to run it"