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

Feature/docker #27

Merged
merged 8 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 7 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
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:20.04

ARG build_with_dependencies_source=0
ARG sph_only_static_build=0

ENV TZ=Europe/Berlin
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get install -y \
apt-utils \
build-essential \
cmake \
libtbb-dev \
libboost-all-dev \
libsimbody-dev \
libsimbody3.6 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENV TBB_HOME=/usr/lib/x86_64-linux-gnu
ENV BOOST_HOME=/usr/lib/x86_64-linux-gnu
ENV SIMBODY_HOME=/usr

COPY ./ /home/SPHinXsys/
WORKDIR /home/SPHinXsys
RUN rm -rf build
RUN mkdir build && cd build && cmake .. -DBUILD_WITH_DEPENDENCIES_SOURCE=${build_with_dependencies_source} -DSPH_ONLY_STATIC_BUILD=${sph_only_static_build} && make -j$(nproc)
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,32 @@ You can find a installation instruction video: https://youtu.be/m0p1nybM4v4, and

Create your own application in the cases_user in the source folder simply by copying the entire folder of a similar test case and rename and modify application files

### Build with docler

Two docker files are provided:

1. Dockerfile: C++ default docker image (x86_64 ubuntu 20.04). Every libraries are installed using debian packages (Simbody is 3.6 instead of 3.7). The docker image size is smallest and suitable for docker hub or CI/CD.

command to build:

docker build . -t sphinxsys:latest

command to run test:

docker run sphinxsys:latest bash scripts/runTest.sh

2. dev.Dockerfile: development packages are all installed and development. This image is too big and can not be used for github testing. Only for local development purposes.

command to build:

docker build . -f dev.Dockerfile -t sphinxsys:dev


additional build arguement can be added to the end of the docker build command using the following syntax: --build-arg <TAG>=<VALUE>

build_with_dependencies_source=0 : default, builds with preprecompiled dependencies
build_with_dependencies_source=1 : builds dependencies together with Sphinxsys


### How to run gpuSPHinXsys cases on CUDA enabled GPUs?
The build process for GPU cases are identical to the CPU cases on all platforms, viz. Linux, Windows and Mac OSX.
Expand Down
55 changes: 28 additions & 27 deletions cmake/Dependency_free_settings.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
## Build with Simbody and/or oneTBB source code
set(BUILD_WITH_DEPENDENCIES 0)
## Only static build is used
set(SPH_ONLY_STATIC_BUILD 0)
option(BUILD_WITH_DEPENDENCIES_SOURCE "BUILD_WITH_DEPENDENCIES_SOURCE" 0)

if(BUILD_WITH_DEPENDENCIES)
## Static build
option(SPH_ONLY_STATIC_BUILD "SPH_ONLY_STATIC_BUILD" 0)
if(SPH_ONLY_STATIC_BUILD)
set(BUILD_SHARED_LIBS OFF)
message(STATUS "SPH_ONLY_STATIC_BUILD is set on")
endif(SPH_ONLY_STATIC_BUILD)

## Webassembly ##
if(NOT DEFINED WASM_BUILD)
set(WASM_BUILD 0)
endif(NOT DEFINED WASM_BUILD)

if(WASM_BUILD)
message(STATUS "WEBASSEMBLY IS BEING BUILT...")
set(BUILD_WITH_DEPENDENCIES_SOURCE 1)
message(WARNING "SPH_ONLY_STATIC_BUILD is forced on")
set(SPH_ONLY_STATIC_BUILD 1)
endif(WASM_BUILD)


if(BUILD_WITH_DEPENDENCIES_SOURCE)
message(STATUS "BUILD_WITH_DEPENDENCIES_SOURCE")
## Select which dependency source code is included
###### Simbody ######
# Simbody and clapack source code will be built with the project
Expand All @@ -23,37 +42,19 @@ if(BUILD_WITH_DEPENDENCIES)
add_definitions(-DBOOST_AVAILABLE)
set(BOOST_AVAILABLE 1)
endif()
###### Boost, only 3D ######
###### Webassembly ######
# this is for porting to javascript, do not change it, unless you're using the SPHinXsys_JS repo
# only works with static build
set(WASM_BUILD 0)
###### Webassembly ######
else(BUILD_WITH_DEPENDENCIES)

else(BUILD_WITH_DEPENDENCIES_SOURCE)
## Default option, doesn't build any dependencies
###### Do not change ######
set(BUILD_WITH_SIMBODY 0)
set(BUILD_WITH_ONETBB 0)
add_definitions(-DBOOST_AVAILABLE)
set(BOOST_AVAILABLE 1)
set(WASM_BUILD 0)
###### Do not change ######
endif(BUILD_WITH_DEPENDENCIES)
endif(BUILD_WITH_DEPENDENCIES_SOURCE)

