update
This commit is contained in:
commit
15319e86eb
15 changed files with 1125 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
.git-gh-pages
|
||||
10
Dockerfile
Normal file
10
Dockerfile
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
FROM stackbrew/ubuntu:13.10
|
||||
RUN apt-get -qq update && apt-get install -y ruby1.8 bundler python
|
||||
RUN locale-gen en_US.UTF-8
|
||||
ADD Gemfile /code/
|
||||
ADD Gemfile.lock /code/
|
||||
WORKDIR /code
|
||||
RUN bundle install
|
||||
ADD . /code
|
||||
EXPOSE 4000
|
||||
CMD bundle exec jekyll build
|
||||
3
Gemfile
Normal file
3
Gemfile
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'github-pages'
|
||||
62
Gemfile.lock
Normal file
62
Gemfile.lock
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
RedCloth (4.2.9)
|
||||
blankslate (2.1.2.4)
|
||||
classifier (1.3.3)
|
||||
fast-stemmer (>= 1.0.0)
|
||||
colorator (0.1)
|
||||
commander (4.1.5)
|
||||
highline (~> 1.6.11)
|
||||
fast-stemmer (1.0.2)
|
||||
ffi (1.9.3)
|
||||
github-pages (12)
|
||||
RedCloth (= 4.2.9)
|
||||
jekyll (= 1.4.2)
|
||||
kramdown (= 1.2.0)
|
||||
liquid (= 2.5.4)
|
||||
maruku (= 0.7.0)
|
||||
rdiscount (= 2.1.7)
|
||||
redcarpet (= 2.3.0)
|
||||
highline (1.6.20)
|
||||
jekyll (1.4.2)
|
||||
classifier (~> 1.3)
|
||||
colorator (~> 0.1)
|
||||
commander (~> 4.1.3)
|
||||
liquid (~> 2.5.2)
|
||||
listen (~> 1.3)
|
||||
maruku (~> 0.7.0)
|
||||
pygments.rb (~> 0.5.0)
|
||||
redcarpet (~> 2.3.0)
|
||||
safe_yaml (~> 0.9.7)
|
||||
toml (~> 0.1.0)
|
||||
kramdown (1.2.0)
|
||||
liquid (2.5.4)
|
||||
listen (1.3.1)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
rb-kqueue (>= 0.2)
|
||||
maruku (0.7.0)
|
||||
parslet (1.5.0)
|
||||
blankslate (~> 2.0)
|
||||
posix-spawn (0.3.8)
|
||||
pygments.rb (0.5.4)
|
||||
posix-spawn (~> 0.3.6)
|
||||
yajl-ruby (~> 1.1.0)
|
||||
rb-fsevent (0.9.4)
|
||||
rb-inotify (0.9.3)
|
||||
ffi (>= 0.5.0)
|
||||
rb-kqueue (0.2.0)
|
||||
ffi (>= 0.5.0)
|
||||
rdiscount (2.1.7)
|
||||
redcarpet (2.3.0)
|
||||
safe_yaml (0.9.7)
|
||||
toml (0.1.0)
|
||||
parslet (~> 1.5.0)
|
||||
yajl-ruby (1.1.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
github-pages
|
||||
127
cli.html
Normal file
127
cli.html
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-gb">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fig CLI reference</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/fig.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo mobile-logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</div>
|
||||
|
||||
<div class="content"><h1>CLI reference</h1>
|
||||
|
||||
<p>Most commands are run against one or more services. If the service is omitted, it will apply to all services.</p>
|
||||
|
||||
<p>Run <code>fig [COMMAND] --help</code> for full usage.</p>
|
||||
|
||||
<h2>build</h2>
|
||||
|
||||
<p>Build or rebuild services.</p>
|
||||
|
||||
<p>Services are built once and then tagged as <code>project_service</code>, e.g. <code>figtest_db</code>. If you change a service's <code>Dockerfile</code> or the contents of its build directory, you can run <code>fig build</code> to rebuild it.</p>
|
||||
|
||||
<h2>help</h2>
|
||||
|
||||
<p>Get help on a command.</p>
|
||||
|
||||
<h2>kill</h2>
|
||||
|
||||
<p>Force stop service containers.</p>
|
||||
|
||||
<h2>logs</h2>
|
||||
|
||||
<p>View output from services.</p>
|
||||
|
||||
<h2>ps</h2>
|
||||
|
||||
<p>List containers.</p>
|
||||
|
||||
<h2>rm</h2>
|
||||
|
||||
<p>Remove stopped service containers.</p>
|
||||
|
||||
<h2>run</h2>
|
||||
|
||||
<p>Run a one-off command on a service.</p>
|
||||
|
||||
<p>For example:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run web python manage.py shell
|
||||
</code></pre></div>
|
||||
<p>Note that this will not start any services that the command's service links to. So if, for example, your one-off command talks to your database, you will need to run <code>fig up -d db</code> first.</p>
|
||||
|
||||
<h2>scale</h2>
|
||||
|
||||
<p>Set number of containers to run for a service.</p>
|
||||
|
||||
<p>Numbers are specified in the form <code>service=num</code> as arguments.
|
||||
For example:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig scale web=2 worker=3
|
||||
</code></pre></div>
|
||||
<h2>start</h2>
|
||||
|
||||
<p>Start existing containers for a service.</p>
|
||||
|
||||
<h2>stop</h2>
|
||||
|
||||
<p>Stop running containers without removing them. They can be started again with <code>fig start</code>.</p>
|
||||
|
||||
<h2>up</h2>
|
||||
|
||||
<p>Build, (re)create, start and attach to containers for a service.</p>
|
||||
|
||||
<p>By default, <code>fig up</code> will aggregate the output of each container, and when it exits, all containers will be stopped. If you run <code>fig up -d</code>, it'll start the containers in the background and leave them running.</p>
|
||||
|
||||
<p>If there are existing containers for a service, <code>fig up</code> will stop and recreate them (preserving mounted volumes with <a href="http://docs.docker.io/en/latest/use/working_with_volumes/">volumes-from</a>), so that changes in <code>fig.yml</code> are picked up.</p>
|
||||
</div>
|
||||
|
||||
<div class="sidebar">
|
||||
<h1 class="logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</h1>
|
||||
|
||||
<ul class="nav">
|
||||
<li><a href="index.html">Home</a></li>
|
||||
<li><a href="install.html">Install</a></li>
|
||||
<li><a href="rails.html">Get started with Rails</a></li>
|
||||
<li><a href="django.html">Get started with Django</a></li>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li>Reference:</li>
|
||||
<ul>
|
||||
<li><a href="yml.html">fig.yml</a></li>
|
||||
<li><a href="cli.html">Commands</a></li>
|
||||
<li><a href="env.html">Environment variables</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li><a href="https://github.com/orchardup/fig">Fig on GitHub</a></li>
|
||||
<li><a href="https://twitter.com/orchardup">Follow us on Twitter</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="badges">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=orchardup&repo=fig&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://orchardup.github.io/fig/">Tweet</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-43996733-3', 'orchardup.github.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
7
css/bootstrap.min.css
vendored
Normal file
7
css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
167
css/fig.css
Normal file
167
css/fig.css
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
body {
|
||||
padding-top: 20px;
|
||||
padding-bottom: 60px;
|
||||
font-family: 'Lato', sans-serif;
|
||||
font-weight: 300;
|
||||
font-size: 18px;
|
||||
color: #362;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: 'Lato', sans-serif;
|
||||
font-weight: 400;
|
||||
color: #25594D;
|
||||
}
|
||||
|
||||
h2, h3, h4, h5, h6 {
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
a, a:hover, a:visited {
|
||||
color: #4D9900;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
border: none;
|
||||
background: #D5E1B4;
|
||||
}
|
||||
|
||||
code, pre code {
|
||||
color: #484F40;
|
||||
}
|
||||
|
||||
pre {
|
||||
border-bottom: 2px solid #bec9a1;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 0.84em;
|
||||
}
|
||||
|
||||
pre code {
|
||||
background: none;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-family: 'Lilita One', sans-serif;
|
||||
font-size: 80px;
|
||||
margin: 20px 0 40px 0;
|
||||
color: #a41211;
|
||||
}
|
||||
|
||||
.logo img {
|
||||
width: 80px;
|
||||
vertical-align: -17px;
|
||||
}
|
||||
|
||||
.mobile-logo {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.sidebar a {
|
||||
color: #a41211;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.sidebar {
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.sidebar .logo {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.mobile-logo {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.logo {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.content h1 {
|
||||
margin: 60px 0 55px 0;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 280px;
|
||||
overflow-y: auto;
|
||||
padding-left: 40px;
|
||||
border-right: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-left: 320px;
|
||||
max-width: 650px;
|
||||
}
|
||||
}
|
||||
|
||||
.nav {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.nav li a {
|
||||
display: block;
|
||||
padding: 8px 0;
|
||||
line-height: 1.2;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav li a:hover, .nav li a:focus {
|
||||
text-decoration: underline;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.nav ul {
|
||||
padding-left: 20px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.badges {
|
||||
margin: 40px 0;
|
||||
}
|
||||
|
||||
a.btn {
|
||||
background: #25594D;
|
||||
color: white;
|
||||
text-transform: uppercase;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.btn:hover {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.strapline {
|
||||
font-size: 40px;
|
||||
display: block;
|
||||
line-height: 1.2;
|
||||
margin-top: 25px;
|
||||
margin-bottom: 35px;
|
||||
}
|
||||
|
||||
138
django.html
Normal file
138
django.html
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-gb">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Getting started with Fig and Django</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/fig.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo mobile-logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</div>
|
||||
|
||||
<div class="content"><h1>Getting started with Fig and Django</h1>
|
||||
|
||||
<p>Let's use Fig to set up and run a Django/PostgreSQL app. Before starting, you'll need to have <a href="install.html">Fig installed</a>.</p>
|
||||
|
||||
<p>Let's set up the three files that'll get us started. First, our app is going to be running inside a Docker container which contains all of its dependencies. We can define what goes inside that Docker container using a file called <code>Dockerfile</code>. It'll contain this to start with:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">FROM orchardup/python:2.7
|
||||
RUN mkdir /code
|
||||
WORKDIR /code
|
||||
ADD requirements.txt /code/
|
||||
RUN pip install -r requirements.txt
|
||||
ADD . /code/
|
||||
</code></pre></div>
|
||||
<p>That'll install our application inside an image with Python installed alongside all of our Python dependencies.</p>
|
||||
|
||||
<p>Second, we define our Python dependencies in a file called <code>requirements.txt</code>:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">Django
|
||||
</code></pre></div>
|
||||
<p>Simple enough. Finally, this is all tied together with a file called <code>fig.yml</code>. It describes the services that our app comprises of (a web server and database), what Docker images they use, how they link together, what volumes will be mounted inside the containers and what ports they expose.</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">db:
|
||||
image: orchardup/postgresql
|
||||
ports:
|
||||
- 5432
|
||||
web:
|
||||
build: .
|
||||
command: python manage.py runserver 0.0.0.0:8000
|
||||
volumes:
|
||||
- .:/code
|
||||
ports:
|
||||
- 8000:8000
|
||||
links:
|
||||
- db
|
||||
</code></pre></div>
|
||||
<p>See the <a href=""><code>fig.yml</code> reference</a> for more information on how it works.</p>
|
||||
|
||||
<p>We can now start a Django project using <code>fig run</code>:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run web django-admin.py startproject figexample .
|
||||
</code></pre></div>
|
||||
<p>First, Fig will build an image for the <code>web</code> service using the <code>Dockerfile</code>. It will then run <code>django-admin.py startproject figexample .</code> inside a container using that image.</p>
|
||||
|
||||
<p>This will generate a Django app inside the current directory:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ ls
|
||||
Dockerfile fig.yml figexample manage.py requirements.txt
|
||||
</code></pre></div>
|
||||
<p>First thing we need to do is set up the database connection. Replace the <code>DATABASES = ...</code> definition in <code>figexample/settings.py</code> to read:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'docker',
|
||||
'USER': 'docker',
|
||||
'PASSWORD': 'docker',
|
||||
'HOST': os.environ.get('MYAPP_DB_1_PORT_5432_TCP_ADDR'),
|
||||
'PORT': os.environ.get('MYAPP_DB_1_PORT_5432_TCP_PORT'),
|
||||
}
|
||||
}
|
||||
</code></pre></div>
|
||||
<p>Then, run <code>fig up</code>:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">Recreating myapp_db_1...
|
||||
Recreating myapp_web_1...
|
||||
Attaching to myapp_db_1, myapp_web_1
|
||||
myapp_db_1 |
|
||||
myapp_db_1 | PostgreSQL stand-alone backend 9.1.11
|
||||
myapp_db_1 | 2014-01-27 12:17:03 UTC LOG: database system is ready to accept connections
|
||||
myapp_db_1 | 2014-01-27 12:17:03 UTC LOG: autovacuum launcher started
|
||||
myapp_web_1 | Validating models...
|
||||
myapp_web_1 |
|
||||
myapp_web_1 | 0 errors found
|
||||
myapp_web_1 | January 27, 2014 - 12:12:40
|
||||
myapp_web_1 | Django version 1.6.1, using settings 'figexample.settings'
|
||||
myapp_web_1 | Starting development server at http://0.0.0.0:8000/
|
||||
myapp_web_1 | Quit the server with CONTROL-C.
|
||||
</code></pre></div>
|
||||
<p>And your Django app should be running at localhost:3000 (or localdocker:3000 if you're using docker-osx).</p>
|
||||
|
||||
<p>You can also run management commands with Docker. To set up your database, for example, run <code>fig up</code> and in other terminal run:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run web python manage.py syncdb
|
||||
</code></pre></div></div>
|
||||
|
||||
<div class="sidebar">
|
||||
<h1 class="logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</h1>
|
||||
|
||||
<ul class="nav">
|
||||
<li><a href="index.html">Home</a></li>
|
||||
<li><a href="install.html">Install</a></li>
|
||||
<li><a href="rails.html">Get started with Rails</a></li>
|
||||
<li><a href="django.html">Get started with Django</a></li>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li>Reference:</li>
|
||||
<ul>
|
||||
<li><a href="yml.html">fig.yml</a></li>
|
||||
<li><a href="cli.html">Commands</a></li>
|
||||
<li><a href="env.html">Environment variables</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li><a href="https://github.com/orchardup/fig">Fig on GitHub</a></li>
|
||||
<li><a href="https://twitter.com/orchardup">Follow us on Twitter</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="badges">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=orchardup&repo=fig&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://orchardup.github.io/fig/">Tweet</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-43996733-3', 'orchardup.github.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
84
env.html
Normal file
84
env.html
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-gb">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fig environment variables reference</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/fig.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo mobile-logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</div>
|
||||
|
||||
<div class="content"><h1>Environment variables reference</h1>
|
||||
|
||||
<p>Fig uses <a href="http://docs.docker.io/en/latest/use/port_redirection/#linking-a-container">Docker links</a> to expose services' containers to one another. Each linked container injects a set of environment variables, each of which begins with the uppercase name of the container.</p>
|
||||
|
||||
<p><b><i>name</i>_PORT</b><br>
|
||||
Full URL, e.g. <code>MYAPP_DB_1_PORT=tcp://172.17.0.5:5432</code></p>
|
||||
|
||||
<p><b><i>name</i>_PORT_<i>num</i>_<i>protocol</i></b><br>
|
||||
Full URL, e.g. <code>MYAPP_DB_1_PORT_5432_TCP=tcp://172.17.0.5:5432</code></p>
|
||||
|
||||
<p><b><i>name</i>_PORT_<i>num</i>_<i>protocol</i>_ADDR</b><br>
|
||||
Container's IP address, e.g. <code>MYAPP_DB_1_PORT_5432_TCP_ADDR=172.17.0.5</code></p>
|
||||
|
||||
<p><b><i>name</i>_PORT_<i>num</i>_<i>protocol</i>_PORT</b><br>
|
||||
Exposed port number, e.g. <code>MYAPP_DB_1_PORT_5432_TCP_PORT=5432</code></p>
|
||||
|
||||
<p><b><i>name</i>_PORT_<i>num</i>_<i>protocol</i>_PROTO</b><br>
|
||||
Protocol (tcp or udp), e.g. <code>MYAPP_DB_1_PORT_5432_TCP_PROTO=tcp</code></p>
|
||||
|
||||
<p><b><i>name</i>_NAME</b><br>
|
||||
Fully qualified container name, e.g. <code>MYAPP_DB_1_NAME=/myapp_web_1/myapp_db_1</code></p>
|
||||
</div>
|
||||
|
||||
<div class="sidebar">
|
||||
<h1 class="logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</h1>
|
||||
|
||||
<ul class="nav">
|
||||
<li><a href="index.html">Home</a></li>
|
||||
<li><a href="install.html">Install</a></li>
|
||||
<li><a href="rails.html">Get started with Rails</a></li>
|
||||
<li><a href="django.html">Get started with Django</a></li>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li>Reference:</li>
|
||||
<ul>
|
||||
<li><a href="yml.html">fig.yml</a></li>
|
||||
<li><a href="cli.html">Commands</a></li>
|
||||
<li><a href="env.html">Environment variables</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li><a href="https://github.com/orchardup/fig">Fig on GitHub</a></li>
|
||||
<li><a href="https://twitter.com/orchardup">Follow us on Twitter</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="badges">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=orchardup&repo=fig&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://orchardup.github.io/fig/">Tweet</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-43996733-3', 'orchardup.github.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
8
fig.yml
Normal file
8
fig.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
jekyll:
|
||||
build: .
|
||||
ports:
|
||||
- 4000:4000
|
||||
volumes:
|
||||
- .:/code
|
||||
environment:
|
||||
- LANG=en_US.UTF-8
|
||||
BIN
img/logo.png
Normal file
BIN
img/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
200
index.html
Normal file
200
index.html
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-gb">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fig | Punctual, lightweight development environments using Docker</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/fig.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo mobile-logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</div>
|
||||
|
||||
<div class="content"><p><strong class="strapline">Fast, isolated development environments using Docker.</strong></p>
|
||||
|
||||
<p>Define your app's environment with Docker so it can be reproduced anywhere.</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">FROM orchardup/python:2.7
|
||||
ADD . /code
|
||||
RUN pip install -r requirements.txt
|
||||
WORKDIR /code
|
||||
CMD python app.py
|
||||
</code></pre></div>
|
||||
<p>Define your app's services so they can be run alongside in an isolated environment. (No more installing Postgres on your laptop!)</p>
|
||||
<div class="highlight"><pre><code class="yaml language-yaml" data-lang="yaml"><span class="l-Scalar-Plain">web</span><span class="p-Indicator">:</span>
|
||||
<span class="l-Scalar-Plain">build</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">.</span>
|
||||
<span class="l-Scalar-Plain">links</span><span class="p-Indicator">:</span>
|
||||
<span class="p-Indicator">-</span> <span class="l-Scalar-Plain">db</span>
|
||||
<span class="l-Scalar-Plain">ports</span><span class="p-Indicator">:</span>
|
||||
<span class="p-Indicator">-</span> <span class="l-Scalar-Plain">8000:8000</span>
|
||||
<span class="l-Scalar-Plain">db</span><span class="p-Indicator">:</span>
|
||||
<span class="l-Scalar-Plain">image</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">orchardup/postgresql</span>
|
||||
</code></pre></div>
|
||||
<p>Then type <code>fig up</code>, and Fig will start and run your entire app:</p>
|
||||
|
||||
<p><img src="https://orchardup.com/static/images/fig-example-large.f96065fc9e22.gif" alt="example fig run"></p>
|
||||
|
||||
<p>There are commands to:</p>
|
||||
|
||||
<ul>
|
||||
<li>start, stop and rebuild services</li>
|
||||
<li>view the status of running services</li>
|
||||
<li>tail running services' log output</li>
|
||||
<li>run a one-off command on a service</li>
|
||||
</ul>
|
||||
|
||||
<p>Fig is a project from <a href="https://orchardup.com">Orchard</a>. <a href="https://twitter.com/orchardup">Follow us on Twitter</a> to keep up to date with Fig and other Docker news.</p>
|
||||
|
||||
<h2>Quick start</h2>
|
||||
|
||||
<p>Let's get a basic Python web app running on Fig. It assumes a little knowledge of Python, but the concepts should be clear if you're not familiar with it.</p>
|
||||
|
||||
<p>First, install Docker. If you're on OS X, you can use <a href="https://github.com/noplay/docker-osx">docker-osx</a>:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ curl https://raw.github.com/noplay/docker-osx/master/docker-osx > /usr/local/bin/docker-osx
|
||||
$ chmod +x /usr/local/bin/docker-osx
|
||||
$ docker-osx shell
|
||||
</code></pre></div>
|
||||
<p>Docker has guides for <a href="http://docs.docker.io/en/latest/installation/ubuntulinux/">Ubuntu</a> and <a href="http://docs.docker.io/en/latest/installation/">other platforms</a> in their documentation.</p>
|
||||
|
||||
<p>Next, install Fig:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ sudo pip install -U fig
|
||||
</code></pre></div>
|
||||
<p>(This command also upgrades Fig when we release a new version. If you don’t have pip installed, try <code>brew install python</code> or <code>apt-get install python-pip</code>.)</p>
|
||||
|
||||
<p>You'll want to make a directory for the project:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ mkdir figtest
|
||||
$ cd figtest
|
||||
</code></pre></div>
|
||||
<p>Inside this directory, create <code>app.py</code>, a simple web app that uses the Flask framework and increments a value in Redis:</p>
|
||||
<div class="highlight"><pre><code class="python language-python" data-lang="python"><span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">Flask</span>
|
||||
<span class="kn">from</span> <span class="nn">redis</span> <span class="kn">import</span> <span class="n">Redis</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="n">app</span> <span class="o">=</span> <span class="n">Flask</span><span class="p">(</span><span class="n">__name__</span><span class="p">)</span>
|
||||
<span class="n">redis</span> <span class="o">=</span> <span class="n">Redis</span><span class="p">(</span>
|
||||
<span class="n">host</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'FIGTEST_REDIS_1_PORT_6379_TCP_ADDR'</span><span class="p">),</span>
|
||||
<span class="n">port</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'FIGTEST_REDIS_1_PORT_6379_TCP_PORT'</span><span class="p">))</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="nd">@app.route</span><span class="p">(</span><span class="s">'/'</span><span class="p">)</span>
|
||||
<span class="k">def</span> <span class="nf">hello</span><span class="p">():</span>
|
||||
<span class="n">redis</span><span class="o">.</span><span class="n">incr</span><span class="p">(</span><span class="s">'hits'</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="s">'Hello World! I have been seen </span><span class="si">%s</span><span class="s"> times.'</span> <span class="o">%</span> <span class="n">redis</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'hits'</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="s">"0.0.0.0"</span><span class="p">,</span> <span class="n">debug</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
|
||||
</code></pre></div>
|
||||
<p>We define our Python dependencies in a file called <code>requirements.txt</code>:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">flask
|
||||
redis
|
||||
</code></pre></div>
|
||||
<p>And we define how to build this into a Docker image using a file called <code>Dockerfile</code>:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">FROM stackbrew/ubuntu:13.10
|
||||
RUN apt-get -qq update
|
||||
RUN apt-get install -y python python-pip
|
||||
ADD . /code
|
||||
WORKDIR /code
|
||||
RUN pip install -r requirements.txt
|
||||
EXPOSE 5000
|
||||
CMD python app.py
|
||||
</code></pre></div>
|
||||
<p>That tells Docker to create an image with Python and Flask installed on it, run the command <code>python app.py</code>, and open port 5000 (the port that Flask listens on).</p>
|
||||
|
||||
<p>We then define a set of services using <code>fig.yml</code>:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">web:
|
||||
build: .
|
||||
ports:
|
||||
- 5000:5000
|
||||
volumes:
|
||||
- .:/code
|
||||
links:
|
||||
- redis
|
||||
redis:
|
||||
image: orchardup/redis
|
||||
</code></pre></div>
|
||||
<p>This defines two services:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>web</code>, which is built from <code>Dockerfile</code> in the current directory. It also says to forward the exposed port 5000 on the container to port 5000 on the host machine, connect up the Redis service, and mount the current directory inside the container so we can work on code without having to rebuild the image.</li>
|
||||
<li><code>redis</code>, which uses the public image <a href="https://index.docker.io/u/orchardup/redis/">orchardup/redis</a>. </li>
|
||||
</ul>
|
||||
|
||||
<p>Now if we run <code>fig up</code>, it'll pull a Redis image, build an image for our own code, and start everything up:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig up
|
||||
Pulling image orchardup/redis...
|
||||
Building web...
|
||||
Starting figtest_redis_1...
|
||||
Starting figtest_web_1...
|
||||
figtest_redis_1 | [8] 02 Jan 18:43:35.576 # Server started, Redis version 2.8.3
|
||||
figtest_web_1 | * Running on http://0.0.0.0:5000/
|
||||
</code></pre></div>
|
||||
<p>Open up <a href="http://localhost:5000">http://localhost:5000</a> in your browser (or <a href="http://localdocker:5000">http://localdocker:5000</a> if you're using <a href="https://github.com/noplay/docker-osx">docker-osx</a>) and you should see it running!</p>
|
||||
|
||||
<p>If you want to run your services in the background, you can pass the <code>-d</code> flag to <code>fig up</code> and use <code>fig ps</code> to see what is currently running:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig up -d
|
||||
Starting figtest_redis_1...
|
||||
Starting figtest_web_1...
|
||||
$ fig ps
|
||||
Name Command State Ports
|
||||
-------------------------------------------------------------------
|
||||
figtest_redis_1 /usr/local/bin/run Up
|
||||
figtest_web_1 /bin/sh -c python app.py Up 5000->5000/tcp
|
||||
</code></pre></div>
|
||||
<p><code>fig run</code> allows you to run one-off commands for your services. For example, to see what environment variables are available to the <code>web</code> service:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run web env
|
||||
</code></pre></div>
|
||||
<p>See <code>fig --help</code> other commands that are available.</p>
|
||||
|
||||
<p>If you started Fig with <code>fig up -d</code>, you'll probably want to stop your services once you've finished with them:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig stop
|
||||
</code></pre></div>
|
||||
<p>That's more-or-less how Fig works. See the reference section below for full details on the commands, configuration file and environment variables. If you have any thoughts or suggestions, <a href="https://github.com/orchardup/fig">open an issue on GitHub</a> or <a href="mailto:hello@orchardup.com">email us</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="sidebar">
|
||||
<h1 class="logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</h1>
|
||||
|
||||
<ul class="nav">
|
||||
<li><a href="index.html">Home</a></li>
|
||||
<li><a href="install.html">Install</a></li>
|
||||
<li><a href="rails.html">Get started with Rails</a></li>
|
||||
<li><a href="django.html">Get started with Django</a></li>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li>Reference:</li>
|
||||
<ul>
|
||||
<li><a href="yml.html">fig.yml</a></li>
|
||||
<li><a href="cli.html">Commands</a></li>
|
||||
<li><a href="env.html">Environment variables</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li><a href="https://github.com/orchardup/fig">Fig on GitHub</a></li>
|
||||
<li><a href="https://twitter.com/orchardup">Follow us on Twitter</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="badges">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=orchardup&repo=fig&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://orchardup.github.io/fig/">Tweet</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-43996733-3', 'orchardup.github.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
78
install.html
Normal file
78
install.html
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-gb">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Installing Fig</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/fig.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo mobile-logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</div>
|
||||
|
||||
<div class="content"><h1>Installing Fig</h1>
|
||||
|
||||
<p>First, install Docker. If you're on OS X, you can use <a href="https://github.com/noplay/docker-osx">docker-osx</a>:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ curl https://raw.github.com/noplay/docker-osx/master/docker-osx > /usr/local/bin/docker-osx
|
||||
$ chmod +x /usr/local/bin/docker-osx
|
||||
$ docker-osx shell
|
||||
</code></pre></div>
|
||||
<p>Docker has guides for <a href="http://docs.docker.io/en/latest/installation/ubuntulinux/">Ubuntu</a> and <a href="http://docs.docker.io/en/latest/installation/">other platforms</a> in their documentation.</p>
|
||||
|
||||
<p>Next, install Fig:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ sudo pip install -U fig
|
||||
</code></pre></div>
|
||||
<p>(This command also upgrades Fig when we release a new version. If you don’t have pip installed, try <code>brew install python</code> or <code>apt-get install python-pip</code>.)</p>
|
||||
|
||||
<p>That should be all you need! Run <code>fig --version</code> to see if it worked.</p>
|
||||
</div>
|
||||
|
||||
<div class="sidebar">
|
||||
<h1 class="logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</h1>
|
||||
|
||||
<ul class="nav">
|
||||
<li><a href="index.html">Home</a></li>
|
||||
<li><a href="install.html">Install</a></li>
|
||||
<li><a href="rails.html">Get started with Rails</a></li>
|
||||
<li><a href="django.html">Get started with Django</a></li>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li>Reference:</li>
|
||||
<ul>
|
||||
<li><a href="yml.html">fig.yml</a></li>
|
||||
<li><a href="cli.html">Commands</a></li>
|
||||
<li><a href="env.html">Environment variables</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li><a href="https://github.com/orchardup/fig">Fig on GitHub</a></li>
|
||||
<li><a href="https://twitter.com/orchardup">Follow us on Twitter</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="badges">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=orchardup&repo=fig&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://orchardup.github.io/fig/">Tweet</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-43996733-3', 'orchardup.github.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
144
rails.html
Normal file
144
rails.html
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-gb">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Getting started with Fig and Rails</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/fig.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo mobile-logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</div>
|
||||
|
||||
<div class="content"><h1>Getting started with Fig and Rails</h1>
|
||||
|
||||
<p>We're going to use Fig to set up and run a Rails/PostgreSQL app. Before starting, you'll need to have <a href="install.html">Fig installed</a>.</p>
|
||||
|
||||
<p>Let's set up the three files that'll get us started. First, our app is going to be running inside a Docker container which contains all of its dependencies. We can define what goes inside that Docker container using a file called <code>Dockerfile</code>. It'll contain this to start with:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">FROM binaryphile/ruby:2.0.0-p247
|
||||
RUN mkdir /myapp
|
||||
WORKDIR /myapp
|
||||
ADD Gemfile /myapp/Gemfile
|
||||
RUN bundle install
|
||||
ADD . /myapp
|
||||
</code></pre></div>
|
||||
<p>That'll put our application code inside an image with Ruby, Bundler and all our dependencies.</p>
|
||||
|
||||
<p>Next, we have a bootstrap <code>Gemfile</code> which just loads Rails. It'll be overwritten in a moment by <code>rails new</code>.</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">source 'https://rubygems.org'
|
||||
gem 'rails', '4.0.2'
|
||||
</code></pre></div>
|
||||
<p>Finally, <code>fig.yml</code> is where the magic happens. It describes what services our app comprises (a database and a web app), how to get each one's Docker image (the database just runs on a pre-made PostgreSQL image, and the web app is built from the current directory), and the configuration we need to link them together and expose the web app's port.</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">db:
|
||||
image: orchardup/postgresql
|
||||
ports:
|
||||
- 5432
|
||||
web:
|
||||
build: .
|
||||
command: bundle exec rackup -p 3000
|
||||
volumes:
|
||||
- .:/myapp
|
||||
ports:
|
||||
- 3000:3000
|
||||
links:
|
||||
- db
|
||||
</code></pre></div>
|
||||
<p>With those files in place, we can now generate the Rails skeleton app using <code>fig run</code>:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run web rails new . --force --database=postgresql --skip-bundle
|
||||
</code></pre></div>
|
||||
<p>First, Fig will build the image for the <code>web</code> service using the <code>Dockerfile</code>. Then it'll run <code>rails new</code> inside a new container, using that image. Once it's done, you should have a fresh app generated:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ ls
|
||||
Dockerfile app fig.yml tmp
|
||||
Gemfile bin lib vendor
|
||||
Gemfile.lock config log
|
||||
README.rdoc config.ru public
|
||||
Rakefile db test
|
||||
</code></pre></div>
|
||||
<p>Uncomment the line in your new <code>Gemfile</code> which loads <code>therubyracer</code>, so we've got a Javascript runtime:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">gem 'therubyracer', platforms: :ruby
|
||||
</code></pre></div>
|
||||
<p>Now that we've got a new <code>Gemfile</code>, we need to build the image again. (This, and changes to the Dockerfile itself, should be the only times you'll need to rebuild).</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig build
|
||||
</code></pre></div>
|
||||
<p>The app is now bootable, but we're not quite there yet. By default, Rails expects a database to be running on <code>localhost</code> - we need to point it at the <code>db</code> container instead. We also need to change the username and password to align with the defaults set by <code>orchardup/postgresql</code>.</p>
|
||||
|
||||
<p>Open up your newly-generated <code>database.yml</code>. Replace its contents with the following:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">development: &default
|
||||
adapter: postgresql
|
||||
encoding: unicode
|
||||
database: myapp_development
|
||||
pool: 5
|
||||
username: docker
|
||||
password: docker
|
||||
host: <%= ENV.fetch('MYAPP_DB_1_PORT_5432_TCP_ADDR', 'localhost') %>
|
||||
port: <%= ENV.fetch('MYAPP_DB_1_PORT_5432_TCP_PORT', '5432') %>
|
||||
|
||||
test:
|
||||
<<: *default
|
||||
database: myapp_test
|
||||
</code></pre></div>
|
||||
<p>We can now boot the app.</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig up
|
||||
</code></pre></div>
|
||||
<p>If all's well, you should see some PostgreSQL output, and then—after a few seconds—the familiar refrain:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">myapp_web_1 | [2014-01-17 17:16:29] INFO WEBrick 1.3.1
|
||||
myapp_web_1 | [2014-01-17 17:16:29] INFO ruby 2.0.0 (2013-11-22) [x86_64-linux-gnu]
|
||||
myapp_web_1 | [2014-01-17 17:16:29] INFO WEBrick::HTTPServer#start: pid=1 port=3000
|
||||
</code></pre></div>
|
||||
<p>Finally, we just need to create the database. In another terminal, run:</p>
|
||||
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run web rake db:create
|
||||
</code></pre></div>
|
||||
<p>And we're rolling—see for yourself at <a href="http://localhost:3000">localhost:3000</a> (or <a href="http://localdocker:3000">localdocker:3000</a> if you're using docker-osx).</p>
|
||||
|
||||
<p><img src="https://orchardup.com/static/images/fig-rails-screenshot.png" alt="Screenshot of Rails' stock index.html"></p>
|
||||
</div>
|
||||
|
||||
<div class="sidebar">
|
||||
<h1 class="logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</h1>
|
||||
|
||||
<ul class="nav">
|
||||
<li><a href="index.html">Home</a></li>
|
||||
<li><a href="install.html">Install</a></li>
|
||||
<li><a href="rails.html">Get started with Rails</a></li>
|
||||
<li><a href="django.html">Get started with Django</a></li>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li>Reference:</li>
|
||||
<ul>
|
||||
<li><a href="yml.html">fig.yml</a></li>
|
||||
<li><a href="cli.html">Commands</a></li>
|
||||
<li><a href="env.html">Environment variables</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li><a href="https://github.com/orchardup/fig">Fig on GitHub</a></li>
|
||||
<li><a href="https://twitter.com/orchardup">Follow us on Twitter</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="badges">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=orchardup&repo=fig&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://orchardup.github.io/fig/">Tweet</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-43996733-3', 'orchardup.github.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
96
yml.html
Normal file
96
yml.html
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-gb">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>fig.yml reference</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/fig.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo mobile-logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</div>
|
||||
|
||||
<div class="content"><h1>fig.yml reference</h1>
|
||||
|
||||
<p>Each service defined in <code>fig.yml</code> must specify exactly one of <code>image</code> or <code>build</code>. Other keys are optional, and are analogous to their <code>docker run</code> command-line counterparts.</p>
|
||||
|
||||
<p>As with <code>docker run</code>, options specified in the Dockerfile (e.g. <code>CMD</code>, <code>EXPOSE</code>, <code>VOLUME</code>, <code>ENV</code>) are respected by default - you don't need to specify them again in <code>fig.yml</code>.</p>
|
||||
<div class="highlight"><pre><code class="yaml language-yaml" data-lang="yaml"><span class="l-Scalar-Plain">-- Tag or partial image ID. Can be local or remote - Fig will attempt to pull if it doesn't exist locally.</span>
|
||||
<span class="l-Scalar-Plain">image</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">ubuntu</span>
|
||||
<span class="l-Scalar-Plain">image</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">orchardup/postgresql</span>
|
||||
<span class="l-Scalar-Plain">image</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">a4bc65fd</span>
|
||||
|
||||
<span class="l-Scalar-Plain">-- Path to a directory containing a Dockerfile. Fig will build and tag it with a generated name, and use that image thereafter.</span>
|
||||
<span class="l-Scalar-Plain">build</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">/path/to/build/dir</span>
|
||||
|
||||
<span class="l-Scalar-Plain">-- Override the default command.</span>
|
||||
<span class="l-Scalar-Plain">command</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">bundle exec thin -p 3000</span>
|
||||
|
||||
<span class="l-Scalar-Plain">-- Link to containers in another service (see "Communicating between containers").</span>
|
||||
<span class="l-Scalar-Plain">links</span><span class="p-Indicator">:</span>
|
||||
<span class="p-Indicator">-</span> <span class="l-Scalar-Plain">db</span>
|
||||
<span class="p-Indicator">-</span> <span class="l-Scalar-Plain">redis</span>
|
||||
|
||||
<span class="l-Scalar-Plain">-- Expose ports. Either specify both ports (HOST:CONTAINER), or just the container port (a random host port will be chosen).</span>
|
||||
<span class="l-Scalar-Plain">ports</span><span class="p-Indicator">:</span>
|
||||
<span class="p-Indicator">-</span> <span class="l-Scalar-Plain">3000</span>
|
||||
<span class="p-Indicator">-</span> <span class="l-Scalar-Plain">8000:8000</span>
|
||||
|
||||
<span class="l-Scalar-Plain">-- Map volumes from the host machine (HOST:CONTAINER).</span>
|
||||
<span class="l-Scalar-Plain">volumes</span><span class="p-Indicator">:</span>
|
||||
<span class="p-Indicator">-</span> <span class="l-Scalar-Plain">cache/:/tmp/cache</span>
|
||||
|
||||
<span class="l-Scalar-Plain">-- Add environment variables.</span>
|
||||
<span class="l-Scalar-Plain">environment</span><span class="p-Indicator">:</span>
|
||||
<span class="l-Scalar-Plain">RACK_ENV</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">development</span>
|
||||
</code></pre></div></div>
|
||||
|
||||
<div class="sidebar">
|
||||
<h1 class="logo">
|
||||
<img src="img/logo.png">
|
||||
Fig
|
||||
</h1>
|
||||
|
||||
<ul class="nav">
|
||||
<li><a href="index.html">Home</a></li>
|
||||
<li><a href="install.html">Install</a></li>
|
||||
<li><a href="rails.html">Get started with Rails</a></li>
|
||||
<li><a href="django.html">Get started with Django</a></li>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li>Reference:</li>
|
||||
<ul>
|
||||
<li><a href="yml.html">fig.yml</a></li>
|
||||
<li><a href="cli.html">Commands</a></li>
|
||||
<li><a href="env.html">Environment variables</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
<ul class="nav">
|
||||
<li><a href="https://github.com/orchardup/fig">Fig on GitHub</a></li>
|
||||
<li><a href="https://twitter.com/orchardup">Follow us on Twitter</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="badges">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=orchardup&repo=fig&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://orchardup.github.io/fig/">Tweet</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-43996733-3', 'orchardup.github.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue