Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Add ci script for building docker image (#3181)
Browse files Browse the repository at this point in the history
* Add ci script for building docker image
  • Loading branch information
nwangtw authored Jan 31, 2019
1 parent 8a6949b commit 9b846ec
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 16 deletions.
28 changes: 25 additions & 3 deletions scripts/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ set -e
set -o pipefail

# Install bazel (linux build) because CI hosts may not have it installed
sh scripts/ci/setup_bazel.sh linux
bash scripts/ci/setup_bazel.sh linux

# Build v0.20.1-incubating packages for centos7 and put in artifacts folder
HERON_BUILD_USER=release-agent
sh scripts/ci/build_release_packages.sh v0.20.1-incubating centos7 artifacts
bash scripts/ci/build_release_packages.sh v0.20.1-incubating centos7 artifacts

```

Expand All @@ -30,8 +30,30 @@ Example:
set -e
set -o pipefail

# Install bazel (linux build) because CI hosts may not have it installed
bash scripts/ci/setup_bazel.sh linux

# Build v0.20.1-incubating artifacts and put in artifacts folder
HERON_BUILD_USER=release-agent
bash scripts/ci/build_maven_artifacts.sh v0.20.1-incubating artifacts

```

## Build docker image

The docker image includes Heron core, tools and examples.

Example:

```bash
set -e
set -o pipefail

# Install bazel (linux build) because CI hosts may not have it installed
bash scripts/ci/setup_bazel.sh linux

# Build v0.20.1-incubating artifacts and put in artifacts folder
HERON_BUILD_USER=release-agent
sh scripts/ci/build_maven_artifacts.sh v0.20.1-incubating artifacts
bash scripts/ci/build_docker_image.sh v0.20.1-incubating debian9 artifacts

```
66 changes: 66 additions & 0 deletions scripts/ci/build_docker_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/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.

# Build docker image to be released
# parameters:
# 1. version tag, e.g. v0.20.1-incubating
# 2. build os, e.g. debian9, centos7
# 3. output dir

# Related environment variables
# HERON_BUILD_USER
# HERON_BUILD_HOST

set -e
set -o pipefail

if [ "$#" -ne 3 ]; then
echo "ERROR: Wrong number of arguments. Usage '$0 VERSION_TAG BUILD_OS OUTPUT_DIR'"
exit 1
fi
VERSION_TAG=$1
BUILD_OS=$2
OUTPUT_DIR=$3

TEMP_RELEASE_DIR=~/heron-release

# Clear out the pex cache
rm -rf /var/lib/jenkins/.pex/build/*


# Build with docker
chmod +x scripts/release/status.sh
chmod +x heron/downloaders/src/shell/heron-downloader.sh
chmod +x heron/tools/apiserver/src/shell/heron-apiserver.sh

bash scripts/release/status.sh

# Create a temporary directory for generated files
mkdir -p $TEMP_RELEASE_DIR
rm -f $TEMP_RELEASE_DIR/*.*

# Build artifacts and the docker image
./docker/scripts/build-artifacts.sh $BUILD_OS $VERSION_TAG $TEMP_RELEASE_DIR
./docker/scripts/build-docker.sh $BUILD_OS $VERSION_TAG $TEMP_RELEASE_DIR

# Cherry-pick files to output dir
mkdir -p $OUTPUT_DIR
cp ${TEMP_RELEASE_DIR}/heron-docker-${VERSION_TAG}-${BUILD_OS}.tar.gz $OUTPUT_DIR

# Remove temporary directory
rm -rf $TEMP_RELEASE_DIR
12 changes: 6 additions & 6 deletions scripts/ci/build_maven_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ sh ./maven/maven-pom-version.sh $VERSION_TAG
cd $BASE_DIR

echo "Build directories for jars ... "
mkdir $OUTPUT_DIR/$VERSION_TAG/heron-api
mkdir $OUTPUT_DIR/$VERSION_TAG/heron-spi
mkdir $OUTPUT_DIR/$VERSION_TAG/heron-simulator
mkdir $OUTPUT_DIR/$VERSION_TAG/heron-storm
mkdir -p $OUTPUT_DIR/$VERSION_TAG/heron-api
mkdir -p $OUTPUT_DIR/$VERSION_TAG/heron-spi
mkdir -p $OUTPUT_DIR/$VERSION_TAG/heron-simulator
mkdir -p $OUTPUT_DIR/$VERSION_TAG/heron-storm

echo "Copy heron-api artifacts ... "
cp ./release/heron-api-$VERSION_TAG.pom $OUTPUT_DIR/$VERSION_TAG/heron-api/
Expand Down Expand Up @@ -89,5 +89,5 @@ cp ./bazel-bin/storm-compatibility/src/java/libstorm-compatibility-java-src.jar


echo "Compress all artifacts into a bundle file ..."
tar -czf "${VERSION_TAG}_artifacts.tar.gz" $OUTPUT_DIR
mv "${VERSION_TAG}_artifacts.tar.gz" $OUTPUT_DIR
tar -czf "heron-artifacts-${VERSION_TAG}.tar.gz" $OUTPUT_DIR
mv "heron-artifacts-${VERSION_TAG}.tar.gz" $OUTPUT_DIR
17 changes: 10 additions & 7 deletions scripts/ci/build_release_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ VERSION_TAG=$1
BUILD_OS=$2
OUTPUT_DIR=$3

HERON_BUILD_VERSION=$VERSION_TAG
TEMP_RELEASE_DIR=~/heron-release

# Clear out the pex cache
rm -rf /var/lib/jenkins/.pex/build/*
Expand All @@ -50,12 +50,15 @@ chmod +x heron/tools/apiserver/src/shell/heron-apiserver.sh

bash scripts/release/status.sh

# Create a temporary director for generated files
mkdir -p ~/heron-release
rm -f ~/heron-release/*.*
./docker/scripts/build-artifacts.sh $BUILD_OS $VERSION_TAG ~/heron-release
# Create a temporary directory for generated files
mkdir -p $TEMP_RELEASE_DIR
rm -f $TEMP_RELEASE_DIR/*.*
./docker/scripts/build-artifacts.sh $BUILD_OS $VERSION_TAG $TEMP_RELEASE_DIR

# Cherry-pick files to output dir
mkdir -p $OUTPUT_DIR
cp ~/heron-release/heron-${VERSION_TAG}-${BUILD_OS}.tar.gz $OUTPUT_DIR
cp ~/heron-release/heron-install-${VERSION_TAG}-${BUILD_OS}.sh $OUTPUT_DIR
cp $TEMP_RELEASE_DIR/heron-${VERSION_TAG}-${BUILD_OS}.tar.gz $OUTPUT_DIR
cp $TEMP_RELEASE_DIR/heron-install-${VERSION_TAG}-${BUILD_OS}.sh $OUTPUT_DIR

# Remove temporary directory
rm -rf $TEMP_RELEASE_DIR

0 comments on commit 9b846ec

Please sign in to comment.