ondemand
ondemand copied to clipboard
Dashboard: The dashboard env vars carry over to product build environment
In particular the RAILS_RELATIVE_URL_ROOT is being set to /pun/dev/ood-dashboard when I precompile the assets in a shared app.
We will need to unset the following variables when running rails or rake commands from within the products path:
OOD_PORTALAPP_TYPEAPP_NAMEAPP_TOKENOOD_DATAROOTRAILS_RELATIVE_URL_ROOTSECRET_KEY_BASE
The above are defined in the dashboard's .env.production.
┆Issue is synchronized with this Asana task by Unito
Any solution to this needs to be aware that it might break once we add https://github.com/OSC/ood_appkit/issues/32
Bundler.with_clean_env does clean up any environment variables set by dotenv. The problem is that the Passenger environment variables are set before Bundler even runs. In particular, this is the output of env within a Bundler.with_clean_env run from within the dashboard app:
TERM=linux
SHELL=/sbin/nologin
LIBRARY_PATH=/opt/rh/v8314/root/usr/lib64
PYTHONUNBUFFERED=1
RACK_BASE_URI=/pun/dev/ood-dashboard
PASSENGER_DEBUG_DIR=/tmp/passenger.spawn-debug.XXXXG797gJ
SERVER_PORT=
X_SCLS=v8314 git19 nodejs010 rh-ruby22 rh-passenger40 nginx16
USER=jnicklas
DOCUMENT_ROOT=/users/appl/jnicklas/awesim/dev/ood-dashboard/public
SCGI=1
LD_LIBRARY_PATH=/opt/rh/v8314/root/usr/lib64:/opt/rh/nodejs010/root/usr/lib64:/opt/rh/rh-ruby22/root/usr/lib64:/opt/rh/rh-passenger40/root/usr/lib64
SUDO_USER=apache
REQUEST_URI=/pun/dev/ood-dashboard/assets/font-awesome/fontawesome-webfont-2adefcbc041e7d18fcf2d417879dc5a09997aa64d675b7a3c4b6ce33da13f3fe.woff2?v=4.7.0
SUDO_UID=48
CPATH=/opt/rh/v8314/root/usr/include
RAILS_RELATIVE_URL_ROOT=/pun/dev/ood-dashboard
IN_PASSENGER=1
USERNAME=root
RACK_ENV=development
REMOTE_PORT=
MAIL=/var/mail/root
PATH=/opt/rh/v8314/root/usr/bin:/opt/rh/git19/root/usr/bin:/opt/rh/nodejs010/root/usr/bin:/opt/rh/rh-ruby22/root/usr/bin:/opt/rh/rh-passenger40/root/usr/bin:/opt/rh/rh-passenger40/root/usr/sbin:/opt/rh/nginx16/root/usr/bin:/opt/rh/nginx16/root/usr/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
WSGI_ENV=development
PWD=/users/appl/jnicklas/awesim/dev/ood-dashboard
LANG=C
NODE_PATH=/opt/rh/rh-passenger40/root/usr/share/passenger/node
NODE_ENV=development
REMOTE_ADDR=unix:
SERVER_NAME=localhost
HOME=/users/appl/jnicklas
SUDO_COMMAND=/opt/ood/nginx_stage/sbin/nginx_stage app -u jnicklas -r %2fusr%2fjnicklas%2fvftwebapp -i %2fpun
SHLVL=0
RAILS_ENV=development
SERVER_SOFTWARE=nginx/1.6.2
LOGNAME=root
PYTHONPATH=/opt/rh/v8314/root/usr/lib/python2.6/site-packages:/opt/rh/nodejs010/root/usr/lib/python2.6/site-packages
QUERY_STRING=v=4.7.0
SERVER_ADDR=unix:/var/run/nginx/jnicklas/passenger.sock
XDG_DATA_DIRS=/opt/rh/rh-ruby22/root/usr/share
PKG_CONFIG_PATH=/opt/rh/v8314/root/usr/lib64/pkgconfig:/opt/rh/rh-ruby22/root/usr/lib64/pkgconfig:/opt/rh/rh-passenger40/root/usr/lib64/pkgconfig:/opt/rh/nginx16/root/usr/lib64/pkgconfig
SERVER_PROTOCOL=HTTP/1.1
PASSENGER_APP_ENV=development
SUDO_GID=48
REQUEST_METHOD=GET
PASSENGER_BASE_URI=/pun/dev/ood-dashboard
Note the Passenger env vars:
-
PASSENGER_BASE_URI -
RAILS_RELATIVE_URL_ROOT -
RACK_BASE_URI -
PASSENGER_APP_ENV -
RAILS_ENV -
NODE_ENV -
WSGI_ENV
Seems like we need our own Bundler.with_clean_env. An OodAppkit.with_clean_env alternative that does more than Bundler.with_clean_env. Or a Passenger.with_clean_env.
This is related to app development. If the command to shell out is rake ... then you would want to do something like this: unset OOD_PORTAL APP_TYPE; rake ... so the child process unsets the vars prior to executing the rake task. The commands are in the products controller that are executed I think when clicking buttons in details view.
Actually this will take more thought now that we are setting more env vars outside of dotenv files... in the PUN.
reviewed, leaving open for further investigation