Commit c18ee24e authored by Vincent Delbar's avatar Vincent Delbar
Browse files

ENH: Allow sys deps, but SuperBuild all by default

parent 1a7bf92c
......@@ -3,11 +3,14 @@ ARG BASE_IMG=ubuntu:20.04
FROM $BASE_IMG
LABEL description="A base image with OTB and remote modules for the MORINGA processing chain, CIRAD/UMR TETIS"
# Build env
WORKDIR /tmp
ARG OTB_BRANCH=release-7.2
# System dependencies
# Controls USE_SYSTEM_* variables
ARG USE_SYSTEM_DEPS=false
# DEPS_INSTALL_PREFIX=/usr is required when USE_SYSTEM_DEPS=true
ARG DEPS_INSTALL_PREFIX=/opt/otb
# Install build dependencies
RUN apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y --no-install-recommends \
......@@ -33,83 +36,66 @@ RUN apt-get update \
vim \
wget \
zip \
# OTB CLI build requirements
&& apt-get install -y --no-install-recommends \
bison \
gdal-bin \
python3-gdal \
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-program-options-dev \
libboost-system-dev \
libboost-thread-dev \
libcurl4-gnutls-dev \
libexpat1-dev \
libfftw3-dev \
libgdal-dev \
libgeotiff-dev \
libgsl-dev \
libinsighttoolkit4-dev \
libkml-dev \
libmuparser-dev \
libmuparserx-dev \
libopencv-core-dev \
libopencv-ml-dev \
libopenthreads-dev \
libossim-dev \
libpng-dev \
libsvm-dev \
libtinyxml-dev \
zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
&& if $USE_SYSTEM_DEPS; then \
apt-get install -y --no-install-recommends \
bison \
gdal-bin \
python3-gdal \
libboost-date-time-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-program-options-dev \
libboost-system-dev \
libboost-thread-dev \
libcurl4-gnutls-dev \
libexpat1-dev \
libfftw3-dev \
libgdal-dev \
libgeotiff-dev \
libgsl-dev \
libinsighttoolkit4-dev \
libkml-dev \
libmuparser-dev \
libmuparserx-dev \
libopencv-core-dev \
libopencv-ml-dev \
libopenthreads-dev \
libossim-dev \
libpng-dev \
libsvm-dev \
libtinyxml-dev \
zlib1g-dev; fi \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# OTB branch to clone
ARG OTB_BRANCH=release-7.2
# Set USE_SYSTEM_* flags
COPY docker/build-flags-otb.txt .
RUN if ! $USE_SYSTEM_DEPS; then \
sed -i -r "s/-DUSE_SYSTEM_([A-Z0-9]*)=ON/-DUSE_SYSTEM_\1=OFF/" build-flags-otb.txt ; fi
# SuperBuild OTB with remote modules, no GUI
RUN git clone --single-branch -b $OTB_BRANCH "https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git" \
&& mkdir /tmp/SuperBuild-archives /tmp/build /opt/otb \
# SuperBuild OTB
RUN mkdir /tmp/SuperBuild-archives /tmp/build /opt/otb \
&& git clone --single-branch -b $OTB_BRANCH "https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git" \
&& if ! $USE_SYSTEM_DEPS; then \
cd SuperBuild-archives \
&& OTB_VERSION=$(head -n1 /tmp/otb/RELEASE_NOTES.txt | sed -r 's/OTB-v ([0-9].[0-9]).[0-9] -.*/\1/') \
&& curl -s "https://www.orfeo-toolbox.org/packages/archives/OTB/SuperBuild-archives-$OTB_VERSION.tar.bz2" \
| tar -xjv --exclude 'q*' --exclude '*gl*'; fi \
&& cd /tmp/build \
# All deps are available via apt-get (except SHARK)
&& OTB_CMAKE_FLAGS=$(cat "../build-flags-otb.txt") \
&& cmake /tmp/otb/SuperBuild \
-DCMAKE_BUILD_TYPE='Release' \
-DUSE_SYSTEM_BOOST=ON \
-DUSE_SYSTEM_CURL=ON \
-DUSE_SYSTEM_EXPAT=ON \
-DUSE_SYSTEM_FFTW=ON \
-DUSE_SYSTEM_FREETYPE=ON \
-DUSE_SYSTEM_GDAL=ON \
-DUSE_SYSTEM_GEOS=ON \
-DUSE_SYSTEM_GEOTIFF=ON \
-DUSE_SYSTEM_GSL=ON \
-DUSE_SYSTEM_ITK=ON \
-DUSE_SYSTEM_LIBKML=ON \
-DUSE_SYSTEM_LIBSVM=ON \
-DUSE_SYSTEM_MUPARSER=ON \
-DUSE_SYSTEM_MUPARSERX=ON \
-DUSE_SYSTEM_OPENCV=ON \
-DUSE_SYSTEM_OPENTHREADS=ON \
-DUSE_SYSTEM_OSSIM=ON \
-DUSE_SYSTEM_PNG=ON \
-DUSE_SYSTEM_SHARK=OFF \
-DUSE_SYSTEM_TINYXML=ON \
-DUSE_SYSTEM_ZLIB=ON \
-DUSE_SYSTEM_SWIG=ON \
-DOTB_USE_QT=OFF \
-DOTB_USE_OPENGL=OFF \
-DOTB_USE_GLUT=OFF \
-DOTB_USE_GLEW=OFF \
-DOTB_USE_GLFW=OFF \
$OTB_CMAKE_FLAGS \
-DCMAKE_BUILD_TYPE="Release" \
-DDOWNLOAD_LOCATION=/tmp/SuperBuild-archives \
-DCMAKE_INSTALL_PREFIX=/opt/otb \
&& make OTB_DEPENDS -j4 \
# Remote modules
&& make OTB_DEPENDS -j12 \
&& cd /tmp/otb/Modules/Remote \
&& rm -f otbGRM.remote.cmake \
&& git clone "https://gitlab.irstea.fr/remi.cresson/GRM.git" \
&& git clone "https://gitlab.irstea.fr/remi.cresson/LSGRM.git" \
&& git clone "https://gitlab.irstea.fr/raffaele.gaetano/otbVectorClassification.git" \
&& git clone "https://gitlab.irstea.fr/raffaele.gaetano/otbSelectiveHaralickTextures.git" \
# Build OTB and modules
&& cd /tmp/build/OTB/build \
&& cmake /tmp/otb \
-DModule_otbGRM=ON \
......@@ -123,13 +109,12 @@ RUN git clone --single-branch -b $OTB_BRANCH "https://gitlab.orfeo-toolbox.org/o
-DCMAKE_INSTALL_PREFIX=/opt/otb \
&& cd /tmp/build \
&& make -j8 \
# For a lightweight layer
&& rm -rf /tmp/SuperBuild-archives /tmp/otb* /tmp/build /root/.cache /opt/otb/bin/otbgui_*
&& rm -rf /tmp/* /root/.cache /opt/otb/bin/otbgui_*
# Persistent environment variables
ENV PATH=/opt/otb/bin:$PATH
ENV PYTHONPATH=/opt/otb/lib/python3/dist-packages:/opt/otb/lib/otb/python:$PYTHONPATH
ENV LD_LIBRARY_PATH=/opt/otb/lib:$LD_LIBRARY_PATH
ENV OTB_APPLICATION_PATH=/opt/otb/lib/otb/applications
ENV PROJ_LIB=/usr/share/proj
ENV GDAL_DATA=/usr/share/gdal
ENV PATH="/opt/otb/bin:$PATH"
ENV PYTHONPATH="/opt/otb/lib/python3/dist-packages:/opt/otb/lib/otb/python:$PYTHONPATH"
ENV LD_LIBRARY_PATH="/opt/otb/lib:$LD_LIBRARY_PATH"
ENV OTB_APPLICATION_PATH="/opt/otb/lib/otb/applications"
ENV PROJ_LIB="$DEPS_INSTALL_PREFIX/share/proj"
ENV GDAL_DATA="$DEPS_INSTALL_PREFIX/share/gdal"
ARG BASE_IMG=gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:latest
FROM $BASE_IMG
LABEL description="A container for the MORINGA processing chain, CIRAD/UMR TETIS"
LABEL maintainer="Raffaele GAETANO"
# PIP dependencies : rios, fmask
RUN pip3 install rios.core \
......
......@@ -102,16 +102,15 @@ cd moringa
docker login gitlab-registry.irstea.fr
# OTB base image, example with tag 7.2.0 (default value is release-7.2)
# It is located in subregistry gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base
docker build --build-arg OTB_BRANCH=7.2.0 -f docker/Dockerfile.base \
-t gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:focal-otb72 .
docker push gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:focal-otb72
# Tag 'moringa/base:latest' == default base image for the moringa build
docker tag gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:focal-otb72 \
# OTB base image, with default USE_SYSTEM_DEPS=false (build all dependencies from source)
docker build -f docker/Dockerfile.base \
-t gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:focal-otb72-superbuild .
docker push gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:focal-otb72-superbuild
# Tag 'moringa/base:latest' == default tag and default base image for the MORINGA build
docker tag gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:focal-otb72-superbuild \
gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:latest
# Default tag is "latest" (if not specified)
# Default pulled or pushed tag is "latest" (if not specified)
docker push gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base
# MORINGA build from the default 'moringa/base' image
......@@ -119,13 +118,22 @@ docker push gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base
#git checkout custom_branch
docker build -f docker/Dockerfile.moringa -t gitlab-registry.irstea.fr/raffaele.gaetano/moringa .
docker push gitlab-registry.irstea.fr/raffaele.gaetano/moringa:latest
# Keep tracks using tags
docker tag gitlab-registry.irstea.fr/raffaele.gaetano/moringa:latest gitlab-registry.irstea.fr/raffaele.gaetano/moringa:ubuntu20
docker push gitlab-registry.irstea.fr/raffaele.gaetano/moringa:ubuntu20
# Build base image using system deps (libs installed from apt repository)
docker build -f docker/Dockerfile.base \
--build-arg USE_SYSTEM_DEPS=true --build-arg DEPS_INSTALL_PREFIX=/usr \
-t gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:focal-otb72-sysdeps .
docker push gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:focal-otb72-sysdeps
# Build with custom ubuntu base image
docker build --build-arg BASE_IMG=ubuntu:18.04 -f docker/Dockerfile.base \
-t gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:bionic-otb72 .
-t gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:bionic-otb72-superbuild .
docker build -f docker/Dockerfile.moringa ---build-arg BASE_IMG=gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:bionic-otb72 \
-t gitlab-registry.irstea.fr/raffaele.gaetano/moringa:bionic .
docker build -f docker/Dockerfile.moringa --build-arg BASE_IMG=gitlab-registry.irstea.fr/raffaele.gaetano/moringa/base:bionic-otb72-superbuild \
-t gitlab-registry.irstea.fr/raffaele.gaetano/moringa:ubuntu18 .
```
### Fix volume ownership issue (required if host's UID > 1000)
......
-DUSE_SYSTEM_BOOST=ON
-DUSE_SYSTEM_CURL=ON
-DUSE_SYSTEM_EXPAT=ON
-DUSE_SYSTEM_FFTW=ON
-DUSE_SYSTEM_FREETYPE=ON
-DUSE_SYSTEM_GDAL=ON
-DUSE_SYSTEM_GEOS=ON
-DUSE_SYSTEM_GEOTIFF=ON
-DUSE_SYSTEM_GSL=ON
-DUSE_SYSTEM_ITK=ON
-DUSE_SYSTEM_LIBKML=ON
-DUSE_SYSTEM_LIBSVM=ON
-DUSE_SYSTEM_MUPARSER=ON
-DUSE_SYSTEM_MUPARSERX=ON
-DUSE_SYSTEM_OPENCV=ON
-DUSE_SYSTEM_OPENTHREADS=ON
-DUSE_SYSTEM_OSSIM=ON
-DUSE_SYSTEM_PNG=ON
-DUSE_SYSTEM_SHARK=OFF
-DUSE_SYSTEM_TINYXML=ON
-DUSE_SYSTEM_ZLIB=ON
-DOTB_USE_QT=OFF
-DOTB_USE_OPENGL=OFF
-DOTB_USE_GLUT=OFF
-DOTB_USE_GLEW=OFF
-DOTB_USE_GLFW=OFF
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