This is an automated email from the ASF dual-hosted git repository.
evansye pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bigtop.git
The following commit(s) were added to refs/heads/master by this push:
new 957bc97 BIGTOP-3153. Switch to docker cp based solution to build
inside containers (#462)
957bc97 is described below
commit 957bc970026ea5b9057d4a836a9d21f966e2033a
Author: Evans Ye <[email protected]>
AuthorDate: Sun Feb 10 15:33:58 2019 +0800
BIGTOP-3153. Switch to docker cp based solution to build inside containers
(#462)
---
bigtop-ci/build.sh | 65 +++++++++++++++++++++++++++++++-----------------------
packages.gradle | 10 ++++++---
2 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/bigtop-ci/build.sh b/bigtop-ci/build.sh
index 9445891..ac5b6bc 100755
--- a/bigtop-ci/build.sh
+++ b/bigtop-ci/build.sh
@@ -14,7 +14,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-while [[ $# -gt 1 ]]
+BIGTOP_HOME=`cd $(dirname $0)/.. && pwd`
+
+usage() {
+ echo "usage build.sh --prefix trunk|1.3.0|1.2.1|... --os
debian-8|centos-7|... --target hadoop|tez|... [--nexus]"
+ exit 1 # unknown option
+}
+
+ if [ $# -eq 0 ]; then
+ usage
+ fi
+
+while [[ $# -gt 0 ]]
do
key="$1"
case $key in
@@ -26,45 +37,45 @@ case $key in
OS="$2"
shift
;;
+ -p|--prefix)
+ PREFIX="$2"
+ shift
+ ;;
-n|--nexus)
NEXUS="--net=container:nexus"
CONFIGURE_NEXUS="configure-nexus"
shift
;;
*)
- echo "usage build.sh --os debian-8|centos-7|... --target hadoop|tez|..."
- exit 1 # unknown option
+ usage
;;
esac
shift
done
-# prepare source image
-cat >Dockerfile <<EOF
-FROM bigtop/slaves:$OS
-# copy source to container
-COPY . /var/lib/jenkins/bigtop
-# make it belong to compile account
-RUN chown -R jenkins /var/lib/jenkins/bigtop
-# define default user jenkins
-USER jenkins
-WORKDIR /var/lib/jenkins/bigtop
-ENTRYPOINT [ "bigtop-ci/entrypoint.sh" ]
-# initialize gradle
-RUN bigtop-ci/entrypoint.sh
-# make it a volume, performancewise
-VOLUME /var/lib/jenkins
-EOF
+if [ -z ${PREFIX+x} ]; then
+ echo "PREFIX is required";
+ UNSATISFIED=true
+fi
+if [ -z ${OS+x} ]; then
+ echo "OS is required";
+ UNSATISFIED=true
+fi
+if [ "$UNSATISFIED" == true ]; then
+ usage
+fi
+
+# Start up build container
+CONTAINER_ID=`docker run -d $NEXUS bigtop/slaves:$PREFIX-$OS /sbin/init`
-# build source image
-docker build -t image-$OS .
+# Copy bigtop repo into container
+docker cp $BIGTOP_HOME $CONTAINER_ID:/bigtop
+docker cp $BIGTOP_HOME/bigtop-ci/entrypoint.sh
$CONTAINER_ID:/bigtop/entrypoint.sh
-# run build
-docker run --name container-$OS-$TARGET-$$ $NEXUS image-$OS $CONFIGURE_NEXUS
$TARGET
+# Build
+docker exec $CONTAINER_ID bash -c "cd /bigtop && ./entrypoint.sh
$CONFIGURE_NEXUS $TARGET"
# save result
mkdir -p output
-docker cp container-$OS-$TARGET-$$:/var/lib/jenkins/bigtop/output .
-docker rm -v container-$OS-$TARGET-$$
-docker rmi image-$OS
-rm -rf Dockerfile
+docker cp $CONTAINER_ID:/bigtop/output .
+#docker rm -f $CONTAINER_ID
diff --git a/packages.gradle b/packages.gradle
index 0253f1c..4d08060 100644
--- a/packages.gradle
+++ b/packages.gradle
@@ -611,15 +611,19 @@ def genTasks = { target ->
task "$target-pkg-ind" (
description: "Invoking a native binary packaging for $target in
Docker. Usage: \$ ./gradlew " +
"-POS=[centos-7|fedora-26|debian-9|ubuntu-16.04|opensuse-42.3] " +
- "-Pprefix=[trunk|1.2.1|1.2.0|1.1.0|...] $target-pkg-ind",
+ "-Pprefix=[trunk|1.2.1|1.2.0|1.1.0|...] $target-pkg-ind" +
+ "-Pnexus=[true|false]",
group: PACKAGES_GROUP) doLast {
def _prefix = project.hasProperty("prefix") ? prefix : "trunk"
def _OS = project.hasProperty("OS") ? OS : "centos-7"
+ def _nexus = project.hasProperty("nexus") ? nexus : "false"
def _target_pkg = "$target-pkg"
def command = [
'./bigtop-ci/build.sh',
- '--os', _prefix + '-' + _OS,
- '--target', _target_pkg
+ '--prefix', _prefix,
+ '--os', _OS,
+ '--target', _target_pkg,
+ _nexus ? '--nexus' : ''
]
println "Building $_prefix $_target_pkg on $_OS in Docker...\n"