diff --git a/Dockerfile.multistage b/Dockerfile.multistage index bb34cc9..4629a97 100644 --- a/Dockerfile.multistage +++ b/Dockerfile.multistage @@ -73,6 +73,9 @@ COPY --from=builder /build/renv /app/renv COPY --from=builder /build/.Rprofile /app/.Rprofile COPY --from=builder /build/renv.lock /app/renv.lock +# Copy the renv cache (symlinks in renv/library point to this cache) +COPY --from=builder /root/.cache/R/renv /root/.cache/R/renv + # Copy application code COPY --from=builder /build/app.R /app/app.R @@ -80,7 +83,9 @@ COPY --from=builder /build/app.R /app/app.R EXPOSE 3838 # Run the application -CMD ["R", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 3838)"] +# Note: Use --vanilla to skip .Rprofile and avoid renv activation at runtime +# The renv library path is already in R's search path +CMD ["R", "--vanilla", "-e", ".libPaths('/app/renv/library/linux-ubuntu-noble/R-4.4/x86_64-pc-linux-gnu'); shiny::runApp('/app', host = '0.0.0.0', port = 3838)"] # ============================================================================ # Build and Run Commands: diff --git a/Dockerfile.single-stage b/Dockerfile.single-stage index c54c857..0408281 100644 --- a/Dockerfile.single-stage +++ b/Dockerfile.single-stage @@ -39,4 +39,6 @@ RUN R -e "renv::restore()" EXPOSE 3838 # Run the application -CMD ["R", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 3838)"] +# Note: Use --vanilla to skip .Rprofile and avoid renv activation at runtime +# The renv library path is already in R's search path +CMD ["R", "--vanilla", "-e", ".libPaths('/app/renv/library/linux-ubuntu-noble/R-4.4/x86_64-pc-linux-gnu'); shiny::runApp('/app', host = '0.0.0.0', port = 3838)"] diff --git a/Dockerfile.three-stage b/Dockerfile.three-stage index 8882cb1..6c4a0d4 100644 --- a/Dockerfile.three-stage +++ b/Dockerfile.three-stage @@ -108,6 +108,9 @@ COPY --from=base /base/renv /app/renv COPY --from=base /base/.Rprofile /app/.Rprofile COPY --from=base /base/renv.lock /app/renv.lock +# Copy the renv cache (symlinks in renv/library point to this cache) +COPY --from=base /root/.cache/R/renv /root/.cache/R/renv + # Copy custom packages from builder stage (if any were installed) # COPY --from=builder /usr/local/lib/R/site-library/mypackage /usr/local/lib/R/site-library/mypackage @@ -118,7 +121,9 @@ COPY --from=builder /build/app.R /app/app.R EXPOSE 3838 # Run the application -CMD ["R", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 3838)"] +# Note: Use --vanilla to skip .Rprofile and avoid renv activation at runtime +# The renv library path is already in R's search path +CMD ["R", "--vanilla", "-e", ".libPaths('/app/renv/library/linux-ubuntu-noble/R-4.4/x86_64-pc-linux-gnu'); shiny::runApp('/app', host = '0.0.0.0', port = 3838)"] # ============================================================================ # Layer Optimization Strategy: