Skip to content

Commit

Permalink
Merge pull request #69 from SCiO-systems/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
angelosnm authored Jul 6, 2024
2 parents b76defe + 87d2ff2 commit f670248
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/pipeline-rocker-eiaspatial.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and Push Docker Images (rocker-eiaspatial)

on:
push:
branches:
- develop
- main
paths:
- ".github/workflows/pipeline-rocker-eiaspatial.yml"
- "rocker-eiaspatial/**"

permissions:
contents: read

jobs:
build_and_push_dev:
runs-on: "self-hosted"
if: startsWith(github.ref, 'refs/heads/develop')

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Get short SHA
uses: benjlevesque/short-sha@v2.2
id: short-sha
with:
length: 7

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and Push Docker Image (dev)
uses: docker/build-push-action@v4
with:
context: ./rocker-eiaspatial
file: ./rocker-eiaspatial/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:dev-${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}-${{ steps.short-sha.outputs.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:dev-${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max

build_and_push_prod:
runs-on: "self-hosted"
if: startsWith(github.ref, 'refs/heads/main')

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Pull "dev" Docker image
run: docker pull ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:dev-${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}

- name: Tag producion Docker image
run: docker tag ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:dev-${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }} ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}

- name: Push Docker image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }}

- name: Tag producion Docker image (non specified version)
run: docker tag ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial:${{ secrets.ROCKER_EIASPATIAL_RELEASE_VERSION }} ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial

- name: Push Docker image (non specified version)
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/rocker-eiaspatial
79 changes: 79 additions & 0 deletions rocker-eiaspatial/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# docker build -t rocker440 --progress=plain . > >(stdbuf -oL tee docker_build_output.log) 2> >(stdbuf -oL tee -a docker_build_output.log)
# docker run --name cg -p 8787:8787 --rm -ti -e PASSWORD=1234 rocker440
FROM rocker/rstudio:4.4.0

### Providing root privillages to default "rstudio" user account
RUN sudo usermod -aG sudo rstudio

### OS Packages installation
RUN sudo apt-get update && sudo apt-get install aptitude gdebi-core curl wget tar build-essential cmake make default-jre default-jdk cron screen pkg-config protobuf-compiler libfontconfig1-dev libgsl-dev libudunits2-dev libprotobuf-dev libjq-dev libmagick++-dev gfortran fftw3 fftw3-dev libxml2-dev libcurl4-openssl-dev libfontconfig1-dev libssl-dev libsodium-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev libgmp3-dev libmpfr-dev libarchive-dev gnupg libmysqlclient-dev -y

### GDAL installation
# RUN sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable # Not necessary
RUN sudo apt-get update && sudo apt-get install libgdal-dev libgeos-dev libproj-dev -y

### gsutil installation
RUN sudo echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && sudo apt-get update -y && sudo apt-get install google-cloud-cli -y

### NCO installation
RUN sudo aptitude install nco -y

### CROP models installation
## DSSAT installation
RUN sudo mkdir -p /opt/DSSAT/v4.7.5.30 && \
sudo chown -R rstudio:users /opt/DSSAT/v4.7.5.30/.

RUN sudo mkdir -p /opt/DSSAT/v4.8.1.40 && \
sudo chown -R rstudio:users /opt/DSSAT/v4.8.1.40/.

# v4.7.5.30 installation
RUN cd /opt/DSSAT/v4.7.5.30 && \
git clone https://github.com/DSSAT/dssat-csm-os.git --depth 1 --branch v4.7.5.30 && \
git clone https://github.com/DSSAT/dssat-csm-data.git

RUN cd /opt/DSSAT/v4.7.5.30/dssat-csm-os && \
mkdir build && \
cd build && \
cmake .. && \
make

