From b034267f077ff31046a8830656b34e79a614337a Mon Sep 17 00:00:00 2001 From: Eli Holmes Date: Thu, 21 Mar 2024 10:03:23 -0700 Subject: [PATCH 1/7] try using openscapes base --- .../docker-image-coastwatch_patch.yml | 30 +++++++++++++ images/coastwatch/Dockerfile | 44 +++---------------- 2 files changed, 36 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/docker-image-coastwatch_patch.yml diff --git a/.github/workflows/docker-image-coastwatch_patch.yml b/.github/workflows/docker-image-coastwatch_patch.yml new file mode 100644 index 0000000..80bebd4 --- /dev/null +++ b/.github/workflows/docker-image-coastwatch_patch.yml @@ -0,0 +1,30 @@ +name: Docker Image CI coastwatch patch +on: + workflow_dispatch: null + push: + branches: coastwatch-patch + paths: + - 'images/coastwatch/**' + - '.github/workflows/docker-image-coastwatch_patch.yml' +jobs: + build: + runs-on: ubuntu-latest + permissions: write-all + steps: + - uses: actions/checkout@v3 + - name: Login to GitHub Container Registry + if: github.repository == 'nmfs-opensci/container-images' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + - name: Build the Docker image + if: github.repository == 'nmfs-opensci/container-images' + run: | + docker build images/coastwatch -f images/coastwatch/Dockerfile --tag ghcr.io/nmfs-opensci/container-images/coastwatch-patch:latest + - name: Publish + if: github.repository == 'nmfs-opensci/container-images' + run: | + docker push ghcr.io/nmfs-opensci/container-images/coastwatch-patch:latest + diff --git a/images/coastwatch/Dockerfile b/images/coastwatch/Dockerfile index 2c090ed..4584445 100644 --- a/images/coastwatch/Dockerfile +++ b/images/coastwatch/Dockerfile @@ -1,47 +1,15 @@ -# devcontainer-focused Rocker -# FROM ghcr.io/rocker-org/devcontainer/tidyverse:4.3 -FROM rocker/geospatial:4.2 -# switch user to jovyan; later not working -#RUN usermod -l rstudio jovyan - -# some Git preferences -RUN git config --system pull.rebase false && \ - git config --system credential.helper 'cache --timeout=36000' - -# Set up conda -ENV NB_USER=rstudio -ENV CONDA_ENV=/opt/miniforge3 -ENV PATH=${CONDA_ENV}/bin:${PATH} -RUN curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" && \ - bash Miniforge3-$(uname)-$(uname -m).sh -b -p ${CONDA_ENV} && \ - chown ${NB_USER}:staff -R ${CONDA_ENV} && \ - rm -f Miniforge3*.sh *.deb +FROM openscapes/rocker:a7596b5 +# Make sure R uses the conda path RUN echo "PATH=${PATH}" >>"${R_HOME}/etc/Renviron.site" -# Initialize conda by default for all users: -RUN conda init --system - -# Standard user setup here -RUN usermod -d /home/jovyan rstudio -USER ${NB_USER} -WORKDIR /home/jovyan -RUN usermod -s /bin/bash ${NB_USER} - -# install into the default environment +# install into the coastwatch packages if missing environment COPY install.R install.R RUN Rscript install.R && rm install.R # set-up the base coastwatch environment -# make sure we install in the base environment +# make sure we install in the notebook environment which is default in the +# Openscapes image COPY coastwatch-environment.yml coastwatch-environment.yml -RUN conda env update --name base -f coastwatch-environment.yml && conda clean --all +RUN mamba --name notebook -f coastwatch-environment.yml && mamba clean --all RUN rm coastwatch-environment.yml - -# add the packages needed for jupyterhubs -# need the --name part so that this is put in the coastwatch env -COPY jhub-environment.yml jhub-environment.yml -RUN conda env update --name base -f jhub-environment.yml && conda clean --all -RUN rm jhub-environment.yml - - From 33065349b7cea4803b0bca81d01ff4898a0f4bb8 Mon Sep 17 00:00:00 2001 From: Eli Holmes Date: Thu, 21 Mar 2024 10:50:16 -0700 Subject: [PATCH 2/7] minor --- images/coastwatch/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/images/coastwatch/Dockerfile b/images/coastwatch/Dockerfile index 4584445..14de581 100644 --- a/images/coastwatch/Dockerfile +++ b/images/coastwatch/Dockerfile @@ -1,5 +1,4 @@ FROM openscapes/rocker:a7596b5 - # Make sure R uses the conda path RUN echo "PATH=${PATH}" >>"${R_HOME}/etc/Renviron.site" From dd3d70523623bc05690bb4017e778e2622378aab Mon Sep 17 00:00:00 2001 From: Eli Holmes Date: Thu, 21 Mar 2024 11:03:11 -0700 Subject: [PATCH 3/7] add user root to update .Renviron --- images/coastwatch/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/images/coastwatch/Dockerfile b/images/coastwatch/Dockerfile index 14de581..a01be67 100644 --- a/images/coastwatch/Dockerfile +++ b/images/coastwatch/Dockerfile @@ -1,7 +1,11 @@ FROM openscapes/rocker:a7596b5 # Make sure R uses the conda path +USER root RUN echo "PATH=${PATH}" >>"${R_HOME}/etc/Renviron.site" +USER ${NB_USER} +WORKDIR ${HOME} + # install into the coastwatch packages if missing environment COPY install.R install.R RUN Rscript install.R && rm install.R From a5961d6baffbd2d9bd5200059575dbe170a29577 Mon Sep 17 00:00:00 2001 From: Eli Holmes Date: Thu, 21 Mar 2024 11:08:56 -0700 Subject: [PATCH 4/7] fix mamba command. missing env update --- images/coastwatch/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/coastwatch/Dockerfile b/images/coastwatch/Dockerfile index a01be67..d5c96f3 100644 --- a/images/coastwatch/Dockerfile +++ b/images/coastwatch/Dockerfile @@ -14,5 +14,5 @@ RUN Rscript install.R && rm install.R # make sure we install in the notebook environment which is default in the # Openscapes image COPY coastwatch-environment.yml coastwatch-environment.yml -RUN mamba --name notebook -f coastwatch-environment.yml && mamba clean --all +RUN mamba env update --name notebook -f coastwatch-environment.yml && mamba clean --all RUN rm coastwatch-environment.yml From e74f0114d76dcffbd71404910a17be81318e81fe Mon Sep 17 00:00:00 2001 From: Eli Holmes Date: Thu, 21 Mar 2024 14:02:21 -0700 Subject: [PATCH 5/7] clean up unneeded installs --- images/coastwatch/install.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/images/coastwatch/install.R b/images/coastwatch/install.R index 4319b68..370fed3 100755 --- a/images/coastwatch/install.R +++ b/images/coastwatch/install.R @@ -2,9 +2,9 @@ # install R dependencies list.of.packages <- c("ncdf4", "httr","plyr","lubridate", "parsedate", "rerddap","plotdap", - "rerddapXtracto", "graphics", "maps", "mapdata","RColorBrewer", - "ggplot2","scales","dplyr","utils","Rcurl","raster","colorRamps", - "parsedate","sp","sf","reshape2","jsonlite","rgdal", - "gridGraphics","grid","PBSmapping","date","viridis", + "rerddapXtracto", "maps", "mapdata","RColorBrewer", + "ggplot2","scales","dplyr","Rcurl","raster","colorRamps", + "parsedate","sp","sf","reshape2","jsonlite", + "gridGraphics","PBSmapping","date","viridis", "openair","cmocean", "terra") install.packages(list.of.packages) \ No newline at end of file From b57b8b6ab80b0cfcd57d60f53a21aa501a740841 Mon Sep 17 00:00:00 2001 From: Eli Holmes Date: Thu, 21 Mar 2024 14:18:12 -0700 Subject: [PATCH 6/7] pin a repository to use. to use the one in the rocker image --- images/coastwatch/install.R | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/images/coastwatch/install.R b/images/coastwatch/install.R index 370fed3..c5cf498 100755 --- a/images/coastwatch/install.R +++ b/images/coastwatch/install.R @@ -1,10 +1,20 @@ #! /usr/local/bin/Rscript # install R dependencies -list.of.packages <- c("ncdf4", "httr","plyr","lubridate", "parsedate", "rerddap","plotdap", - "rerddapXtracto", "maps", "mapdata","RColorBrewer", - "ggplot2","scales","dplyr","Rcurl","raster","colorRamps", - "parsedate","sp","sf","reshape2","jsonlite", - "gridGraphics","PBSmapping","date","viridis", - "openair","cmocean", "terra") -install.packages(list.of.packages) \ No newline at end of file +# to match rocker/geospatial:4.2 uses in openscapes/rocker:a7596b5 +repo <- "https://p3m.dev/cran/__linux__/jammy/2023-04-20" +list.of.packages <- c("ncdf4", "httr", "plyr", "lubridate", "parsedate", "rerddap", + "maps", "mapdata", "RColorBrewer", + "ggplot2","scales", "dplyr", "Rcurl", "raster", "colorRamps", + "parsedate", "sp", "sf", "reshape2", "jsonlite", + "gridGraphics", "PBSmapping", "date", "viridis", + "openair","cmocean", "terra", + "plotdap", "rerddapXtracto") +install.packages(list.of.packages, repos=repo) + +# https://rmendels.r-universe.dev/plotdap +#install.packages('plotdap', repos = c('https://rmendels.r-universe.dev', 'https://cloud.r-project.org')) + +# https://rmendels.r-universe.dev/rerddapXtracto +#install.packages('rerddapXtracto', repos = c('https://rmendels.r-universe.dev', 'https://cloud.r-project.org')) + From 122cabbf02483bd1efdf04b03d9966085dd836e6 Mon Sep 17 00:00:00 2001 From: Eli Holmes Date: Thu, 21 Mar 2024 14:28:52 -0700 Subject: [PATCH 7/7] RCurl not Rcurl --- images/coastwatch/install.R | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/images/coastwatch/install.R b/images/coastwatch/install.R index c5cf498..4d17165 100755 --- a/images/coastwatch/install.R +++ b/images/coastwatch/install.R @@ -5,16 +5,9 @@ repo <- "https://p3m.dev/cran/__linux__/jammy/2023-04-20" list.of.packages <- c("ncdf4", "httr", "plyr", "lubridate", "parsedate", "rerddap", "maps", "mapdata", "RColorBrewer", - "ggplot2","scales", "dplyr", "Rcurl", "raster", "colorRamps", + "ggplot2","scales", "dplyr", "RCurl", "raster", "colorRamps", "parsedate", "sp", "sf", "reshape2", "jsonlite", "gridGraphics", "PBSmapping", "date", "viridis", "openair","cmocean", "terra", - "plotdap", "rerddapXtracto") + "plotdap", "rerddapXtracto", "rgdal") install.packages(list.of.packages, repos=repo) - -# https://rmendels.r-universe.dev/plotdap -#install.packages('plotdap', repos = c('https://rmendels.r-universe.dev', 'https://cloud.r-project.org')) - -# https://rmendels.r-universe.dev/rerddapXtracto -#install.packages('rerddapXtracto', repos = c('https://rmendels.r-universe.dev', 'https://cloud.r-project.org')) -