title: Dockerfile for minimum image size on R-base
body: <p>I'm trying to minimize the size of my docker image. It's on R-Base from the rocker project. It needs to be as small as possible, since it is used as a container instance in a cloud based workflow.</p>
  
  <p>The image needs some extra packages (<code>dplyr</code>, <code>pdftools</code>, <code>stringr</code> and <code>AzureStor</code>). Some are available as binary, but <code>AzureStor</code> I could not find as such.</p>
  
  <p>I already used some recommended commands to minimize size. What can I do more? Please read the docker file below. A few options I'm considering now:</p>
  
  <ul>
  <li>Can I save space using 'no cache'? How do I 'implement' this?</li>
  <li>Is there a binary version for a R package like <code>AzureStor</code>? I can't find it.</li>
  <li>Are there any other build commands or dockerfile lines I can use to reduce any excess size?</li>
  </ul>
  
  <p>Any help would be much appreciated!</p>
  
  <p>Here is my current dockerfile</p>
  
  <pre><code>    FROM rocker/r-base:latest
  ## install binary, build and dependend packages from single run command
  
  RUN apt-get update &amp;&amp; apt-get install -y -qq --no-install-recommends --purge
  r-cran-pdftools \
  r-cran-dplyr \
  r-cran-stringr \
  libxml2-dev \
  libssl-dev &amp;&amp; \
  
  ## install non-binary packages (from the same run command)
  
  echo "r &lt;- getOption('repos');r['CRAN'] &lt;- 'http://cran.us.r-project.org'; options(repos = r);" &gt; ~/.Rprofile &amp;&amp; \
  Rscript -e "install.packages(c('AzureStor'))" &amp;&amp; \
  
  mkdir -p /scripts \
  
  ## remove and clean what we can (still the same run command)
  apt-get autoclean &amp;&amp; \
  apt-get -y autoremove libssl-dev &amp;&amp; \
  rm -rf /var/lib/apt/lists/*
  
  ## copy code
  COPY script / script
  
  ## Set workdir
  WORKDIR /scripts
  
  ## command line for autorunning the entire rscript
  CMD [ "Rscript", "runscript.R"]
  </code></pre>
  
  <p>Right now, the size is around 800 mb. Hoping to get this down.</p>