LoginSignup
2
2

More than 5 years have passed since last update.

Use Phusion Passenger on nginx with RAILS_ENV

Posted at

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:

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2