Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile renv lock #38

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 25 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,67 +1,58 @@
# syntax=docker/dockerfile:1
FROM rocker/rstudio:4.2.1
MAINTAINER Lee Evans <evans@ohdsi.org>
FROM rocker/rstudio:4.2.3
LABEL Lee Evans <evans@ohdsi.org>

# install OS dependencies including java and python 3
RUN apt-get update && apt-get install -y openjdk-11-jdk liblzma-dev libbz2-dev libncurses5-dev curl python3-dev python3.venv \
RUN apt-get update && apt-get install -y openjdk-11-jdk liblzma-dev libbz2-dev libncurses5-dev curl python3-dev python3-virtualenv \
cmake libpng-dev libjpeg-dev make libssl-dev libsodium-dev libxml2-dev libicu-dev libsecret-1-dev libcurl4-openssl-dev \
pandoc git zlib1g-dev \
&& R CMD javareconf \
&& rm -rf /var/lib/apt/lists/*

# CRAN snapshot date
ARG POSIT_DATE=2024-03-29

# install utility R packages
RUN install2.r \
openssl \
httr \
xml2 \
remotes \
RUN install2.r --error --skipinstalled --repos "https://p3m.dev/cran/__linux__/jammy/$POSIT_DATE" \
renv \
&& rm -rf /tmp/download_packages/ /tmp/*.rds

# HADES wide release
ARG HADES_RELEASE=2024Q1
COPY hadesWideReleases/$HADES_RELEASE/renv.lock /renv.lock

# install OHDSI HADES R packages from CRAN and GitHub, temporarily adding a GitHub Personal Access Token (PAT) to the Renviron file
RUN --mount=type=secret,id=build_github_pat \
RUN --mount=type=secret,id=build_github_pat --mount=type=cache,target=/root/.cache/R \
cp /usr/local/lib/R/etc/Renviron /tmp/Renviron \
&& echo "GITHUB_PAT=$(cat /run/secrets/build_github_pat)" >> /usr/local/lib/R/etc/Renviron \
&& R -e "remotes::install_github(repo = 'OHDSI/Hades', upgrade = 'always')" \
&& cp /tmp/Renviron /usr/local/lib/R/etc/Renviron
&& R -e "library(renv); options(renv.verbose = TRUE); renv::restore(lockfile='/renv.lock', repos=c(CRAN='https://p3m.dev/cran/__linux__/jammy/$POSIT_DATE'))" \
&& mv /tmp/Renviron /usr/local/lib/R/etc/Renviron

# install useful R libraries to help RStudio users to create/use their own GitHub Personal Access Token
RUN install2.r \
RUN install2.r --error --skipinstalled --repos "https://p3m.dev/cran/__linux__/jammy/$POSIT_DATE" \
usethis \
gitcreds \
&& rm -rf /tmp/download_packages/ /tmp/*.rds

# create Python virtual environment used by the OHDSI PatientLevelPrediction R package
ENV WORKON_HOME="/opt/.virtualenvs"
RUN R <<EOF
RUN --mount=type=cache,target=/root/.cache/pip R <<EOF
reticulate::use_python("/usr/bin/python3", required=T)
PatientLevelPrediction::configurePython(envname='r-reticulate', envtype='python')
reticulate::use_virtualenv("/opt/.virtualenvs/r-reticulate")
EOF

# install shiny and other R packages used by the OHDSI PatientLevelPrediction R package viewPLP() function
# and additional model related R packages
RUN install2.r \
DT \
markdown \
plotly \
shiny \
shinycssloaders \
shinydashboard \
shinyWidgets \
# install additional model related R packages
RUN install2.r --error --skipinstalled --repos "https://p3m.dev/cran/__linux__/jammy/$POSIT_DATE" \
xgboost \
&& rm -rf /tmp/download_packages/ /tmp/*.rds

# install the jdbc drivers for database access using the OHDSI DatabaseConnector R package
ENV DATABASECONNECTOR_JAR_FOLDER="/opt/hades/jdbc_drivers"
RUN R <<EOF
library(DatabaseConnector);
downloadJdbcDrivers('postgresql');
downloadJdbcDrivers('redshift');
downloadJdbcDrivers('sql server');
downloadJdbcDrivers('oracle');
downloadJdbcDrivers('spark');
EOF
RUN R -e "DatabaseConnector::downloadJdbcDrivers('all');"

# Install Rserve server and client
RUN install2.r \
RUN install2.r --error --skipinstalled --repos "https://p3m.dev/cran/__linux__/jammy/$POSIT_DATE" \
Rserve \
RSclient \
&& rm -rf /tmp/download_packages/ /tmp/*.rds
Expand All @@ -75,7 +66,8 @@ EXPOSE 8787
EXPOSE 6311

# install supervisor process controller
RUN apt-get update && apt-get install -y supervisor
RUN apt-get update && apt-get install -y supervisor \
&& rm -rf /var/lib/apt/lists/*

# start Rserve & RStudio using supervisor
RUN echo "" >> /etc/supervisor/conf.d/supervisord.conf \
Expand Down