-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-build-env.sh
executable file
·64 lines (53 loc) · 2.14 KB
/
start-build-env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Start a Docker-based build environment
set -e -u
cd "$(dirname "$0")"
# OS to build on
: ${BUILD_OS:=centos7}
# Directory with Ambari source
: ${AMBARI_DIR:=$(pwd -P)}
# Maven version
: ${MAVEN_VERSION:=3.3.9}
docker build -t ambari-build-base:${BUILD_OS} dev-support/docker/${BUILD_OS}
docker build -t ambari-build:${BUILD_OS} --build-arg BUILD_OS="${BUILD_OS}" --build-arg MAVEN_VERSION="${MAVEN_VERSION}" dev-support/docker/common
USER_NAME=${SUDO_USER:=$USER}
USER_ID=$(id -u "${USER_NAME}")
GROUP_ID=$(id -g "${USER_NAME}")
USER_TAG="ambari-build-${USER_NAME}-${USER_ID}:${BUILD_OS}"
docker build -t "$USER_TAG" - <<UserSpecificDocker
FROM ambari-build:${BUILD_OS}
RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME}
ENV HOME /home/${USER_NAME}
UserSpecificDocker
TTY_MODE="-t -i"
if [ "$#" -gt 0 ]; then
TTY_MODE=""
fi
# By mapping the .m2 directory you can do an mvn install from
# within the container and use the result on your normal
# system. This also allows a significant speedup in subsequent
# builds, because the dependencies are downloaded only once.
docker run --rm=true $TTY_MODE \
-u "${USER_NAME}" \
-h "${BUILD_OS}" \
-v "${AMBARI_DIR}:/home/${USER_NAME}/src:delegated" \
-v "${HOME}/.m2:/home/${USER_NAME}/.m2:cached" \
-w "/home/${USER_NAME}/src" \
"$USER_TAG" \
"$@"