Coder Social home page Coder Social logo

Comments (5)

markegge avatar markegge commented on July 18, 2024

I ran into this issue myself a couple months ago. From what I recall, for security reasons Shiny isn't able to access environmental variables set by Docker. One workaround is to define your environmental variables in a .Renviron file and copy this file into /home/shiny/.

For example, my .Renviron file:

DBHOST=db
DBNAME=txdb
DBUSER=postgres
DBPASS=XXXXXXXXXXX

And my Dockerfile:

FROM rocker/shiny-verse
RUN R -e "install.packages(c('data.table', 'DT', 'leaflet'), repos='https://cran.rstudio.com/')"
RUN rm -rf /srv/shiny-server
WORKDIR /srv/shiny-server
COPY --chown=shiny:shiny . ./
COPY --chown=shiny:shiny .Renviron /home/shiny/.Renviron
EXPOSE 3838

from shiny.

Chrisjb avatar Chrisjb commented on July 18, 2024

Thanks, I ended up doing something pretty similar to that. It's not an ideal solution for me though since some of my deployments build from github or dockerhub and I don't want my environment variables on a public repo.

Would be ideal if shiny server could access environment variables set on the container rather than wiping them as it currently does. As you say doesn't seem to be an option currently.

from shiny.

cboettig avatar cboettig commented on July 18, 2024

👍 Thanks all for the comments. I agree it would be nicer if rstudio-server and shiny-server read env vars from the environment instead of only though the .Renviron files, but afaik that's the only option and is what we do in our Dockerfile recipes as well. Feel free to raise the issue with the RStudio developers, as this is ultimately their choice. They have been gracious in allowing Rocker explicit permission to package their open source products this way, and obviously they have commercial products in the same space.

We welcome other suggestions for working around these issues as well.

from shiny.

johanneshk avatar johanneshk commented on July 18, 2024

Here's my workaround: I override the CMD and simply dump all env variables into .Renviron:

CMD env > /home/shiny/.Renviron && shiny-server

This way you can still define the env variables in e.g. your docker-compose.yml or via an env file and don't have to hard-code into the Dockerfile.

I have a question about the security aspect: If shiny shouldn't access env variables for security reasons (why?) then 'read-only' access would be fine? I could only imagine, if shiny writes some env variables, that would pose a risk?

from shiny.

eitsupi avatar eitsupi commented on July 18, 2024

For Images with tags >= 4.0.0, which are currently maintained, this issue was resolved by rocker-org/rocker-versioned2#320.
So I close this issue.

from shiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.