github.com/inflatablewoman/deis@v1.0.1-0.20141111034523-a4511c46a6ce/docs/contributing/hacking.rst (about) 1 :description: How to hack on Deis including setup instructions 2 3 .. _hacking: 4 5 Hacking on Deis 6 =============== 7 8 We try to make it simple to hack on Deis. However, there are necessarily several moving 9 pieces and some setup required. We welcome any suggestions for automating or simplifying 10 this process. 11 12 If you're just getting into the Deis codebase, look for GitHub issues with the label 13 `easy-fix`_. These are more straightforward or low-risk issues and are a great way to 14 become more familiar with Deis. 15 16 Prerequisites 17 ------------- 18 19 You can develop on any supported platform including your laptop, cloud providers or 20 on bare metal. We strongly recommend a minimum 3-node cluster. 21 22 The development workflow requires a Docker Registry that is accessible to you 23 (the developer) and to all of the hosts in your cluster. 24 25 You will also need a `deisctl`_ client to update images and restart components. 26 27 Fork the Repository 28 ------------------- 29 30 To get Deis running for development, first `fork the Deis repository`_, 31 then clone your fork of the repository: 32 33 .. code-block:: console 34 35 $ git clone git@github.com:<username>/deis.git 36 $ cd deis 37 $ export DEIS_DIR=`pwd` # to use in future commands 38 39 Install the Client 40 ------------------ 41 42 In a development environment you'll want to use the latest version of the client. Install 43 its dependencies by using the Makefile and symlinking ``client/deis.py`` to ``deis`` on 44 your local workstation. 45 46 .. code-block:: console 47 48 $ cd $DEIS_DIR/client 49 $ make install 50 $ sudo ln -fs $DEIS_DIR/client/deis.py /usr/local/bin/deis 51 $ deis 52 Usage: deis <command> [<args>...] 53 54 Configure SSH Tunneling 55 ----------------------- 56 57 To connect to the cluster using ``deisctl``, you must add the private key to ``ssh-agent``. 58 For example, when using Vagrant: 59 60 .. code-block:: console 61 62 $ ssh-add ~/.vagrant.d/insecure_private_key 63 64 Set ``DEISCTL_TUNNEL`` so the ``deisctl`` client on your workstation can connect to 65 one of the hosts in your cluster: 66 67 .. code-block:: console 68 69 $ export DEISCTL_TUNNEL=172.17.8.100 70 71 Test connectivity using ``deisctl list``: 72 73 .. code-block:: console 74 75 $ deisctl list 76 77 Configure a Docker Registry 78 --------------------------- 79 80 The development workflow requires Docker Registry set at the ``DEV_REGISTRY`` 81 environment variable. If you're developing locally you can use the ``dev-registry`` 82 target to spin up a quick, disposable registry inside a Docker container. 83 84 .. code-block:: console 85 86 $ make dev-registry 87 88 To configure the registry for local Deis development: 89 export DEV_REGISTRY=192.168.59.103:5000 90 91 .. note:: 92 93 For Docker 1.3.1 and later, ``docker push`` to this development registry may fail 94 without SSL certificate support. Restart docker with an ``--insecure-registry`` flag. 95 96 For ``boot2docker`` 1.3.1 for example, add 97 ``EXTRA_ARGS="--insecure-registry 192.168.59.103:5000"`` to 98 /var/lib/boot2docker/profile and restart docker with ``sudo /etc/init.d/docker restart``. 99 100 If you are developing elsewhere, you must set up a registry yourself. 101 Make sure it meets the following requirements: 102 103 #. You can push Docker images from your workstation 104 #. Hosts in the cluster can pull images with the same URL 105 106 Development Workflow 107 -------------------- 108 109 Deis includes ``Makefile`` targets designed to simplify the development workflow. 110 This workflow is typically: 111 112 #. Update source code and commit your changes using ``git`` 113 #. Use ``make -C <component> build`` to build a new Docker image 114 #. Use ``make -C <component> dev-release`` to push a snapshot release 115 #. Use ``make -C <component> restart`` to restart the component 116 117 This can be shortened to a one-liner using the ``deploy`` target: 118 119 .. code-block:: console 120 121 $ make -C controller deploy 122 123 You can also use the same tasks on the root ``Makefile`` to operate on all 124 components at once. For example, ``make deploy`` will build, dev-release, 125 and restart all components on the cluster. 126 127 .. important:: 128 129 In order to cut a dev-release, you must commit changes using ``git`` to increment 130 the SHA used when tagging Docker images 131 132 Test Your Changes 133 ----------------- 134 135 Deis ships with a comprehensive suite of automated tests, most written in Go. 136 See :ref:`testing` for instructions on running the tests. 137 138 Useful Commands 139 --------------- 140 141 Once your controller is running, here are some helpful commands. 142 143 Tail Logs 144 ````````` 145 146 .. code-block:: console 147 148 $ deisctl journal controller 149 150 Rebuild Services from Source 151 ```````````````````````````` 152 153 .. code-block:: console 154 155 $ make -C controller build push restart 156 157 Restart Services 158 ```````````````` 159 160 .. code-block:: console 161 162 $ make -C controller restart 163 164 Django Shell 165 ```````````` 166 167 .. code-block:: console 168 169 $ deisctl ssh controller # SSH into the controller 170 $ nse deis-controller # inject yourself into the container 171 $ cd /app # change into the django project root 172 $ ./manage.py shell # get a django shell 173 174 Have commands other Deis developers might find useful? Send us a PR! 175 176 Pull Requests 177 ------------- 178 179 Please read :ref:`standards`. It contains a checklist of things you should do 180 when proposing a change to Deis. 181 182 .. _`easy-fix`: https://github.com/deis/deis/issues?labels=easy-fix&state=open 183 .. _`deisctl`: https://github.com/deis/deis/deisctl 184 .. _`fork the Deis repository`: https://github.com/deis/deis/fork 185 .. _`running the tests`: https://github.com/deis/deis/tree/master/tests#readme 186 .. _`pull request`: https://github.com/deis/deis/pulls