# Adjusting filesystem to DSSAT compiler requirements
RUN cp /opt/DSSAT/v4.7.5.30/dssat-csm-os/build/bin/* /opt/DSSAT/v4.7.5.30
RUN cp -r /opt/DSSAT/v4.7.5.30/dssat-csm-os/Data/. /opt/DSSAT/v4.7.5.30
RUN cp -r /opt/DSSAT/v4.7.5.30/dssat-csm-data/* /opt/DSSAT/v4.7.5.30
RUN sed -i 's,/usr/local,opt/DSSAT/v4.7.5.30,g' /opt/DSSAT/v4.7.5.30/DSSATPRO.L47
RUN chown -R rstudio:rstudio /opt/DSSAT/v4.7.5.30/*

# v4.8.1.40 installation
RUN cd /opt/DSSAT/v4.8.1.40 && \
git clone https://github.com/DSSAT/dssat-csm-os.git --depth 1 --branch v4.8.1.40 && \
git clone https://github.com/DSSAT/dssat-csm-data.git

RUN cd /opt/DSSAT/v4.8.1.40/dssat-csm-os && \
mkdir build && \
cd build && \
cmake .. && \
make

# Adjusting filesystem to DSSAT compiler requirements
RUN cp /opt/DSSAT/v4.8.1.40/dssat-csm-os/build/bin/* /opt/DSSAT/v4.8.1.40
RUN cp -r /opt/DSSAT/v4.8.1.40/dssat-csm-os/Data/. /opt/DSSAT/v4.8.1.40
RUN cp -r /opt/DSSAT/v4.8.1.40/dssat-csm-data/* /opt/DSSAT/v4.8.1.40
RUN sed -i 's,/usr/local,opt/DSSAT/v4.8.1.40,g' /opt/DSSAT/v4.8.1.40/DSSATPRO.L48
RUN chown -R rstudio:rstudio /opt/DSSAT/v4.8.1.40/*

## ApsimX
RUN sudo apt-get update && sudo apt-get install libsqlite3-dev dotnet-sdk-6.0 -y

RUN cd /opt/ && \
sudo git clone https://github.com/APSIMInitiative/ApsimX && \
sudo chown -R rstudio:users /opt/ApsimX/. && \
dotnet build -c Release ./ApsimX/ApsimX.sln

## rJava dependencies
RUN sudo R CMD javareconf

### R packages installation
COPY packages.R packages.R
RUN sudo Rscript packages.R
RUN rm packages.R
25 changes: 25 additions & 0 deletions rocker-eiaspatial/packages.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
install.packages(c('devtools', 'shapefiles',
'ncdf4', 'terra', 'rworldmap', 'spatstat.geom', 'ggmap', 'rgee',
'leaflet', 'dismo', 'gdalUtilities', 'Hmisc',
'circlize', 'diagis', 'ggnewscale', 'lmerTest', 'lme4', 'metafor',
'metan', 'pbapply', 'FactoMineR', 'doParallel', 'ggpubr', 'broom',
'mlr3', 'RInside', 'doSNOW', 'Microsoft365R', 'googleCloudStorageR',
'circular', 'miceadds', 'multimode', 'sfsmisc', 'rJava', 'R.utils',
'reshape2', 'rworldxtra', 'RCurl', 'tidyverse', 'ranger', 'sodium',
'pals', 'ggcorrplot', 'aws.s3', 'agricolae', 'xlsx', 'ecmwfr',
'envirem', 'ranger', 'maps', 'dplyr', 'DSSAT', Ncpus = 4),
dependencies=TRUE,
repos='http://cran.rstudio.com/')

devtools::install_github(c("CIAT-DAPA/analogues",
"SantanderMetGroup/loadeR.java",
"SantanderMetGroup/climate4R.UDG",
"SantanderMetGroup/loadeR",
"SantanderMetGroup/transformeR",
"SantanderMetGroup/visualizeR",
"SantanderMetGroup/downscaleR",
"femiguez/apsimx"))
devtools::install_github(c("SantanderMetGroup/convertR",
"SantanderMetGroup/climate4R.indices"), Ncpus = 4)

devtools::install_github("bakaburg1/BaySREn")

0 comments on commit f670248

Please sign in to comment.