How to
Phusion passenger sets Rails' environment variable as production
by default and doesn't see ENV in shell. To change this value, you can change passenger_app_env
in nginx configuration file.
passenger_app_env staging;
Handle it in Docker container
I have Docker environment for staging. To set up this in my environment, I added another configuration file in starting script used in Dockerfile
.
# Dockerfile
# Some setup commands...
ENV RAILS_ENV production # This is default value. It will be overwritten by `--env` option.
CMD ['start.sh']
# starting script; start.sh
# Add nginx configuration for setting `passenger_app_env` as RAILS_ENV
RUN echo "passenger_app_env $RAILS_ENV;" > /opt/nginx/conf/00_app_env.conf
rake db:migrate && \
/opt/nginx/sbin/nginx
ref: