A simple Docker Image for running Ruby on Rails Rails applications with Passenger.
docker run -i -t -d --name postgresql yrpri/postgresql docker run -d -name rtest1 -link postgresql:db -p 127.0.0.1:3000:3000 -v /var/www/your-priorities:/var/www/your-priorities -e APP_NAME=your-priorities yrpri/rails
docker run -d -name <containername> -link <dbcontainer>:db -v /var/www/<dir>:/var/www/<dir> -e APP_NAME=<appname> zumbrunnen/rails
When the container starts, the necessary gems will be installed, then the DB will be prepared (created and migrated), and eventually, Passenger will be started in standalone mode. See the start script which will be triggered by supervisord.
###Remarks
<dbcontainer>) of your choice. It works with zumbrunnen/postgresql.<dir> must be equal to $APP_NAME and - when using Capistrano - be the same on the host and in the container for deployments (because of absolute symlinks)-e KEY=value):APP_RUBY_VERSION=2.0.0RAILS_ENV=productionDB_USERNAME=dockerDB_PASSWORD=dockerWhen linked to another container holdig your database, use something like this in config/database.yml:
production:
adapter: postgresql
database: betastore_production
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
host: <%= ENV['DB_PORT_5432_TCP_ADDR'] %>
port: <%= ENV['DB_PORT_5432_TCP_PORT'] %>
pool: 5
timeout: 5000
To access your Rails app from "the outside", install a reverse proxy on the host system and point it to the container's IP on port 80.
I use Apache2. Here's how to set it up:
sudo apt-get install apache2/etc/apache2/sites-available, e.g. a file called appname:<VirtualHost *:80>
ServerName appname.your.domain
ErrorLog ${APACHE_LOG_DIR}/appname-error.log
CustomLog ${APACHE_LOG_DIR}/appname-access.log combined
ProxyRequests Off
ProxyPass / http://containerip:80/
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
N.B.: You can get the container's IP address by using: docker inspect -format '{{ .NetworkSettings.IPAddress }}' <containername>
proxy and proxy_http:sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2ensite yoursite
sudo service apache2 restart
Content type
Image
Digest
sha256:b4ebdd0c5…
Size
326.3 MB
Last updated
almost 11 years ago
docker pull yrpri/rails