Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shiny Server don't respect the container environment variables #318

Closed
eitsupi opened this issue Jan 7, 2022 · 2 comments · Fixed by #320
Closed

Shiny Server don't respect the container environment variables #318

eitsupi opened this issue Jan 7, 2022 · 2 comments · Fixed by #320

Comments

@eitsupi
Copy link
Member

eitsupi commented Jan 7, 2022

I was creating a docker-compose project to link multiple containers as shown below, and had trouble with the timezone setting not being reflected in the shiny app.

version: "3.8"

x-common_environment: &common_environment
  TZ: Asia/Tokyo

services:
  db:
    image: postgres:13
    environment:
      <<: *common_environment

  shiny:
    image: rocker/shiny:4
    environment:
      <<: *common_environment
    ports:
      - 3838:3838

I think it is worthwhile to make the same changes to Shiny Server that were once made to containers with RStudio Server installed (#186).
I think it can be achieved by simply copying the following lines from userconf.sh and pasting it into install_shiny_server.sh.

exclude_vars="HOME PASSWORD RSTUDIO_VERSION"
for file in /var/run/s6/container_environment/*
do
sed -i "/^${file##*/}=/d" ${R_HOME}/etc/Renviron.site
regex="(^| )${file##*/}($| )"
[[ ! $exclude_vars =~ $regex ]] && echo "${file##*/}=$(cat $file)" >> ${R_HOME}/etc/Renviron.site || echo "skipping $file"
done

Like these lines.

cat > /etc/services.d/shiny-server/run << 'EOF'
#!/usr/bin/with-contenv bash
## load /etc/environment vars first:
for line in $( cat /etc/environment ) ; do export $line > /dev/null; done
if [ "$APPLICATION_LOGS_TO_STDOUT" != "false" ]; then
exec xtail /var/log/shiny-server/ &
fi
exec shiny-server 2>&1
EOF

@cboettig
Copy link
Member

cboettig commented Jan 7, 2022

yup, that makes sense to me. Do you have a chance to send a PR along these lines?

@eitsupi
Copy link
Member Author

eitsupi commented Jan 8, 2022

Yes, I would like to try this and create a PR.
It may be more appropriate to cut out only this part of the process into a stand-alone script and copy it into the S6 installation.

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 a pull request may close this issue.

2 participants