From e419e6bbb262a0b0181a3eb7703e9dc766d49572 Mon Sep 17 00:00:00 2001
From: Sujen Shah <sujen.shah@jpl.nasa.gov>
Date: Tue, 6 Aug 2024 11:15:01 +0000
Subject: [PATCH] Create docker image for custom isce2 build

---
 .gitlab-ci.yml                   | 33 ++++++++++++++++++++++++++++++++
 configuration/sconsConfigFile.py |  2 +-
 infiles_dps/dockerfile           | 19 ++++++++++++++++++
 infiles_dps/install.sh           | 11 +++++++++++
 4 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 infiles_dps/dockerfile
 create mode 100644 infiles_dps/install.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..141430e
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,33 @@
+# This file is a template, and might need editing before it works on your project.
+# To contribute improvements to CI/CD templates, please follow the Development guide at:
+# https://docs.gitlab.com/ee/development/cicd/templates.html
+# This specific template is located at:
+# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml
+
+# Build a Docker image with CI/CD and push to the GitLab registry.
+# Docker-in-Docker documentation: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
+#
+# This template uses one generic job with conditional builds
+# for the default branch and all other (MR) branches.
+
+docker-build:
+  # Use the official docker image.
+  image: docker:latest
+  stage: build
+  services:
+    - docker:dind
+  before_script:
+    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
+  # Default branch leaves tag empty (= latest tag)
+  # All other branches are tagged with the escaped branch name (commit ref slug)
+  script:
+    - tag="$CI_COMMIT_SHA"
+    - docker build --pull -t "${CI_REGISTRY_IMAGE}:${tag}" -f infiles_dps/dockerfile .
+    - docker push "${CI_REGISTRY_IMAGE}:${tag}"
+  # Run this job in a branch where a Dockerfile exists
+  rules:
+    - if: $CI_COMMIT_BRANCH
+      exists:
+        - infiles_dps/dockerfile
+  tags:
+    - shell
diff --git a/configuration/sconsConfigFile.py b/configuration/sconsConfigFile.py
index 86c2d1f..6d9eb8c 100644
--- a/configuration/sconsConfigFile.py
+++ b/configuration/sconsConfigFile.py
@@ -35,7 +35,7 @@ import sys
 
 COMPILER_OPTIONS ={'COMPILER_OPTIMIZATION':'-O2','COMPILER_WARNING':'-Wall'}
 LINKER_OPTIONS ={'LINKFLAGS':'-fopenmp'} # some systems don't need it, but ubuntu does
-GFORTRANFLAGS = ['-ffixed-line-length-none' ,'-fno-second-underscore',    '-fPIC','-fno-range-check', '-fallow-argument-mismatch']
+GFORTRANFLAGS = ['-ffixed-line-length-none' ,'-fno-second-underscore',    '-fPIC','-fno-range-check', '-Wno-argument-mismatch']
 GCCFLAGS = ['-fPIC']
 if 'DEVELOPER' in os.environ:
     GFORTRANFLAGS.append('-fbounds-check')
diff --git a/infiles_dps/dockerfile b/infiles_dps/dockerfile
new file mode 100644
index 0000000..ae2d8c8
--- /dev/null
+++ b/infiles_dps/dockerfile
@@ -0,0 +1,19 @@
+FROM isce/isce2:20240804
+
+RUN apt-get update -y && \
+    apt-get install -y nano scons libfftw3-dev libxm4 libmotif-dev python3-dev python3-pip git && \
+    apt-get install -y python3-scipy python3-opencv python3-numpy python3-h5py cython3 gdal-bin gfortran libgdal-dev python3-gdal libhdf5-dev python3.9-dev
+
+RUN pip3 install cython opencv-python opencv-contrib-python shapely requests
+
+RUN mkdir -p /home/pkgs /home/.isce
+COPY . /home/pkgs/isce2
+RUN ln -s /home/pkgs/isce2 /home/pkgs/isce 
+
+RUN cp /home/pkgs/isce2/infiles_dps/ISCE_config.sh /home/pkgs/isce2/ && \
+    cp /home/pkgs/isce2/infiles_dps/read_calibration_slc.py /home/pkgs/isce2/contrib/stack/topsStack/ && \
+    cp /home/pkgs/isce2/infiles_dps/SConfigISCE /home/.isce/
+
+RUN bash /home/pkgs/isce2/infiles_dps/install.sh
+
+CMD ["/bin/bash"]
diff --git a/infiles_dps/install.sh b/infiles_dps/install.sh
new file mode 100644
index 0000000..d6ee13e
--- /dev/null
+++ b/infiles_dps/install.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+export SCONS_CONFIG_DIR=/home/.isce
+export PATH="/home/pkgs/isce/contrib/stack/topsStack:$PATH"
+export ISCE_INSTALL_ROOT=/home/pkgs/isce
+export PYTHONPATH=$ISCE_INSTALL_ROOT:$PYTHONPATH
+export ISCE_HOME=$ISCE_INSTALL_ROOT/isce
+export PATH=$ISCE_HOME/applications:$PATH
+
+pushd /home/pkgs/isce2
+scons install
-- 
GitLab