github.com/greenboxal/deis@v1.12.1/docs/using_deis/config-application.rst (about) 1 :title: Configure an Application on Deis 2 :description: Instructions for developers using Deis to configure applications. 3 4 .. _config-application: 5 6 Configure an Application 7 ======================== 8 A Deis application `stores config in environment variables`_. 9 10 Configure the Application 11 ------------------------- 12 Use ``deis config`` to modify environment variables for a deployed application. 13 14 .. code-block:: console 15 16 $ deis help config 17 Valid commands for config: 18 19 config:list list environment variables for an app 20 config:set set environment variables for an app 21 config:unset unset environment variables for an app 22 config:pull extract environment variables to .env 23 config:push set environment variables from .env 24 25 Use `deis help [command]` to learn more. 26 27 When config is changed, a new release is created and deployed automatically. 28 29 You can set multiple environment variables with one ``deis config:set`` command, 30 or with ``deis config:push`` and a local .env file. 31 32 .. code-block:: console 33 34 $ deis config:set FOO=1 BAR=baz && deis config:pull 35 $ cat .env 36 FOO=1 37 BAR=baz 38 $ echo "TIDE=high" >> .env 39 $ deis config:push 40 Creating config... done, v4 41 42 === yuppie-earthman 43 DEIS_APP: yuppie-earthman 44 FOO: 1 45 BAR: baz 46 TIDE: high 47 48 49 Attach to Backing Services 50 -------------------------- 51 Deis treats backing services like databases, caches and queues as `attached resources`_. 52 Attachments are performed using environment variables. 53 54 For example, use ``deis config`` to set a `DATABASE_URL` that attaches 55 the application to an external PostgreSQL database. 56 57 .. code-block:: console 58 59 $ deis config:set DATABASE_URL=postgres://user:pass@example.com:5432/db 60 === peachy-waxworks 61 DATABASE_URL: postgres://user:pass@example.com:5432/db 62 63 Detachments can be performed with ``deis config:unset``. 64 65 Custom Domains 66 -------------- 67 68 You can use ``deis domains`` to add or remove custom domains to your application: 69 70 .. code-block:: console 71 72 $ deis domains:add hello.bacongobbler.com 73 Adding hello.bacongobbler.com to finest-woodshed... done 74 75 Once that's done, you can go into your DNS registrar and set up a CNAME from the new 76 appname to the old one: 77 78 .. code-block:: console 79 80 $ dig hello.deisapp.com 81 [...] 82 ;; ANSWER SECTION: 83 hello.bacongobbler.com. 1759 IN CNAME finest-woodshed.deisapp.com. 84 finest-woodshed.deisapp.com. 270 IN A 172.17.8.100 85 86 .. note:: 87 88 Setting a CNAME for your root domain can cause issues. Setting your @ record 89 to be a CNAME causes all traffic to go to the other domain, including mail and the SOA 90 ("start-of-authority") records. It is highly recommended that you bind a subdomain to 91 an application, however you can work around this by pointing the @ record to the 92 address of the load balancer (if any). 93 94 Custom Health Checks 95 -------------------- 96 97 By default, Deis only checks that a container is running. You can add a healthcheck by configuring a 98 URL, initial delay, and timeout value: 99 100 .. code-block:: console 101 102 $ deis config:set HEALTHCHECK_URL=/200.html 103 === peachy-waxworks 104 HEALTHCHECK_URL: /200.html 105 $ deis config:set HEALTHCHECK_INITIAL_DELAY=5 106 === peachy-waxworks 107 HEALTHCHECK_INITIAL_DELAY: 5 108 HEALTHCHECK_URL: /200.html 109 $ deis config:set HEALTHCHECK_TIMEOUT=5 110 === peachy-waxworks 111 HEALTHCHECK_TIMEOUT: 5 112 HEALTHCHECK_INITIAL_DELAY: 5 113 HEALTHCHECK_URL: /200.html 114 115 If a new release does not pass the healthcheck, the application will be rolled back to the previous 116 release. Beyond that, if an application container responds to a heartbeat check with a different 117 status than a 200 OK, the :ref:`router` will mark that container as down and stop sending 118 requests to that container. 119 120 Track Changes 121 ------------- 122 Each time a build or config change is made to your application, a new :ref:`release` is created. 123 Track changes to your application using ``deis releases``. 124 125 .. code-block:: console 126 127 $ deis releases 128 === peachy-waxworks Releases 129 v4 3 minutes ago gabrtv deployed d3ccc05 130 v3 1 hour 17 minutes ago gabrtv added DATABASE_URL 131 v2 6 hours 2 minutes ago gabrtv deployed 7cb3321 132 v1 6 hours 2 minutes ago gabrtv deployed deis/helloworld 133 134 Rollback the Application 135 ------------------------ 136 Use ``deis rollback`` to revert to a previous release. 137 138 .. code-block:: console 139 140 $ deis rollback v2 141 Rolled back to v2 142 143 $ deis releases 144 === folksy-offshoot Releases 145 v5 Just now gabrtv rolled back to v2 146 v4 4 minutes ago gabrtv deployed d3ccc05 147 v3 1 hour 18 minutes ago gabrtv added DATABASE_URL 148 v2 6 hours 2 minutes ago gabrtv deployed 7cb3321 149 v1 6 hours 3 minutes ago gabrtv deployed deis/helloworld 150 151 .. note:: 152 153 All releases (including rollbacks) append to the release ledger. 154 155 156 .. _`stores config in environment variables`: http://12factor.net/config 157 .. _`attached resources`: http://12factor.net/backing-services