opencpu / opencpu

OpenCPU system for embedded scientific computation and reproducible research
https://www.opencpu.org
Other
721 stars 120 forks source link

docker image optimization #377

Open rgr opened 3 years ago

rgr commented 3 years ago

Hi,

I created a docker image of my package with opencpu and I am wondering why is there such a huge difference between my final image and the one from opencpu base in terms of size and memory usage...

With the base image, the image size is 350mo and uses 200mo of ram when iddle. When I get my image, it is 1Go (with 3 files of code added) and it uses 1.2Go of ram when idle, not calling any function...

Here is my docker file. The installer only installs 3 packages that are also loaded in the preload server conf...

# Use the official OpenCPU Dockerfile as a base
FROM opencpu/base:2.2.2-1

# Move OpenCPU configuration files into place
COPY docker/opencpu_config/* /etc/opencpu/

# Copy and run our custom install script for R dependencies
WORKDIR /usr/local/src
COPY docker/installer.R /usr/local/src/app/docker/installer.R
RUN /usr/bin/R --vanilla -f app/docker/installer.R

# Copy our R code into the container
COPY . /usr/local/src/app

# Install our code as an R package on the server
RUN tar czf /tmp/xyz.tar.gz app/ \
  && /usr/bin/R CMD INSTALL /tmp/xyz.tar.gz

Do you have any idea about how to optimize both the size and the memory usage? I'm wondering where the issue could come from...

rgr commented 3 years ago

Following the solutions offered by @jeroen here (https://stackoverflow.com/a/47461528/7474722), and reading on the ocpu doc for the server, I was wondering :

I now realize this would be more a StackOverflow question than an issue in that repo, sorry...