Merge lp:~jorge/juju-core/add-rails into lp:juju-core/docs

Proposed by Jorge Castro
Status: Merged
Approved by: Dave Cheney
Approved revision: no longer in the source branch.
Merged at revision: 90
Proposed branch: lp:~jorge/juju-core/add-rails
Merge into: lp:juju-core/docs
Diff against target: 294 lines (+290/-0)
1 file modified
htmldocs/howto-rails.html (+290/-0)
To merge this branch: bzr merge lp:~jorge/juju-core/add-rails
Reviewer Review Type Date Requested Status
Nick Veitch Pending
Review via email: mp+183283@code.launchpad.net

Description of the change

Add rails workflow

To post a comment you must log in.
Revision history for this message
Nick Veitch (evilnick) wrote :

I don't know what you did to get all the ’ things in there, but I will fix it

Revision history for this message
Dave Cheney (dave-cheney) wrote :

LGTM

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'htmldocs/howto-rails.html'
2--- htmldocs/howto-rails.html 1970-01-01 00:00:00 +0000
3+++ htmldocs/howto-rails.html 2013-08-30 21:33:23 +0000
4@@ -0,0 +1,290 @@
5+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
6+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
7+<html xmlns="http://www.w3.org/1999/xhtml">
8+ <head>
9+ <meta name="generator" content="HTML Tidy for Linux (vers 25 March 2009), see www.w3.org" />
10+ <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
11+ <meta http-equiv="Content-Style-Type" content="text/css" />
12+ <meta name="generator" content="pandoc" />
13+ <title></title>
14+ <style type="text/css">
15+/*<![CDATA[*/
16+ code{white-space: pre;}
17+ /*]]>*/
18+ </style>
19+ <link rel="stylesheet" href="file:////opt/extras.ubuntu.com/uberwriter/share/uberwriter/media/uberwriter.css" type="text/css" />
20+ </head>
21+ <body>
22+ <h1 id="using-juju-to-deploy-your-rails-application">
23+ Using Juju to Deploy your Rails Application
24+ </h1>
25+ <p>
26+ One of Juju&acirc;&euro;&trade;s main use cases is to deploy your application directly out of version control and into a cloud. Since Juju supports local and remote clouds, this makes for a nice workflow that enables you to rev your app quickly on your local machine and then deploy out the cloud.
27+ </p>
28+ <p>
29+ In this tutorial we will deploy a Rails/PostgreSQL application directly from github. The application will be behind an HAProxy service so that we can horizontally scale when needed.
30+ </p>
31+ <p>
32+ We will then set up a local-to-cloud workflow with our application so we can do continuous deployment. Since we deploy locally in the exact same way as we deploy to a cloud, this is a powerful method for developing your application in an environment that more closely resembles production.
33+ </p>
34+ <p>
35+ Before moving on you should have gone through the <a href="https://juju.ubuntu.com/docs/getting-started.html">Getting Started</a> section and installed and configured Juju.
36+ </p>
37+ <h2 id="basic-usage-of-the-ruby-on-rails-charm">
38+ Basic Usage of the Ruby on Rails Charm
39+ </h2>
40+ <p>
41+ Create a YAML config file with your application&acirc;&euro;&trade;s name and it&acirc;&euro;&trade;s git location
42+ </p>
43+ <p>
44+ <strong>sample-app.yml</strong>
45+ </p>
46+ <pre>
47+<code>sample-app:
48+ repo: https://github.com/pavelpachkovskij/sample-rails</code>
49+</pre>
50+ <p>
51+ Deploy the application and a proxy:
52+ </p>
53+ <pre>
54+<code>juju deploy rails myapp --config sample-app.yml
55+juju deploy haproxy
56+juju add-relation haproxy myapp</code>
57+</pre>
58+ <p>
59+ Deploy and relate database
60+ </p>
61+ <pre>
62+<code>juju deploy postgresql
63+juju add-relation postgresql:db myapp</code>
64+</pre>
65+ <p>
66+ Now you can run migrations:
67+ </p>
68+ <pre>
69+<code>juju ssh myapp/0 run rake db:migrate</code>
70+</pre>
71+ <p>
72+ Seed database
73+ </p>
74+ <pre>
75+<code>juju ssh myapp/0 run rake db:seed</code>
76+</pre>
77+ <p>
78+ And finally expose the proxy:
79+ </p>
80+ <pre>
81+<code>juju expose haproxy</code>
82+</pre>
83+ <p>
84+ Find the instance&acirc;&euro;&trade;s public URL from
85+ </p>
86+ <pre>
87+<code>juju status haproxy</code>
88+</pre>
89+ <p>
90+ Scale horizontally by adding and removing units:
91+ </p>
92+ <pre>
93+<code>juju add-unit myapp
94+juju remove-unit myapp</code>
95+</pre>
96+ <p>
97+ Or go even larger with <code>juju add-unit -n10 myapp</code> for 10 nodes.
98+ </p>
99+ <h2 id="local-to-cloud-workflow">
100+ Local to Cloud Workflow
101+ </h2>
102+ <p>
103+ The previous example deploys your application quickly to the cloud, in this example we will show how to hack and test on an application locally on your laptop and then push out to the public cloud.
104+ </p>
105+ <p>
106+ We need to configure 2 environments, a local one and a public cloud one.
107+ </p>
108+ <ol style="list-style-type: decimal">
109+ <li>Configure the <a href="https://juju.ubuntu.com/docs/config-local.html">local provider</a> on your machine.
110+ </li>
111+ <li>Configure a public or private cloud on your machine.
112+ </li>
113+ </ol>
114+ <ul>
115+ <li>
116+ <a href="https://juju.ubuntu.com/docs/config-aws.html">AWS</a>
117+ </li>
118+ <li>
119+ <a href="https://juju.ubuntu.com/docs/config-hpcloud.html">HP Cloud</a>
120+ </li>
121+ <li>
122+ <a href="https://juju.ubuntu.com/docs/config-openstack.html">OpenStack</a>
123+ </li>
124+ </ul>
125+ <p>
126+ In this example the local environment is named <code>local</code> and we&acirc;&euro;&trade;ll deploy to an AWS environment called <code>amazon</code>. First let&acirc;&euro;&trade;s <code>switch</code> to the local environment and bootstrap.
127+ </p>
128+ <pre>
129+<code>juju switch local
130+juju bootstrap</code>
131+</pre>
132+ <p>
133+ Create a YAML config file with your application&acirc;&euro;&trade;s name and it&acirc;&euro;&trade;s git location
134+ </p>
135+ <p>
136+ <strong>sample-app.yml</strong>
137+ </p>
138+ <pre>
139+<code>sample-app:
140+ repo: https://github.com/pavelpachkovskij/sample-rails</code>
141+</pre>
142+ <p>
143+ Deploy the application and database:
144+ </p>
145+ <pre>
146+<code>juju deploy rails myapp --config sample-app.yml
147+juju deploy postgresql</code>
148+</pre>
149+ <p>
150+ and relate them
151+ </p>
152+ <pre>
153+<code>juju add-relation myapp postgresql</code>
154+</pre>
155+ <p>
156+ Now open up your browser and go to <code>http://localhost</code> to get your application loaded in your browser.
157+ </p>
158+ <h3 id="continuous-deployment">
159+ Continuous Deployment
160+ </h3>
161+ <p>
162+ Continue to write your code, push to git as you land features and fixes. When you&acirc;&euro;&trade;re ready to test it you can tell Juju to check the git repository again:
163+ </p>
164+ <pre>
165+<code>juju set myapp repo=https://github.com/yourapplication</code>
166+</pre>
167+ <p>
168+ The charm will then fetch the latest code and you can refresh your browser at <code>http://localhost</code>.
169+ </p>
170+ <p>
171+ Repeat pushing to git and using the juju set command to keep a live instance of your application running in your local environment.
172+ </p>
173+ <h3 id="push-to-your-publicprivate-cloud">
174+ Push to your Public/Private Cloud
175+ </h3>
176+ <p>
177+ After you&acirc;&euro;&trade;ve repeatedly upgraded your application locally it&acirc;&euro;&trade;s time to push it out to a place where your coworkers can see your app in all it&acirc;&euro;&trade;s glory, let&acirc;&euro;&trade;s push this to AWS. Same exact commands as before, just to a different environment:
178+ </p>
179+ <pre>
180+<code>juju switch amazon
181+juju bootstrap
182+juju deploy --config ~/myapp.yaml rails myapp
183+juju deploy postgresql
184+juju add-relation postgresql myapp</code>
185+</pre>
186+ <p>
187+ Since we&acirc;&euro;&trade;re on a public cloud and not on a local provider we need to explicitly expose the service and get its public IP:
188+ </p>
189+ <pre>
190+<code>juju expose myapp
191+juju status myapp</code>
192+</pre>
193+ <p>
194+ And put the ec2 URL in your browser. If you want to enable some horizontal scalability to your application you can do so, even after you&acirc;&euro;&trade;ve deployed!
195+ </p>
196+ <pre>
197+<code>juju deploy haproxy
198+juju add-relation haproxy myapp
199+juju expose haproxy
200+juju unexpose myapp</code>
201+</pre>
202+ <p>
203+ And then get the public IP from the haproxy instead (notice how we&acirc;&euro;&trade;ve unexposed your application so that only haproxy is serving the public internet):
204+ </p>
205+ <pre>
206+<code>juju status haproxy</code>
207+</pre>
208+ <p>
209+ Now you can <code>juju add-unit myapp</code> and <code>juju remove-unit myapp</code> based on load.
210+ </p>
211+ <h3 id="tearing-it-all-down">
212+ Tearing it all down
213+ </h3>
214+ <p>
215+ The local containers survive reboots and do not go away until you explicitly tear the environment down. Now that your coworkers have seen your great application let&acirc;&euro;&trade;s also stop spending money:
216+ </p>
217+ <pre>
218+<code>juju destroy-environment -eamazon
219+juju destroy-environment -local</code>
220+</pre>
221+ <h2 id="charm-details">
222+ Charm Details
223+ </h2>
224+ <p>
225+ This document just scratches the surface of what is possible with the Rails charm, for more deployment options, including support for more databases, integrated logging with Logstash/Kibana, and Nagios integration, make sure you check out the <a href="https://jujucharms.com/precise/rails-HEAD/">Charm README</a> for more information.
226+ </p>
227+
228+
229+ </section>
230+
231+ </article>
232+ </section>
233+ <div class="shadow"></div>
234+ <footer class="global clearfix" role="contentinfo">
235+ <div class="row">
236+ <div class="inner-wrapper">
237+ <nav role="navigation" class="clearfix">
238+ <ul class="footer-a">
239+ <li class="grid-3 first-col">
240+ <h4><a href="/get-started">Get started</a></h4>
241+ <ul>
242+ <li class="page_item page-item-20"><a href="https://juju.ubuntu.com/get-started/local/">Local</a></li>
243+ <li class="page_item page-item-22"><a href="https://juju.ubuntu.com/get-started/amazon/">Amazon Web Services</a></li>
244+ <li class="page_item page-item-18"><a href="https://juju.ubuntu.com/get-started/hp-cloud/">HP Cloud</a></li>
245+ <li class="page_item page-item-16"><a href="https://juju.ubuntu.com/get-started/rackspace/">Rackspace</a></li>
246+ <li class="page_item page-item-3596"><a href="https://juju.ubuntu.com/get-started/openstack/">Openstack</a></li>
247+ <li class="page_item page-item-3600"><a href="https://juju.ubuntu.com/get-started/maas/">MAAS</a></li>
248+ </ul>
249+ </li>
250+ <li class="grid-3">
251+ <h4><a href="/resources">Resources</a></h4>
252+ <ul>
253+ <li><a href="http://juju.ubuntu.com/docs">Documentation</a></li>
254+ <li><a href="/resources/videos/">Videos</a></li>
255+ <li><a href="http://uistage.jujucharms.com:8080/">Juju GUI demo site</a></li>
256+ </ul>
257+ </li>
258+ <li class="grid-3">
259+ <h4><a href="/community">Community</a></h4>
260+ <ul>
261+ <li class="page_item page-item-28"><a href="https://juju.ubuntu.com/community/juju-blog/">Juju Blog</a></li>
262+ <li class="page_item page-item-4262"><a href="https://juju.ubuntu.com/community/weekly-charm-meeting/">Weekly Charm Meeting</a></li>
263+ <li class="page_item page-item-4036"><a href="https://juju.ubuntu.com/community/charmers/">Charmers</a></li>
264+ <li><a href="https://lists.ubuntu.com/mailman/listinfo/juju">Mailing List</a></li>
265+ <li><a href="http://webchat.freenode.net/?channels=juju">Chat</a></li>
266+ <li><a href="http://askubuntu.com/questions/tagged/juju?sort=faq&pagesize=50">FAQ</a></li>
267+ </ul>
268+ </li>
269+ <li class="grid-3 last-col">
270+ <h4><a href="https://launchpad.net/juju">Code</a></h4>
271+ <ul>
272+ <li><a href="https://launchpad.net/juju-core">Juju Core</a></li>
273+ <li><a href="https://launchpad.net/charms">Charms</a></li>
274+ </ul>
275+ </li>
276+ </ul>
277+ </nav>
278+ </div>
279+ </div>
280+ <div class="row no-border">
281+ <div class="legal inner-wrapper">
282+ <p>&copy; 2013 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.</p>
283+ <p><a href="https://bugs.launchpad.net/juju-website/+filebug">Report a bug on this site</a></p>
284+ </div>
285+ </div>
286+</footer>
287+
288+ <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
289+ <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
290+ <script src="//d38yea5fb4e2oh.cloudfront.net/jquery.stacktack.min.js"></script>
291+ <script type="text/javascript" src="js/main.js"></script>
292+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
293+ </body>
294+</html>

Subscribers

People subscribed via source and target branches