ThinkR-open / dockerfiler

Easy Dockerfile Creation from R
https://thinkr-open.github.io/dockerfiler/
Other
169 stars 25 forks source link

add_dockerfile_with_renv() should check non-R files containing R code #45

Closed gueyenono closed 8 months ago

gueyenono commented 1 year ago

I was introduced to the magical function that is add_dockerfile_with_renv() through this very useful, relatively short and concise video by Vincent Guyader: https://www.youtube.com/watch?v=diCG4t76k78

Upon using it the first few times, it worked very well for me until I tried it in a slightly different context. I use the {katex} package inside an Rmd file which is rendered inside the app. The package is used nowhere else inside the app. The consequence is that the package is not accounted for when the call to add_dockerfile_with_renv() is made and the final containerized app does not work because it lacks this dependency.

My workaround for now is to add katex::example_math() in app_sever.R, which simply prints a string to the console. But it would be nice if the function could also check the packages used inside non-R files that contain R code such as Rmd and qmd.

ColinFay commented 1 year ago

Hey,

Is {katex} listed in your DESCRIPTION file? That should be caught by the Dockerfile creation.

For the original request, I'm not sure it should, as you might for example use things in dev/ or inst/ that are only for development purpose and then are not required during deployment. Or, let's say for example you have a Rmd with code example but this code is not executed in the app, just displayed, then you don't need that for your deployment. Hence our choice to rely on the DESCRIPTION file.

That being said, you might want to force this behavior (searching everywhere) with an option. @VincentGuyader is this doable?

gueyenono commented 1 year ago

You are right. I did not think of the other case scenarios you mentioned. I now see that it should be the developer's prerogative to make sure that the required dependencies are in the DESCRIPTION file. Having the option (as you suggested) would definitely be cool.

Thank you.

VincentGuyader commented 1 year ago

Your check should return 0 error 0 warning to be sure to create thé propre dockerfile.

Have a look to attachment::att_amend_desc() for help