I'm creating an app that in addition to the live production environment requires a development and staging environment. The production environment is currently live and on its own VPS instance. A record:
myapp.com 1.2.3.4
The development and staging environments will be on their own VPS instance. I've configured the appropriate DNS records so each environment has its own sub-domain (A record in the myapp.com domain pointing to the dev/staging server:
dev.myapp.com 5.6.7.8
staging.myapp.com 5.6.7.8
The Nginx confix (Rails, Passenger) sets the root for each server (wild card SSL is configure in the http definition and port 80 redirects to port 443):
server {
listen 443;
server_name dev.myapp.com
root /apps/myapp/dev/public
}
server {
listen 443;
server_name staging.myapp.com
root /apps/myapp/staging/public
}
I'm a bit confused on the Rails side what else do I need to do to configure the environments so I can access the individual dev and staging environments by URL:
staging.myapp.com
dev.myapp.com
I know Capistrano allows you to set production and staging environments but I need both the dev and staging URLs to be live or should this be sufficient?
Rails comes with three environments: development, test, and production, but it is easy to add your own.
A staging environment (stage) is a nearly exact replica of a production environment for software testing. Staging environments are made to test codes, builds, and updates to ensure quality under a production-like environment before application deployment.
Go to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option. The default development environment can be changed using -e .
You can set the environment for each instance using the rails_env
option. For example:
server {
listen 443;
server_name staging.myapp.com;
root /apps/myapp/staging/public;
passenger_enabled on;
rails_env staging;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With