-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 container image for tracking memory usage (#40)
* Adding valgrind container * to revert - run build * completing exclusion criteria * fixing path to R installation * single include for valgrind * to revert - targeting only valgrind * fixing wrong R path * adding DrMemory * fixing path * minor cleaning up * make it executable
- Loading branch information
Showing
2 changed files
with
156 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# Before the build stage | ||
ARG TARGET_OS | ||
ARG COMPILER | ||
ARG R_VERSION | ||
|
||
# For the valgrind container, target_os, compiler and r_vresion are not specified | ||
# Hovever, the valgrind container is fedora, gcc, devel | ||
# see https://r-hub.github.io/containers/containers.html#valgrind | ||
FROM rhub/${TARGET_OS} | ||
|
||
# Build stage: ARGs need to be redeclared | ||
ARG TARGET_OS | ||
ARG COMPILER | ||
ARG R_VERSION | ||
# ARG PACKAGE | ||
ARG PACKAGE_PATH | ||
ARG REPO_PATH | ||
ARG JAGS | ||
ARG DRMEMORY | ||
# # sets the date for the CRAN snapshot (e.g. BUILD_DATE=2023-12-20) | ||
# ARG BUILD_DATE | ||
|
||
# Update package repositories | ||
RUN dnf check-update && dnf -y install \ | ||
openssl-devel \ | ||
libcurl-devel | ||
|
||
# Install dependencies for DrMemory | ||
RUN dnf -y install libunwind | ||
# Install DrMemory | ||
ADD https://github.com/DynamoRIO/drmemory/releases/download/release_$DRMEMORY/DrMemory-Linux-$DRMEMORY.tar.gz /tmp/drmemory.tar.gz | ||
WORKDIR /tmp/ | ||
RUN mkdir -p /opt/DrMemory | ||
RUN tar -xf drmemory.tar.gz --directory /opt/DrMemory | ||
RUN rm drmemory.tar.gz | ||
# add DrMemory to PATH | ||
RUN chmod 755 /opt/DrMemory/DrMemory-Linux-$DRMEMORY/bin/drmemory | ||
ENV PATH="/opt/DrMemory/DrMemory-Linux-$DRMEMORY/bin:${PATH}" | ||
|
||
# add R to PATH | ||
ENV PATH="/opt/R/devel-valgrind/bin:${PATH}" | ||
|
||
# diff to debian: /lib/ > /lib64/ | ||
# ENV PATH "$PATH:/opt/R-devel/bin/" | ||
# Set a mirror for CRAN | ||
RUN RPATH=/opt/R/devel-valgrind \ | ||
&& echo 'options(repos =c(CRAN = "https://cran.rstudio.com"))' >> ${RPATH}/lib/R/library/base/R/Rprofile | ||
|
||
# rjags: | ||
RUN dnf -y install \ | ||
lapack* blas* atlas* | ||
ADD https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Source/$JAGS.tar.gz/download /tmp/jags.tar.gz | ||
WORKDIR /tmp/ | ||
RUN tar -xf jags.tar.gz | ||
RUN rm jags.tar.gz | ||
WORKDIR /tmp/$JAGS | ||
# Building JAGS requires the same environment that is then used to build rjags. | ||
# To achieve this we follow the approach for building JAGS with Clang outlined | ||
# in the JAGS installation guide | ||
# (https://usermanual.wiki/Document/jagsinstallationmanual.880863585.pdf) | ||
# and substitute the compilers with the specifics from the R installation that | ||
# we can get by using the `R CMD config CC/CXX/BLAS_LIBS/LAPACK_LIBS' commands: | ||
RUN if [ "$COMPILER" = "clang" ]; then RCC=/usr/bin/clang RCXX="/usr/bin/clang++ -std=gnu++17 -stdlib=libc++"; else RRCC=/usr/bin/gcc RCXX="/usr/bin/g++"; fi \ | ||
&& LD="llvm-ld" CC="${RCC}" CXX="${RCXX}" ./configure --with-blas="-L/opt/R/devel-valgrind/lib/R/lib -lRblas" --with-lapack="-L/opt/R/devel-valgrind/lib/R/lib -lRlapack" --libdir=/usr/local/lib && make && make install | ||
RUN ls /tmp/$JAGS | ||
# ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig | ||
# RUN R -e "install.packages('rjags')" | ||
RUN R -e "install.packages('rjags', configure.args = '--enable-rpath')" | ||
|
||
# Get and install packages for local debugging | ||
RUN R -e "install.packages('devtools')" \ | ||
&& R -e "install.packages('remotes')" \ | ||
&& R -e "install.packages('R.rsp')" \ | ||
&& R -e "install.packages('renv')" \ | ||
&& R -e "install.packages('desc')" | ||
|
||
# Prepare for potential check to be run | ||
RUN R -e "install.packages('urlchecker')" | ||
|
||
# Install dependencies not managed by CRAN | ||
# - lme4 and gsl: | ||
RUN dnf -y install \ | ||
gsl-devel \ | ||
sqlite-devel \ | ||
NLopt-devel | ||
# RUN R -e "install.packages('lme4')" | ||
# RUN R -e "install.packages('gsl')" | ||
|
||
# Graphviz | ||
RUN R -e "install.packages('BiocManager')" \ | ||
&& R -e "BiocManager::install('Rgraphviz')" | ||
|
||
# INLA | ||
# - sf | ||
RUN dnf -y install \ | ||
udunits2-devel gdal-devel geos-devel proj-devel | ||
# RUN R -e "install.packages('sf')" | ||
# - fmesher | ||
RUN dnf -y install \ | ||
udunits2-devel | ||
# RUN R -e "install.packages('fmesher')" | ||
# - INLA | ||
RUN R -e "install.packages('INLA',repos=c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'), dep=TRUE)" | ||
|
||
### | ||
# install all package dependencies | ||
### | ||
RUN dnf -y install \ | ||
git \ | ||
openssh-clients | ||
WORKDIR /root/ | ||
# get a shallow copy of the target repository | ||
# # Note: If the repository is private you must use a deploy token here (ssh key) | ||
# RUN --mount=type=secret,id=key,dst=/root/.ssh/key GIT_SSH_COMMAND="ssh -i /root/.ssh/key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone --depth=1 git@$REPO_PATH target | ||
RUN git clone --depth=1 https://$REPO_PATH target | ||
WORKDIR target/ | ||
# get a list of all dependencies; install remaining packages | ||
# escape=\ | ||
RUN R -e "renv::deactivate();pckgs<-unique(renv::dependencies('$PACKAGE_PATH')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs)])" |