Add Docker and Jenkins files.

This commit is contained in:
Andrea Dell'Amico 2023-04-09 17:12:31 +02:00
parent fd2dfde71b
commit 250e7e549e
Signed by: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
2 changed files with 128 additions and 0 deletions

79
Dockerfile Normal file
View File

@ -0,0 +1,79 @@
FROM rocker/r-ver:4.2.3
LABEL org.d4science.image.licenses="EUPL-1.2" \
org.d4science.image.source="https://code-repo.d4science.org/gCubeSystem/r-full-4.2" \
org.d4science.image.vendor="D4Science <https://www.d4science.org>" \
org.d4science.image.authors="Andrea Dell'Amico <andrea.dellamico@isti.cnr.it>"
ENV DEBIAN_FRONTEND noninteractive
# Some R dependencies
RUN apt-get update && apt-get install -y \
jags \
libxml2 \
git \
gdal-bin \
libgdal-dev \
libsodium-dev \
libudunits2-dev \
libfontconfig1-dev \
netcdf-bin \
libcairo2-dev \
libharfbuzz-dev \
libfribidi-dev \
sshpass \
p7zip-full \
sox \
imagemagick \
proj-bin \
proj-data \
libgsl23 \
postgresql-server-dev-all \
libsecret-1-0 \
fuse \
zip \
jq \
openjdk-8-jdk-headless
# Install the R packages we need, using the binary distribution
# at https://packagemanager.rstudio.com/client/#/repos/1/overview
ADD https://code-repo.d4science.org/gCubeSystem/r-packages-list/raw/branch/master/install2r-packages.txt /tmp
RUN for f in `cat /tmp/install2r-packages.txt` ; do install2.r --error --skipinstalled --ncpus -1 $f ; done
# Non CRAN repositories
ADD https://code-repo.d4science.org/gCubeSystem/r-packages-list/raw/branch/master/r_non_cran_pkgs.txt /tmp
RUN for l in `cat /tmp/r_non_cran_pkgs.txt` ; do \
pkg=`echo $l | cut -d : -f 1` ; \
mirror=`echo $l | cut -d : -f 2-` ; \
Rscript --slave --no-site-file --no-init-file --no-save --no-restore-history \
-e "install.packages(pkgs='$pkg', repos=c('$mirror/'));" ; done
# Install some CRAN packages from source
ADD https://code-repo.d4science.org/gCubeSystem/r-packages-list/raw/branch/master/jupyter-image-r-cran-pkgs.txt /tmp
RUN for cr in `cat /tmp/r_non_cran_pkgs.txt` ; do \
pkg='$cr' ; \
mirror='https://cloud.r-project.org' ; \
Rscript --slave --no-site-file --no-init-file --no-save --no-restore-history \
-e "install.packages(pkgs='$pkg', repos=c('$mirror/'));" ; done
# From github
ADD https://code-repo.d4science.org/gCubeSystem/r-packages-list/raw/branch/master/r_github_pkgs.txt /tmp
RUN mkdir -p /etc/R
RUN echo "GITHUB_PAT=$GITHUB_PAT" >> /etc/R/Renviron.site
#RUN for g in `cat /tmp/r_github_pkgs.txt` ; do \
# Rscript --slave --no-site-file --no-init-file --no-save --no-restore-history \
# -e " require(devtools); devtools::install_github('$g')" ; done
#RUN for g in `cat /tmp/r_github_pkgs.txt` ; do installGithub.r -d TRUE -u FALSE -r https://packagemanager.rstudio.com/all/__linux__/focal/latest $g ; done
#RUN grep -v "GITHUB_PATH" /etc/R/Renviron.site > /etc/R/Renviron.site.1
#RUN mv -f /etc/R/Renviron.site.1 /etc/R/Renviron.site
RUN installGithub.r -d TRUE -u FALSE -r https://packagemanager.rstudio.com/all/__linux__/focal/latest DanOvando/sraplus
RUN installGithub.r -d TRUE -u FALSE -r https://packagemanager.rstudio.com/all/__linux__/focal/latest sofia-tsaf/SOFIA
RUN installGithub.r -d TRUE -u FALSE -r https://packagemanager.rstudio.com/all/__linux__/focal/latest jabbamodel/JABBA
RUN installGithub.r -d TRUE -u FALSE -r https://packagemanager.rstudio.com/all/__linux__/focal/latest tokami/lbmsmt
# Ensure that we remove the source packages
RUN rm -fr /tmp/downloaded_packages/*
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && \
rm -f /tmp/R* /tmp/install2r-packages.txt /tmp/r_github_pkgs.txt /tmp/jupyter-image-r-cran-pkgs.txt /tmp/r_non_cran_pkgs.txt && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen

49
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,49 @@
// REMEMBER TO FILL THE environment section with your values.
// the following filed should be filled: imagename, git_url
// REMEMBER to put your Dockerfile in the root folder of your project
// The related jenkinsjob template is here:
pipeline {
agent {
label 'docker'
}
environment {
imagename = "d4science/r-full" //TO FILL WITH THE RIGHT VALUE (RepositoryName) e.g. d4science/RepositoryName
registryCredential = 'e348bfab-5580-4db6-b0e0-d854966bde08'
dockerImage = ''
git_url='https://code-repo.d4science.org/gCubeSystem/r-full-4.2.git' // SET HERE THE URL OF YOUR NEW GIT PROJECT
}
stages {
stage('Cloning Git') {
steps {
git([url: git_url, branch: 'main', credentialsId: '88b54962-1c0e-49cb-8155-22276860f346'])
}
}
stage('Building image') {
steps{
script {
dockerImage = docker.build imagename
}
}
}
stage('Deploy Image') {
steps{
script {
docker.withRegistry( '', registryCredential ) {
dockerImage.push("$BUILD_NUMBER")
dockerImage.push('4.2')
}
}
}
}
stage('Remove Unused docker image') {
steps{
sh "docker rmi $imagename:$BUILD_NUMBER"
sh "docker rmi $imagename:4.2"
}
}
}
}