Skip to content

Commit

Permalink
Add Docker run instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
keesvanbochove committed Sep 20, 2021
1 parent b2b3c4f commit 8e40ba3
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ inst_real

# Error reports
errorReportSql.txt

# Docker environment files
.env
117 changes: 117 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
FROM rocker/r-ver:4.1.0

RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
libbz2-dev \
liblzma-dev \
libcairo2-dev \
libcurl4-openssl-dev \
libfontconfig1-dev \
libpcre3-dev \
libssl-dev \
libxml2 \
libxml2-dev \
openjdk-11-jdk-headless \
pandoc \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 \
LD_LIBRARY_PATH=/usr/lib/jvm/java-11-openjdk-amd64/lib/server

RUN R CMD javareconf \
&& ln -s /usr/local/lib/R/site-library/littler/examples/install.r /usr/local/bin/install.r \
&& install.r \
devtools \
Andromeda \
base64enc \
benchmarkme \
benchmarkmeData \
bit64 \
bitops \
broom \
car \
checkmate \
codemetar \
colorspace \
curl \
clock \
conquer \
data.table \
devtools \
doParallel \
DT \
dplyr \
digest \
farver \
fastmap \
ff \
flextable \
foreach \
gdtools \
generics \
ggplot2 \
ggiraph \
gtable \
gridtext \
haven \
hms \
httpuv \
isoband \
iterators \
jpeg \
KMsurv \
labeling \
lme4 \
lubridate \
maptools \
munsell \
officer \
openxlsx \
pool \
plyr \
plotly \
png \
RColorBrewer \
RCurl \
readr \
readxl \
renv \
rJava \
rjson \
RJSONIO \
RSQLite \
rlang \
rmarkdown \
scales \
shiny \
shinydashboard \
shinyWidgets \
snow \
sourcetools \
survminer \
systemfonts \
tidyr \
tinytex \
tsibble \
utf8 \
uuid \
viridisLite \
vroom \
withr \
XML \
xml2 \
xtable \
zip \
&& installGithub.r \
OHDSI/CohortDiagnostics \
OHDSI/CirceR \
OHDSI/Eunomia \
OHDSI/FeatureExtraction \
OHDSI/ParallelLogger \
OHDSI/ROhdsiWebApi \
OHDSI/SqlRender \
OHDSI/DatabaseConnector \
OHDSI/DatabaseConnectorJars \
ohdsi-studies/[email protected]
49 changes: 49 additions & 0 deletions docker/README-Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Docker container instructions
=============================

This folder contains a number of files that can help you to run the study package within a Docker container.
Ready-to-go containers are also published on [Docker Hub](https://hub.docker.com/repository/docker/keesvanbochove/pioneer-package).

# Instructions
These instructions assume you would like to use the published container, but of course
you can also choose to build it from source yourself using the provided `Dockerfile`.

## 1. Supply configuration variables and create the cointainer
You can use the file `pioneer-package.env` in this folder to update environment variables
needed to run the study. Please copy it to a file named `.env` and fill in your details.
You can then create and start the container using the following command:
```
docker run -itd --env-file .env --name pioneer keesvanbochove:pioneer-package
```
Note that depending on your Docker configuration you may need to add other arguments, such as the target network.

## 2. Copy your private SFTP upload key to the container
```
docker cp study-data-site-pioneer pioneer:/
```

## 3. Run the study
You can use the following command to attach to the R session started within the container:
```
docker attach pioneer
```
You can now follow the instructions in `extras/CodeToRun.R` from section 2 on as if you were running locally.

A few comments:
* If you want to temporarily return to your command line but keep the container running, the default detach sequence is `CTRL-p CTRL-q`
* Please don't forget to run the `uploadDiagnosticsResults` and `uploadStudyResults` commands to upload to the OHDSI SFTP server! This requires your container to have internet connection.
* If you exit the R session (using `q()`), the container will be stopped, so don't do that until you are finished.

## 4. Copy the results out of the container onto your filesystem
By default, the results are in a folder named identical to your database ID.
So if your database ID is `SP` and you would like to copy the result folder to your current path, you would run:
```
docker cp pioneer:/SP .
```

5. Destroy the container
After you copied and inspected the results, you can safely destroy the container.
However, this will not delete the results in the result tables in your database (see `COHORT_SCHEMA`).
```
docker rm pioneer
```
10 changes: 10 additions & 0 deletions docker/pioneer-package.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
GITHUB_PAT=
DBMS=postgresql
DB_USER=postgres
DB_PASSWORD=postgres
DB_SERVER=host.docker.internal
DB_PORT=5432
CONNECTION_STRING=jdbc:postgresql://host.docker.internal:5432/ohdsi
PATH_TO_DRIVER=/usr/local/lib/R/site-library/DatabaseConnectorJars/java
CDM_SCHEMA=cdm_synpuf
COHORT_SCHEMA=pioneer
2 changes: 1 addition & 1 deletion extras/CodeToRun.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ cohortIdsToExcludeFromExecution <- c()
cohortIdsToExcludeFromResultsExport <- NULL

# For uploading the results. You should have received the key file from the study coordinator, input the correct path here:
keyFileName <- "your-home-folder-here/.ssh/study-data-site-pioneer"
keyFileName <- "study-data-site-pioneer"
userName <- "study-data-site-pioneer"

# Run cohort diagnostics -----------------------------------
Expand Down

0 comments on commit 8e40ba3

Please sign in to comment.