Dynamically Provisioning R Libraries with renv

Is it possible to run apps through shinyproxy with a host renv cache mount?

# the location of the renv cache on the host machine
RENV_PATHS_CACHE_HOST=/opt/local/renv/cache

# where the cache should be mounted in the container
RENV_PATHS_CACHE_CONTAINER=/renv/cache

# run the container with the host cache mounted in the container
docker run --rm \
    -e "RENV_PATHS_CACHE=${RENV_PATHS_CACHE_CONTAINER}" \
    -v "${RENV_PATHS_CACHE_HOST}:${RENV_PATHS_CACHE_CONTAINER}" \
    -p 14618:14618 \
    R -s -e 'renv::restore(); shiny::runApp(host = "0.0.0.0", port = 14618)'

Using renv with Docker • renv

Would this be the way?

Dockerfile

FROM openanalytics/r-ver:4.4.2

# Prepare system libraries and R environment
RUN apt-get update && apt-get install --no-install-recommends -y \
    libpq-dev \
    && rm -rf /var/lib/apt/lists/*

# Set up working directory and permissions
WORKDIR /project
COPY . /project
RUN chown -R nobody:nogroup /project

# Install renv and prepare the R environment for Shiny
RUN R -e "install.packages('remotes'); remotes::install_version('renv', '1.0.11');"
ENV RENV_PATHS_CACHE=/renv/cache

USER nobody
CMD ["R", "-e", "renv::restore(); shiny::runApp('/project')"]

application.yml

proxy:
  title: ShinyProxy Example
  port: 8080
  docker:
    url: http://localhost:2375
    internal-networking: true
  specs:
    - id: app1
      display-name: Application 1
      description: An application with RENV
      container-cmd: ["R", "-e", "renv::restore(); shiny::runApp('/project')"]
      container-env:
        RENV_PATHS_CACHE: "/renv/cache"
      docker-volumes:
        - "/path/on/host/renv/cache:/renv/cache"