From b1770bc53869ff072c9843860a63a3429b73769c Mon Sep 17 00:00:00 2001 From: Raffaele Gaetano <raffaele.gaetano@cirad.fr> Date: Wed, 7 Jun 2023 14:19:54 +0200 Subject: [PATCH] ENH: new env setup and first working dockerfile. --- TimeSeries/s2planetary.py | 2 +- docker/{dockerfile.otb => dockerfile} | 38 ++++++++++++++++++--------- docker/dockerfile.moringa | 0 3 files changed, 26 insertions(+), 14 deletions(-) rename docker/{dockerfile.otb => dockerfile} (83%) delete mode 100644 docker/dockerfile.moringa diff --git a/TimeSeries/s2planetary.py b/TimeSeries/s2planetary.py index 800a80a..a0de403 100644 --- a/TimeSeries/s2planetary.py +++ b/TimeSeries/s2planetary.py @@ -7,7 +7,7 @@ import rasterio import rasterio.mask from osgeo import ogr from pyproj import Transformer as T -from shapely import Polygon +from shapely.geometry import Polygon import tqdm def fetch(shp, dt, output_fld, band_list=None): diff --git a/docker/dockerfile.otb b/docker/dockerfile similarity index 83% rename from docker/dockerfile.otb rename to docker/dockerfile index 36ce85b..cb18502 100644 --- a/docker/dockerfile.otb +++ b/docker/dockerfile @@ -1,12 +1,11 @@ ARG BASE_IMG=ubuntu:20.04 # Base image can be either focal (20.04) or bionic (18.04) and descendants FROM $BASE_IMG -LABEL description="A base image with OTB and remote modules for the MORINGAv2 platform, CIRAD/UMR TETIS" +LABEL description="An image for the MORINGAv2 platform including a specific OTB build, CIRAD/UMR TETIS" +LABEL maintainer="Raffaele GAETANO" WORKDIR /tmp -ARG DEPS_INSTALL_PREFIX=/opt/otb - # Install build dependencies RUN apt-get update \ && export DEBIAN_FRONTEND=noninteractive \ @@ -47,18 +46,16 @@ RUN mkdir /tmp/SuperBuild-archives /tmp/build /opt/otb \ && 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*' - -RUN cd /tmp/build \ + | tar -xjv --exclude 'q*' --exclude '*gl*' \ + && cd /tmp/build \ && OTB_CMAKE_FLAGS=$(cat "../build-flags-otb.txt") \ && cmake /tmp/otb/SuperBuild \ $OTB_CMAKE_FLAGS \ -DCMAKE_BUILD_TYPE="Release" \ -DDOWNLOAD_LOCATION=/tmp/SuperBuild-archives \ -DCMAKE_INSTALL_PREFIX=/opt/otb \ - && make OTB_DEPENDS -j20 - -RUN cd /tmp/otb/Modules/Remote \ + && make OTB_DEPENDS -j7 \ + && cd /tmp/otb/Modules/Remote \ && rm -f otbGRM.remote.cmake \ && git clone "https://gitlab.irstea.fr/remi.cresson/GRM.git" \ && git clone -b disassembled "https://gitlab.irstea.fr/remi.cresson/LSGRM.git" \ @@ -89,12 +86,11 @@ RUN cd /tmp/otb/Modules/Remote \ -DModule_SertitObject=OFF \ -DOTB_WRAP_PYTHON=ON \ -DPYTHON_EXECUTABLE=/usr/bin/python3 \ - -DCMAKE_INSTALL_PREFIX=/opt/otb - -RUN sed -i 's/SetDocName/\/\/SetDocName/g' /tmp/otb/Modules/Remote/OTBPhenology/app/otbSigmoFitting.cxx \ + -DCMAKE_INSTALL_PREFIX=/opt/otb \ + && sed -i 's/SetDocName/\/\/SetDocName/g' /tmp/otb/Modules/Remote/OTBPhenology/app/otbSigmoFitting.cxx \ && sed -i 's/SetDocName/\/\/SetDocName/g' /tmp/otb/Modules/Remote/otb-slic/app/otbSLIC.cxx \ && cd /tmp/build \ - && make -j20 \ + && make -j7 \ && rm -rf /tmp/* /root/.cache /opt/otb/bin/otbgui_* # Persistent environment variables @@ -104,3 +100,19 @@ 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" + +RUN useradd -s /bin/bash -m ubuntu +USER ubuntu +WORKDIR /home/ubuntu + +RUN pip install gdal==3.4.2 \ + rasterio \ + geopandas \ + scikit-learn \ + scikit-image \ + psutil \ + planetary_computer \ + theia_picker + +RUN mkdir moringav2 +COPY --chown=ubuntu . /home/ubuntu/moringav2 \ No newline at end of file diff --git a/docker/dockerfile.moringa b/docker/dockerfile.moringa deleted file mode 100644 index e69de29..0000000 -- GitLab