Rebase yardstick
[fuel.git] / docs / buildprocedure / build.instruction.rst
1 ==============================================================================================
2 OPNFV Build instruction for the Colorado release of OPNFV when using Fuel as a deployment tool
3 ==============================================================================================
4
5 License
6 =======
7
8 This work is licensed under a Creative Commons Attribution 4.0
9 International License. .. http://creativecommons.org/licenses/by/4.0 ..
10 (c) Jonas Bjurel (Ericsson AB) and others
11
12 Abstract
13 ========
14
15 This document describes how to build the Fuel deployment tool for the
16 Colorado release of OPNFV build system, dependencies and required
17 system resources.
18
19 Introduction
20 ============
21
22 This document describes the build system used to build the Fuel
23 deployment tool for the Colorado release of OPNFV, required
24 dependencies and minimum requirements on the host to be used for the
25 build system.
26
27 The Fuel build system is designed around Docker containers such that
28 dependencies outside of the build system can be kept to a minimum. It
29 also shields the host from any potential dangerous operations
30 performed by the build system.
31
32 The audience of this document is assumed to have good knowledge in
33 network and Unix/Linux administration.
34
35 Requirements
36 ============
37
38 Minimum Hardware Requirements
39 -----------------------------
40
41 - ~30 GB available disc
42
43 - 4 GB RAM
44
45 Minimum Software Requirements
46 -----------------------------
47
48 The build host should run Ubuntu 14.04 operating system.
49
50 On the host, the following packages must be installed:
51
52 - An x86_64 host (Bare-metal or VM) with Ubuntu 14.04 LTS installed
53
54   - **Note:** Builds on Wily (Ubuntu 15.x) are currently not supported
55   - A kernel equal- or later than 3.19 (Vivid), simply available through
56
57 .. code-block:: bash
58
59     $ sudo apt-get install linux-generic-lts-vivid
60
61 - docker - see https://docs.docker.com/installation/ubuntulinux/ for
62   installation notes for Ubuntu 14.04. Note: use the latest version from
63   Docker (docker-engine) and not the one in Ubuntu 14.04.
64
65 - git (simply available through $ sudo apt-get install git)
66
67 - make (simply available through $ sudo apt-get install make)
68
69 - curl (simply available through $ sudo apt-get install curl)
70
71 - p7zip-full (simply available through $ sudo apt-get install p7zip-full)
72
73 Preparations
74 ============
75
76 Setting up the Docker build container
77 -------------------------------------
78 After having installed Docker, add yourself to the docker group:
79
80 .. code-block:: bash
81
82     $ sudo usermod -a -G docker [userid]
83
84 Also make sure to define relevant DNS servers part of the global
85 DNS chain in your </etc/default/docker> configuration file.
86 Uncomment, and modify the values appropriately.
87
88 For example:
89
90 .. code-block:: bash
91
92     DOCKER_OPTS=" --dns=8.8.8.8 --dns=8.8.8.4"
93
94 Then restart docker:
95
96 .. code-block:: bash
97
98     $ sudo service docker restart
99
100 Setting up OPNFV Gerrit in order to being able to clone the code
101 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102 - Start setting up OPNFV gerrit by creating a SSH key (unless you
103   don't already have one), create one with ssh-keygen
104
105 - Add your generated public key in OPNFV Gerrit <https://gerrit.opnfv.org/>
106   (this requires a Linux foundation account, create one if you do not
107   already have one)
108
109 - Select "SSH Public Keys" to the left and then "Add Key" and paste
110   your public key in.
111
112 Clone the OPNFV code Git repository with your SSH key
113 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114 Now it is time to clone the code repository:
115
116 .. code-block:: bash
117
118     $ git clone ssh://<Linux foundation user>@gerrit.opnfv.org:29418/fuel
119
120 Now you should have the OPNFV fuel repository with the Fuel
121 directories stored locally on your build host.
122
123 Check out the Colorado release:
124
125 .. code-block:: bash
126
127     $ cd fuel
128     $ git checkout colorado.1.0
129
130 Clone the OPNFV code Git repository without a SSH key
131 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132 You can also opt to clone the code repository without a SSH key:
133
134 .. code-block:: bash
135
136     $ git clone https://gerrit.opnfv.org/gerrit/fuel
137
138 Make sure to checkout the release tag as described above.
139
140 Support for building behind a http/https/rsync proxy
141 ----------------------------------------------------
142
143 The build system is able to make use of a web proxy setup if the
144 http_proxy, https_proxy, no_proxy (if needed) and RSYNC_PROXY or
145 RSYNC_CONNECT_PROG environment variables have been set before invoking make.
146
147 The proxy setup must permit port 80 (http), 443 (https) and 873
148 (rsync).
149
150 Important note about the host Docker daemon settings
151 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152
153 The Docker daemon on the host must be configured to use the http proxy
154 for it to be able to pull the base Ubuntu 14.04 image from the Docker
155 registry before invoking make! In Ubuntu this is done by adding a line
156 like:
157
158 .. code-block:: bash
159
160     export http_proxy="http://10.0.0.1:8888/"
161
162 to /etc/default/docker and restarting the Docker daemon.
163
164 Setting proxy environment variables prior to build
165 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
166
167 The build system will make use the following environment variables
168 that needs to be exported to subshells by using export (bash) or
169 setenv (csh/tcsh).
170
171 .. code-block:: bash
172
173      http_proxy (or HTTP_PROXY)
174      https_proxy (or HTTP_PROXY)
175      no_proxy (or NO_PROXY)
176      RSYNC_PROXY
177      RSYNC_CONNECT_PROG
178
179 As an example, these are the settings that were put in the user's
180 .bashrc when verifying the proxy build functionality:
181
182 .. code-block:: bash
183
184     export RSYNC_PROXY=10.0.0.1:8888
185     export http_proxy=http://10.0.0.1:8888
186     export https_proxy=http://10.0.0.1:8888
187     export no_proxy=localhost,127.0.0.1,.consultron.com,.sock
188
189 Using a ssh proxy for the rsync connection
190 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191
192 If the proxy setup is not allowing the rsync protocol, an alternative
193 solution is to use a SSH tunnel to a machine capable of accessing the
194 outbound port 873. Set the RSYNC_CONNECT_PROG according to the rsync
195 manual page (for example to "ssh <username>@<hostname> nc %H 873")
196 to enable this. Also note that netcat needs to be installed on the
197 remote system!
198
199 Make sure that the ssh command also refers to the user on the remote
200 system, as the command itself will be run from the Docker build container
201 as the root user (but with the invoking user's SSH keys).
202
203 Disabling the Ubuntu repo cache if rsync is not allowed
204 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205
206 During the build phase, a local Ubuntu package repository is fetched
207 from upstream in order to be added to the OPNFV Fuel ISO and for parts
208 of this process rsync is used.
209
210 If neither of the two available methods for proxying rsync are
211 available, the last resort is to turn off the caching of the Ubuntu
212 packages in the build system. This is done by removing the
213 "f_repobuild" from SUBDIRS in the beginning of
214 the fuel/build/f_isoroot/Makefile.
215
216 Note! Doing this will require the Fuel master node to have Internet
217 access when installing the ISO artifact built as no Ubuntu package
218 cache will be on the ISO!
219
220 Configure your build environment
221 --------------------------------
222
223 ** Configuring the build environment should not be performed if building
224 standard Colorado release **
225
226 Select the versions of the components you want to build by editing the
227 fuel/build/config.mk file.
228
229 Non official build: Selecting which plugins to build
230 ----------------------------------------------------
231 In order to cut the build time for unofficial builds (made by an
232 individual developer locally), the selection if which Fuel plugins to
233 build (if any) can be done by environment variable
234 "BUILD_FUEL_PLUGINS" prior to building.
235
236 Only the plugin targets from fuel/build/f_isoroot/Makefile that are
237 specified in the environment variable will then be built. In order to
238 completely disable the building of plugins, the environment variable
239 is set to " ". When using this functionality, the resulting iso file
240 will be prepended with the prefix "unofficial-" to clearly indicate
241 that this is not a full build.
242
243 This method of plugin selection is not meant to be used from within
244 Gerrit!
245
246 Building
247 ========
248
249 There are two methods available for building Fuel:
250
251 - A low level method using Make
252
253 - An abstracted method using build.sh
254
255 Low level build method using make
256 ---------------------------------
257 The low level method is based on Make:
258
259 From the <fuel/build> directory, invoke <make [target]>
260
261 Following targets exist:
262
263 - none/all -  this will:
264
265   - Initialize the docker build environment
266
267   - Build Fuel from upstream (as defined by fuel-build/config-spec)
268
269   - Build the OPNFV defined plugins/features from upstream
270
271   - Build the defined additions to fuel (as defined by the structure
272     of this framework)
273
274   - Apply changes and patches to fuel (as defined by the structure of
275     this framework)
276
277   - Reconstruct a fuel .iso image
278
279 - clean - this will remove all artifacts from earlier builds.
280
281 - debug - this will simply enter the build container without starting a build, from here you can start a build by enter "make iso"
282
283 If the build is successful, you will find the generated ISO file in
284 the <fuel/build/release> subdirectory!
285
286 Abstracted build method using build.sh
287 --------------------------------------
288 The abstracted build method uses the <fuel/ci/build.sh> script which
289 allows you to:
290
291 - Create and use a build cache - significantly speeding up the
292   build time if upstream repositories have not changed.
293
294 - push/pull cache and artifacts to an arbitrary URI (http(s):, file:, ftp:)
295
296 For more info type <fuel/ci/build.sh -h>.
297
298 Artifacts
299 =========
300
301 The artifacts produced are:
302
303 - <OPNFV_XXXX.iso> - Which represents the bootable Fuel image, XXXX is
304   replaced with the build identity provided to the build system
305
306 - <OPNFV_XXXX.iso.txt> - Which holds version metadata.
307
308 References
309 ==========
310
311 1)  `OPNFV Installation instruction for the Colorado release of OPNFV when using Fuel as a deployment tool <http://artifacts.opnfv.org/fuel/colorado/docs/installation-instruction.html>`_
312
313 2) `OPNFV Build instruction for the Colorado release of OPNFV when using Fuel as a deployment tool <http://artifacts.opnfv.org/fuel/colorado/docs/build-instruction.html>`_
314
315 3) `OPNFV Release Note for the Colorado release of OPNFV when using Fuel as a deployment tool <http://artifacts.opnfv.org/fuel/colorado/docs/release-notes.html>`_