Skip to content

fix(dockerignore): exclude .Rprofile from the build context#12

Merged
VincentGuyader merged 1 commit into
mainfrom
fix/dockerignore-rprofile
Apr 27, 2026
Merged

fix(dockerignore): exclude .Rprofile from the build context#12
VincentGuyader merged 1 commit into
mainfrom
fix/dockerignore-rprofile

Conversation

@VincentGuyader

Copy link
Copy Markdown
Owner

Summary

Adds .Rprofile to the list of paths written to .dockerignore by
create_dockerignore() (used by shiny2docker()).

Why

.Rprofile is a per-project R startup file. In a typical dev setup it
contains things like renv::activate(), dev-only options, and paths
that point to the developer's machine. Copying it into a production
container changes the R startup behaviour silently — for instance, it
can override .libPaths() and shadow the library that renv::restore()
or uvr sync just populated, leading to packages being loaded from a
non-existent host path inside the image.

Excluding it matches the spirit of the existing entries (.Rproj.user,
manifest.json, rsconnect/) and aligns with what the experimental
uvr backend (shiny2docker_uvr()) already does in its variant of
.dockerignore.

Scope

  • Single line added in R/shiny2docker.R (create_dockerignore).
  • No public API change. No documentation change required.
  • Existing test only asserts that .dockerignore is created, not its
    content; no test update needed.

Test plan

  • Rscript -e 'devtools::test()' — existing tests still pass.
  • Manual: run shiny2docker() on a project that has a .Rprofile,
    confirm the file is no longer copied into the image
    (docker build --no-cache . then docker run --rm <img> ls -la /srv/shiny-server/.Rprofile
    should report absent).

`.Rprofile` is a per-project R startup file that often references
host-side state (`renv::activate()`, dev-only options, paths from the
developer's machine) and has no business being copied into a production
container — it can subtly change which library `R` picks up at startup
and break the deterministic install carried out by `renv::restore()`
or `uvr sync`.

Adding it to the auto-generated `.dockerignore` aligns the renv backend
with what the experimental uvr backend already does, and matches the
spirit of the existing exclusions (`.Rproj.user`, `manifest.json`,
`rsconnect/`).
@VincentGuyader VincentGuyader self-assigned this Apr 27, 2026
@VincentGuyader VincentGuyader merged commit ddfd16e into main Apr 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant