Skip to content

Commit

Permalink
Build/clean dockerfile (#58)
Browse files Browse the repository at this point in the history
* build(docker): Set base image

Do not accept base iomage as a build arg

* build(docker): Inherit system packages from base image

Do not install new system packages unless they are needed

* build(docker): Move `pak` installation into Rscript

Install `pak` at same time as other dependencies

* build(docker): Explicitly copy file

Copy only needed file, rather than full build context

* build(docker): use JSON notation for RUN command
  • Loading branch information
AlexAxthelm authored Feb 26, 2024
1 parent cc3de8a commit d93b71c
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,22 @@
# https://packagemanager.rstudio.com/client/#/repos/2/overview
# https://packagemanager.rstudio.com/cran/__linux__/jammy/2023-03-31+MbiAEzHt

ARG BASE_IMAGE=transitionmonitordockerregistry.azurecr.io/rmi_pacta:2021q4_1.0.0
FROM --platform=linux/amd64 $BASE_IMAGE
FROM transitionmonitordockerregistry.azurecr.io/rmi_pacta:2021q4_1.0.0
ARG CRAN_REPO="https://packagemanager.posit.co/cran/__linux__/jammy/2023-10-30"
RUN echo "options(repos = c(CRAN = '$CRAN_REPO'))" >> "${R_HOME}/etc/Rprofile.site"

# install system dependencies
ARG SYS_DEPS="git"

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $SYS_DEPS \
&& chmod -R a+rwX /root \
&& rm -rf /var/lib/apt/lists/*

# install R package dependencies
RUN Rscript -e "install.packages('pak')"

# Install R deopendencies
# Install R dependencies
COPY DESCRIPTION /workflow.prepare.pacta.indices/DESCRIPTION

# install R package dependencies
RUN Rscript -e "\
install.packages('pak'); \
deps <- pak::local_install_deps(root = '/workflow.prepare.pacta.indices'); \
"

# copy in workflow repo
COPY . /workflow.prepare.pacta.indices
COPY prepare_pacta_indices.R /workflow.prepare.pacta.indices/prepare_pacta_indices.R

WORKDIR /workflow.prepare.pacta.indices

CMD Rscript --vanilla /workflow.prepare.pacta.indices/prepare_pacta_indices.R
CMD ["Rscript", "--vanilla", "/workflow.prepare.pacta.indices/prepare_pacta_indices.R"]

0 comments on commit d93b71c

Please sign in to comment.