I'm learning how to use shinyproxy to deploy R shiny applications but I can't figure out where to place my .Renviron file which contains global variables used to access a database.
The docker image builds without any errors but when I start the container using:
docker run -it -p 3838:3838 shinyproxy-template .
It doesn't find the env variables in the .Renviron file and I end up getting an error on the part of the R code that requires the global variables.
My current folder structure is as follows:
shinyproxy-template/
|- app-folder/
|- .gitignore
|- Dockerfile
|- README.md
|- app.Rproj
|- Rprofile.site
|- .Renviron
I tried placing the .Renviron file inside the app-folder/ then built the docker image again but the global variables were still inaccessible.
Where should I place the .Renviron so that the global variables are accessed by the app?
There are multiple options:
Put
.Renvironfile to the expected location inside the containerYou can add a
COPYcommand to theDockerfileto copy your.Renvironfile to the expected location - i.e. either a home directory of the user or theWORKDIRlocation if defined in the Dockerfile. In case of the root user it would be:Add environment variables from
.Renvironto the DockerfileAdd lines like:
to your
DockerfileAdd environment variables from
.Renvironto the shinyproxy configurationYou can define environment variables in the
application.yamlconfiguration file by either usingor
for your app specification. Note that the path here is on the host and not inside the container.
For
docker runWhen you do a
docker runoutside of shinyproxy you can use argument--env-filewith something like:Releant documentation links: