Skip to content

Commit

Permalink
Improve docker build speed and caching
Browse files Browse the repository at this point in the history
  • Loading branch information
stefpiatek committed Dec 4, 2024
1 parent a1e6e0d commit 1e0eb50
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PREPROCESS_DB_USERNAME= # username for the source database
PREPROCESS_DB_PASSWORD= # password for the source database
PREPROCESS_DB_CDM_SCHEMA= # Schema name in the database to connect the OMOP CDM to
PREPROCESS_SUMMARISE_LEVEL=monthly # Level to summarise record counts at (monthly or quarterly)
PREPROCESS_BUILD_CORES=4 # Number of cores to use for make in docker build

# Low-frequency replacement
LOW_FREQUENCY_THRESHOLD=5
Expand Down
2 changes: 1 addition & 1 deletion app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN install2.r --error --skipinstalled renv remotes && \
RUN R -e 'remotes::install_github("SAFEHR-data/omop-bundles")'

# Install the app
RUN R -e 'remotes::install_local(".", dependencies = TRUE)'
RUN R -e 'devtools::install(".", dependencies = TRUE)'

EXPOSE 3838
CMD ["R", "-e", "options('shiny.port'=3838, shiny.host='0.0.0.0'); omopcat::run_app()" ]
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
# Required for running on GAE
HTTP_PROXY: ${HTTP_PROXY}
HTTPS_PROXY: ${HTTPS_PROXY}
CORES: ${PREPROCESS_BUILD_CORES}
image: omopcat_preprocessing:latest
platform: linux/amd64
environment:
Expand Down
7 changes: 6 additions & 1 deletion preprocessing/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
FROM rocker/tidyverse:4.4.1

WORKDIR /pkg
ADD preprocessing .
COPY preprocessing/renv.lock ./renv.lock

# Speed up building by setting make with multiple cores from env
ARG CORES
ENV MAKE="make -j${CORES}"

RUN install2.r --error --skipinstalled renv remotes && \
R -e 'renv::restore()' && \
rm -rf /tmp/downloaded_packages

ADD preprocessing .

RUN R -e 'remotes::install_local(path = ".", dependencies = TRUE)'

CMD ["R", "-e", "omopcat.preprocessing::preprocess()"]
2 changes: 1 addition & 1 deletion public.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PREPROCESS_DB_USERNAME= # username for the source database
PREPROCESS_DB_PASSWORD= # password for the source database
PREPROCESS_DB_CDM_SCHEMA= # Schema name in the database to connect the OMOP CDM to
PREPROCESS_SUMMARISE_LEVEL=quarterly # Level to summarise record counts at (monthly or quarterly)

PREPROCESS_BUILD_CORES=4 # Number of cores to use for make in docker build
# Low-frequency replacement
LOW_FREQUENCY_THRESHOLD=10
LOW_FREQUENCY_REPLACEMENT=5
Expand Down

0 comments on commit 1e0eb50

Please sign in to comment.