[docker build] Install OpenSSH server
[fuel.git] / ci / build.sh
1 #!/bin/bash -e
2 # shellcheck disable=SC1004,SC1090
3 ##############################################################################
4 # Copyright (c) 2018 Mirantis Inc., Enea AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 ##############################################################################
12 # BEGIN of Exit handlers
13 #
14 do_exit () {
15     local RC=$?
16     if [ ${RC} -eq 0 ]; then
17         notify_n "[OK] MCP: Docker build finished succesfully!" 2
18     else
19         notify_n "[ERROR] MCP: Docker build threw a fatal error!"
20     fi
21 }
22 #
23 # End of Exit handlers
24 ##############################################################################
25
26 ##############################################################################
27 # BEGIN of variables to customize
28 #
29 CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
30 MCP_REPO_ROOT_PATH=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")
31 DEPLOY_DIR=$(cd "${MCP_REPO_ROOT_PATH}/mcp/scripts"; pwd)
32 DOCKER_DIR=$(cd "${MCP_REPO_ROOT_PATH}/docker"; pwd)
33 DOCKER_TAG=${1:-latest}
34
35 source "${DEPLOY_DIR}/globals.sh"
36 source "${DEPLOY_DIR}/lib.sh"
37
38 #
39 # END of variables to customize
40 ##############################################################################
41
42 ##############################################################################
43 # BEGIN of main
44 #
45
46 # Enable the automatic exit trap
47 trap do_exit SIGINT SIGTERM EXIT
48
49 # Set no restrictive umask so that Jenkins can remove any residuals
50 umask 0000
51
52 # Clone git submodules and apply our patches
53 make -C "${MCP_REPO_ROOT_PATH}/mcp/patches" deepclean patches-import
54
55 pushd "${DOCKER_DIR}" > /dev/null
56
57 # Install distro packages and pip-managed prerequisites
58 notify "[NOTE] Installing required build-time distro and pip pkgs" 2
59 jumpserver_pkg_install 'build'
60 pip install pipenv --user
61 docker_install
62
63 pipenv --two
64 pipenv install
65 pipenv shell \
66   "invoke build saltmaster-reclass \
67     --require 'salt salt-formulas opnfv reclass tini-saltmaster' \
68     --dist=ubuntu \
69     --dist-rel=xenial \
70     --formula-rev=nightly \
71     --opnfv-tag='${DOCKER_TAG}' \
72     --salt='stable 2017.7'; \
73   exit"
74
75 popd > /dev/null
76
77 #
78 # END of main
79 ##############################################################################