github.com/tmlbl/deis@v1.0.2/docs/using_deis/using-dockerfiles.rst (about)

     1  :title: Deploying with Dockerfiles on Deis
     2  :description: How to deploy applications on Deis using Dockerfiles
     3  
     4  .. _using-dockerfiles:
     5  
     6  Using Dockerfiles
     7  =================
     8  Deis supports deploying applications via Dockerfiles.  A `Dockerfile`_ automates the steps for crafting a `Docker Image`_.
     9  Dockerfiles are incredibly powerful but require some extra work to define your exact application runtime environment.
    10  
    11  Prepare an Application
    12  ----------------------
    13  If you do not have an existing application, you can clone an example application that demonstrates the Dockerfile workflow.
    14  
    15  .. code-block:: console
    16  
    17      $ git clone https://github.com/deis/helloworld.git
    18      $ cd helloworld
    19  
    20  Dockerfile Requirements
    21  ^^^^^^^^^^^^^^^^^^^^^^^
    22  In order to deploy Dockerfile applications, they must conform to the following requirements:
    23  
    24   * The Dockerfile must EXPOSE only one port
    25   * The exposed port must be an HTTP service that can be connected to an HTTP router
    26   * A default CMD must be specified for running the container
    27  
    28  .. note::
    29  
    30      Dockerfiles which expose more than one port will hit `issue 1156`_.
    31  
    32  Create an Application
    33  ---------------------
    34  Use ``deis create`` to create an application on the :ref:`controller`.
    35  
    36  .. code-block:: console
    37  
    38      $ deis create
    39      Creating application... done, created folksy-offshoot
    40      Git remote deis added
    41  
    42  Push to Deploy
    43  --------------
    44  Use ``git push deis master`` to deploy your application.
    45  
    46  .. code-block:: console
    47  
    48      $ git push deis master
    49      Counting objects: 13, done.
    50      Delta compression using up to 8 threads.
    51      Compressing objects: 100% (13/13), done.
    52      Writing objects: 100% (13/13), 1.99 KiB | 0 bytes/s, done.
    53      Total 13 (delta 2), reused 0 (delta 0)
    54      -----> Building Docker image
    55      Uploading context 4.096 kB
    56      Uploading context
    57      Step 0 : FROM deis/base:latest
    58       ---> 60024338bc63
    59      Step 1 : MAINTAINER OpDemand <info@opdemand.com>
    60       ---> Using cache
    61       ---> 2af5ad7f28d6
    62      Step 2 : RUN wget -O /tmp/go1.2.1.linux-amd64.tar.gz -q https://go.googlecode.com/files/go1.2.1.linux-amd64.tar.gz
    63       ---> Using cache
    64       ---> cf9ef8c5caa7
    65      Step 3 : RUN tar -C /usr/local -xzf /tmp/go1.2.1.linux-amd64.tar.gz
    66       ---> Using cache
    67       ---> 515b1faf3bd8
    68      Step 4 : RUN mkdir -p /go
    69       ---> Using cache
    70       ---> ebf4927a00e9
    71      Step 5 : ENV GOPATH /go
    72       ---> Using cache
    73       ---> c6a276eded37
    74      Step 6 : ENV PATH /usr/local/go/bin:/go/bin:$PATH
    75       ---> Using cache
    76       ---> 2ba6f6c9f108
    77      Step 7 : ADD . /go/src/github.com/deis/helloworld
    78       ---> 94ab7f4b977b
    79      Removing intermediate container 171b7d9fdb34
    80      Step 8 : RUN cd /go/src/github.com/deis/helloworld && go install -v .
    81       ---> Running in 0c8fbb2d2812
    82      github.com/deis/helloworld
    83       ---> 13b5af931393
    84      Removing intermediate container 0c8fbb2d2812
    85      Step 9 : ENV PORT 80
    86       ---> Running in 9b07da36a272
    87       ---> 2dce83167874
    88      Removing intermediate container 9b07da36a272
    89      Step 10 : CMD ["/go/bin/helloworld"]
    90       ---> Running in f7b215199940
    91       ---> b1e55ce5195a
    92      Removing intermediate container f7b215199940
    93      Step 11 : EXPOSE 80
    94       ---> Running in 7eb8ec45dcb0
    95       ---> ea1a8cc93ca3
    96      Removing intermediate container 7eb8ec45dcb0
    97      Successfully built ea1a8cc93ca3
    98      -----> Pushing image to private registry
    99  
   100             Launching... done, v2
   101  
   102      -----> folksy-offshoot deployed to Deis
   103             http://folksy-offshoot.local.deisapp.com
   104  
   105             To learn more, use `deis help` or visit http://deis.io
   106  
   107      To ssh://git@local.deisapp.com:2222/folksy-offshoot.git
   108       * [new branch]      master -> master
   109  
   110      $ curl -s http://folksy-offshoot.local.deisapp.com
   111      Welcome to Deis!
   112      See the documentation at http://docs.deis.io/ for more information.
   113  
   114  Because a Dockerfile application is detected, the ``cmd`` process type is automatically scaled to 1 on first deploy.
   115  
   116  Define Process Types
   117  --------------------
   118  Docker containers have a default command usually specified by a `CMD instruction`_.
   119  Deis uses the ``cmd`` process type to refer to this default command.
   120  
   121  Deis also supports scaling other process types as defined in a `Procfile`_.  To use this functionality, you must:
   122  
   123  1. Define process types with a `Procfile`_ in the root of your repository
   124  2. Include a ``start`` executable that can be called with: ``start <process-type>``
   125  
   126  
   127  .. _`Dockerfile`: https://docs.docker.com/reference/builder/
   128  .. _`Docker Image`: https://docs.docker.com/introduction/understanding-docker/
   129  .. _`CMD instruction`:  https://docs.docker.com/reference/builder/#cmd
   130  .. _`issue 1156`: https://github.com/deis/deis/issues/1156
   131  .. _`Procfile`: https://devcenter.heroku.com/articles/procfile