From d93b71c58659f4ebdd894bf358fb3c5b110d01dc Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Mon, 26 Feb 2024 17:14:40 +0100 Subject: [PATCH] Build/clean dockerfile (#58) * 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 --- Dockerfile | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 39be13f..4e3a5d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"]