Skip to content

Commit

Permalink
Add BUILD_TAUDEMEXT option; Build image based on ghcr.io/lreis2415/ta…
Browse files Browse the repository at this point in the history
…udem_ext
  • Loading branch information
crazyzlj committed Jun 12, 2024
1 parent 20f22f5 commit 55b03d3
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 5 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# -DINSTALL_PREFIX=<path/to/install>
# -DLLVM_ROOT_DIR Specific the root directory of brew installed LLVM, e.g., /usr/local/opt/llvm
# -DSEIMS_DOC=1 means build SEIMS documentation based on doxygen
# -DBUILD_TAUDEMEXT=0 means do not build TauDEM_ext
#
# Routine testing platforms and compilers include:
# 1. Windows 10 with Visual Studio 2010/2013/2015, MSMPI-v8.1, GDAL-1.11.4
Expand All @@ -18,9 +19,9 @@
# 5. macOS 10.14.5 with Clang-10.0 with Xcode, OpenMPI-4.0.1, GDAL-2.4.2 (brew installed)
#
# Created and maintained by Liangjun Zhu (zlj@lreis.ac.cn)
# Latest updated: Apr 15, 2023
# Latest updated: Jun 12, 2024
#
# Copyright (C) 2013-2023 Lreis, IGSNRR, CAS, and NJNU
# Copyright (C) 2013-2024 Lreis, IGSNRR, CAS, and NJNU
# ----------------------------------------------------------------------------
### Disable in-source builds to prevent source tree corruption.
IF(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
Expand Down Expand Up @@ -72,6 +73,8 @@ option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
option(BUILD_WITH_STATIC_CRT "Build against dynamic CRT on windows." ON)
# Build documatation by doxygen
option(SEIMS_DOC "Build SEIMS documentation." OFF)
# Build TauDEM_ext or not
option(BUILD_TAUDEMEXT "Do not build TauDEM_ext" ON)

### Detect compiler and target platform architecture.
INCLUDE(Utils)
Expand Down Expand Up @@ -213,7 +216,6 @@ ENDIF()

### Add subdirectories.
ADD_SUBDIRECTORY(./seims)
# ADD_SUBDIRECTORY(./gui) # TODO
IF(SEIMS_DOC)
ADD_SUBDIRECTORY(./doc)
ENDIF()
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ARG INSTALL_DIR=/seims/dist
RUN cd /seims \
&& mkdir build \
&& cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DINSTALL_PREFIX=${INSTALL_DIR} \
&& make -j 8 \
&& make install -j 8 \
&& cd ..
Expand Down
68 changes: 68 additions & 0 deletions docker/Dockerfile.TauDEMext
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
##
#
# Copyright 2024 Liang-Jun Zhu <zlj@lreis.ac.cn>
#

# Use the latest master branch of TauDEM_ext image based on continuumio/miniconda3 as the build and test container, which is based on debian:12.5-slim
# https://github.com/ContinuumIO/docker-images/blob/main/miniconda3/debian/Dockerfile
# https://github.com/lreis2415/TauDEM_ext/pkgs/container/taudem_ext
FROM ghrc.io/lreis2415/taudem_ext:master-debian-miniconda as builder

LABEL maintainer="Liang-Jun Zhu <zlj@lreis.ac.cn>"

# Copy source directory
WORKDIR /seims
COPY CMakeLists.txt .
COPY cmake cmake
COPY seims seims

RUN apt-get update -q && \
apt-get install -q -y --no-install-recommends cmake make g++ \
gdal-bin openmpi-bin libgdal-dev libopenmpi-dev \
libmongoc-1.0-0 libmongoc-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG INSTALL_DIR=/seims/dist
RUN cd /seims \
&& mkdir build \
&& cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DINSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TAUDEMEXT=0 \
&& make -j 8 \
&& make install -j 8 \
&& cd ..

## Build final image
FROM ghrc.io/lreis2415/taudem_ext:master-debian-miniconda as runner

# Copy source directory
WORKDIR /seims
COPY seims seims
COPY docker docker

# Create new conda environment for pyseims
# Refers to https://pythonspeed.com/articles/activate-conda-dockerfile/
RUN conda env create -f ./seims/pyseims_env.yml

# Make RUN commands use the new environment:
SHELL ["conda", "run", "--no-capture-output", "-n", "pyseims", "/bin/bash", "-c"]

RUN apt-get update -q && \
apt-get install -q -y --no-install-recommends \
gdal-bin openmpi-bin libgomp1 tini libmongoc-1.0-0 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Order layers starting with less frequently varying ones
ARG INSTALL_DIR=/seims/dist
COPY --from=builder ${INSTALL_DIR}/bin/ /usr/local/bin/
COPY --from=builder ${INSTALL_DIR}/include/ /usr/local/include/
COPY --from=builder ${INSTALL_DIR}/lib/ /usr/local/lib/
COPY --from=builder ${INSTALL_DIR}/share/ /usr/local/share/

ENV OMPI_ALLOW_RUN_AS_ROOT=1
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1

COPY docker/docker-entrypoint.sh /
WORKDIR /seims/seims
ENTRYPOINT ["/usr/bin/tini", "--", "/docker-entrypoint.sh"]
4 changes: 3 additions & 1 deletion seims/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ ADD_SUBDIRECTORY(${FIELD_PARTITION} bin/field_partition)
ADD_SUBDIRECTORY(${GRID_LAYERING} bin/grid_layering)
ADD_SUBDIRECTORY(${IUH} bin/iuh)
ADD_SUBDIRECTORY(${METIS} bin/metis)
ADD_SUBDIRECTORY(${TAUDEM} bin/taudem)
IF(BUILD_TAUDEMEXT)
ADD_SUBDIRECTORY(${TAUDEM} bin/taudem)
ENDIF()
ADD_SUBDIRECTORY(${SEIMS_MAIN} bin/seims_project)

MESSAGE(STATUS "All SEIMS related compiled done!")

0 comments on commit 55b03d3

Please sign in to comment.