How to deploy Ruby on Rails application on Google Compute Engine
NOTICE:
To allow better navigation, all actions to be taken are marked with
![]() Example: ![]() |
Introduction
This is basic set of instructions to deploy Ruby on Rails application on Google Compute Engine.Google Compute Engine is IaaS (Infrastructure as a Service) - in other words, it's managed Virtual Machine, where you can install your software.
When setting up Google Compute Engine you can choose machine type, operating system and also you can preload some technology stack (including Ruby on Rails).
Step 1: Create Google Cloud Project


Step 2: Use "Click to Deploy" to deploy with Ruby on Rails stack



After this stage please write down your MySQL root password – we will need it later to change MySQL password to new one.
NOTICE:
At this point, cheapest machine type you can choose is n1-standard-1 (1 vCPU, 3.75 GB RAM). Estimated cost for this kind of machine is 25$/month.
You can change it later to f1-micro
(vCPUs: shared, RAM 0.6 GB) which is cheaper ~4.60$/month.
For instructions please see Appendix chapter at the end of this article. |
Your virtual machine will be
preloaded with Ruby components:
- Ruby on Rails 4.2.0 (Ruby version 2.1.1)
- Apache HTTP Sever 2.2.22
- Phusion Passenger 4.0
- MySQL 5.5
You can get description of your
installation directories here:


Step 3: Login to your VM and push source code


$ git clone https://github.com/maciej-arkit/rubyonrails_sample_blog |
4. Create MySQL database and run db:migrate

$
mysqladmin -u root -p password
|
NOTICE
You need to provide your current root
password (you should have it), or you can find it going to
https://console.developers.google.com/project/${YOUR_APP}/compute/instances,
and clicking on your instance.
Then plese find "MYSQL_ROOT_PASSWORD"
string.
|

$ mysqladmin -u root -p create blog_dev |

Gemfile
|
gem mysql
gem 'therubyracer', platforms: :ruby |

$ rake db:migrate |
5. Configure apache

$ sudo nano default |
/etc/apache2/sites-available/default
|
|

$ sudo service apache2 restart |

Logs
You can access Apache logs in /var/log/apache2/
Appendix: How to change instance type to f1-micro (~4.6$/month)
For pricing information, go to https://cloud.google.com/products/calculator.



NOTICE:
You have to delete your instance before using it's disk with another one. |

I wonder what change in App Engine made it possible to deploy Rails stack ..
OdpowiedzUsuńYou can deploy pure RoR stack on Google Compute Engine VM (not on Google App Engine). To do it on Google App Engine you will need to use JRuby and deploy it like Java application.
UsuńGoogleAppEngine is Platform as a Service, and to deliver it's scalability, underneath it uses Google Compute Engine VMs (IaaS).
In this case we are using Compute Engine. Please see this diagram: http://goo.gl/dbRp4e
Fantastic ... Great article.
OdpowiedzUsuń