Deploying Using a Buildpack

Deploying a Ruby Application

Now that we have a working Deis cluster, let's see Deis in action by deploying a sample Ruby app.

Clone the Deis example-ruby-sinatra app somewhere:

$ git clone git@github.com:deis/example-ruby-sinatra.git 
$ cd example-ruby-sinatra

We then create an app for Deis:

$ deis create
Creating application... done, created <random>-<words>
Git remote deis added

This will automatically add the Deis git remote:

We see that there's a new remote for pushing our app:

$ git remote -v
deis  ssh://git@deis.54.164.177.68.xip.io:2222/<random>-<words>.git (fetch)
deis  ssh://git@deis.54.164.177.68.xip.io:2222/<random>-<words>.git (push)
origin  git@github.com:deis/example-ruby-sinatra.git (fetch)
origin  git@github.com:deis/example-ruby-sinatra.git (push)

We can then deploy using git push:

$ git push deis master
Counting objects: 110, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (57/57), done.
Writing objects: 100% (110/110), 23.28 KiB | 0 bytes/s, done.
Total 110 (delta 47), reused 110 (delta 47)
-----> Ruby app detected
-----> Compiling Ruby/Rack
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using 1.7.12
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from http://rubygems.org/..........
       Using bundler 1.7.12
       Installing tilt 1.3.6
       Installing rack 1.5.2
       Installing rack-protection 1.5.0
       Installing sinatra 1.4.2
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Bundle completed (3.36s)
       Cleaning up the bundler cache.

-----> Discovering process types
       Procfile declares types -> web
       Default process types for Ruby -> rake, console, web
-----> Compiled slug size is 15M

-----> Building Docker image
remote: Sending build context to Docker daemon 15.09 MB
remote: build context to Docker daemon
Step 0 : FROM deis/slugrunner
 ---> 84828c0a7562
Step 1 : RUN mkdir -p /app
 ---> Running in e2ab6a1fd7bb
 ---> 322c62cb1a38
Removing intermediate container e2ab6a1fd7bb
Step 2 : WORKDIR /app
 ---> Running in cb47ac3e4226
 ---> f6c947361212
Removing intermediate container cb47ac3e4226
Step 3 : ENTRYPOINT /runner/init
 ---> Running in b04a7480d20d
 ---> 99d57affda58
Removing intermediate container b04a7480d20d
Step 4 : ADD slug.tgz /app
 ---> 411f6180993a
Removing intermediate container 0966164da96b
Step 5 : ENV GIT_SHA 6b1a9488ac7f37fab78e69b20118d48d6294b8f3
 ---> Running in 8204e135091e
 ---> 9d39bbb4c0a1
Removing intermediate container 8204e135091e
Successfully built 9d39bbb4c0a1
-----> Pushing image to private registry

-----> Launching...
       done, <random>-<words>:v2 deployed to Deis

       http://<random>-<words>.107.23.152.6.xip.io

       To learn more, use `deis help` or visit http://deis.io

To ssh://git@deis.<elb-IP>.xip.io:2222/<random>-<words>.git
 * [new branch]      master -> master

To verify that it deployed successfully, you can run deis open to pull up the site in your browser.

Deploying a PHP Application

This process is identical to deploying the Ruby application:

Clone the Deis example-php app somewhere:

$ git clone git@github.com:deis/example-php.git 
$ cd example-php

We then create an app for Deis:

$ deis create
Creating application... done, created <random>-<words>
Git remote deis added

This will automatically add the Deis git remote:

We see that there's a new remote for pushing our app:

$ git remote -v
deis  ssh://git@deis.54.164.177.68.xip.io:2222/<random>-<words>.git (fetch)
deis  ssh://git@deis.54.164.177.68.xip.io:2222/<random>-<words>.git (push)
origin  git@github.com:deis/example-php.git (fetch)
origin  git@github.com:deis/example-php.git (push)

We can then deploy using git push:

$ git push deis master
Counting objects: 218, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (157/157), done.
Writing objects: 100% (218/218), 368.95 KiB | 0 bytes/s, done.
Total 218 (delta 52), reused 218 (delta 52)
-----> PHP app detected
-----> Resolved composer.lock requirement for PHP to version 5.6.4.
-----> Installing system packages...
       - PHP 5.6.4
       - Apache 2.4.10
       - Nginx 1.6.0
-----> Installing PHP extensions...
       - zend-opcache (automatic; bundled)
-----> Installing dependencies...
       Composer version 1.0.0-alpha10 2015-04-14 21:18:51
Loading composer repositories with package information
Installing dependencies from lock file
  - Installing slim/slim (2.6.2)
    Downloading: 100%

Generating optimized autoload files
-----> Preparing runtime environment...
-----> Discovering process types
       Procfile declares types -> web
       Default process types for PHP -> web
-----> Compiled slug size is 72M

-----> Building Docker image
remote: Sending build context to Docker daemon 75.23 MB
remote: build context to Docker daemon
Step 0 : FROM deis/slugrunner
 ---> 84828c0a7562
Step 1 : RUN mkdir -p /app
 ---> Using cache
 ---> 322c62cb1a38
Step 2 : WORKDIR /app
 ---> Using cache
 ---> f6c947361212
Step 3 : ENTRYPOINT /runner/init
 ---> Using cache
 ---> 99d57affda58
Step 4 : ADD slug.tgz /app
 ---> f33397529d55
Removing intermediate container f04e32ac723c
Step 5 : ENV GIT_SHA f6a3d7266ff307c51d7bd7515ae2dca47306104f
 ---> Running in 5e4e398e429c
 ---> 88ae870d4969
Removing intermediate container 5e4e398e429c
Successfully built 88ae870d4969
-----> Pushing image to private registry

-----> Launching...
       done, <random>-<words>:v2 deployed to Deis

       http://<random>-<words>.<elb-IP>.xip.io

       To learn more, use `deis help` or visit http://deis.io

To ssh://git@deis.<elb-IP>.xip.io:2222/<random>-<words>.git
 * [new branch]      master -> master

To verify that it deployed successfully, you can run deis open to pull up the site in your browser.