###### WASM_BUILD ######
if(WASM_BUILD)
set(SPH_ONLY_STATIC_BUILD 0)
endif(WASM_BUILD)
###### SPH_ONLY_STATIC_BUILD ######

###### SPH_ONLY_STATIC_BUILD ######
if(SPH_ONLY_STATIC_BUILD)
set(BUILD_SHARED_LIBS OFF)
endif(SPH_ONLY_STATIC_BUILD)
###### SPH_ONLY_STATIC_BUILD ######

###### Simbody ######
if(BUILD_WITH_SIMBODY)
# if(BUILD_WITH_SIMBODY)
include_directories(${PLATFORM_INCLUDE_DIRECTORIES})
set(SIMBODY_MAJOR_VERSION 3)
set(SIMBODY_MINOR_VERSION 7)
Expand Down Expand Up @@ -92,5 +93,5 @@ if(BUILD_WITH_SIMBODY)

add_definitions(-DBUILD_VISUALIZER=off)
set(CMAKE_C_FLAGS "-DINTEGER_STAR_8")
endif(BUILD_WITH_SIMBODY)
# endif(BUILD_WITH_SIMBODY)
###### Simbody ######
4 changes: 2 additions & 2 deletions cmake/FindSIMBODY.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ if(NOT BUILD_WITH_SIMBODY)

find_library(Simbody_LIB_DIR_TEMP
NAMES ${Simbody_LIBRARY_LIST}
PATHS ${Simbody_ROOT_DIR}/lib ${Simbody_ROOT_DIR}/lib64
PATHS ${Simbody_ROOT_DIR}/lib ${Simbody_ROOT_DIR}/lib64 ${Simbody_ROOT_DIR}/lib/x86_64-linux-gnu
NO_DEFAULT_PATH)

get_filename_component(Simbody_LIB_DIR ${Simbody_LIB_DIR_TEMP} DIRECTORY)
get_filename_component(Simbody_LIB_DIR ${Simbody_LIB_DIR_TEMP} DIRECTORY)

set(Simbody_LAPACK_LIBRARY_LIST )
set(Simbody_EXTRA_LIBRARY_LIST )
Expand Down
51 changes: 51 additions & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM ubuntu:20.04

ARG build_with_dependencies_source=0
ARG sph_only_static_build=0
ARG was_build=0
ARG build_with_visualization=off

ENV TZ=Europe/Berlin
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get install -y \
apt-utils \
build-essential \
cmake \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN if [ "$build_with_visualization" = on ] ; then cd /home \
&& apt-get update && apt-get install -y \
libglu1-mesa-dev freeglut3-dev mesa-common-dev libxi-dev libxmu-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*; fi

RUN if [ "$build_with_dependencies_source" = 0 ] ; then cd /home \
&& apt-get update && apt-get install -y \
libtbb-dev \
libboost-all-dev \
liblapack-dev \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& wget https://github.com/simbody/simbody/archive/Simbody-3.7.tar.gz \
&& tar xvzf Simbody-3.7.tar.gz \
&& rm Simbody-3.7.tar.gz \
&& mkdir /home/simbody-build && mkdir /home/simbody \
&& cd /home/simbody-build \
&& cmake /home/simbody-Simbody-3.7 -DCMAKE_INSTALL_PREFIX=/home/simbody -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_VISUALIZER=${build_with_visualization} -DBUILD_STATIC_LIBRARIES=on \
&& make -j$(nproc) \
# && ctest -j$(nproc) \
&& make -j$(nproc) install; fi

ENV TBB_HOME=/usr/lib/x86_64-linux-gnu
ENV BOOST_HOME=/usr/lib/x86_64-linux-gnu
ENV SIMBODY_HOME=/home/simbody
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SIMBODY_HOME/lib
ENV CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SIMBODY_HOME/include

COPY ./ /home/SPHinXsys/
WORKDIR /home/SPHinXsys
RUN rm -rf build
RUN mkdir build && cd build && cmake .. -DWASM_BUILD=${was_build} -DBUILD_WITH_DEPENDENCIES_SOURCE=${build_with_dependencies_source} -DSPH_ONLY_STATIC_BUILD=${sph_only_static_build} && make -j$(nproc)
2 changes: 2 additions & 0 deletions scripts/runTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd build
ctest