-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Devguide: Fix and enhance local EdgeHub build (#6077)
The devguide specified a set of commands to build EdgeHub locally. These stopped working when we made the change to build the rocksdb `.so` file every build. To fix this I created two scripts: 1. buildRocksDb.sh: This is the current bash logic in the devops template which builds rocksdb and copies out the binary 2. buildLocalEdgeHub.sh: This uses buildRocksDB.sh, along with another set of scripts to build a local EdgeHub image. Passing build (waiting for results): https://msazure.visualstudio.com/One/_build/results?buildId=51582888&view=results ***Please replace this line with your PR description and read PR checklist below*** ## Azure IoT Edge PR checklist:
- Loading branch information
1 parent
ca22a6b
commit 5dd965f
Showing
4 changed files
with
139 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
############################################################################### | ||
# This script builds an EdgeHub image locally | ||
############################################################################### | ||
|
||
############################################################################### | ||
# Define Environment Variables | ||
############################################################################### | ||
# Get directory of running script | ||
DIR=$(cd "$(dirname "$0")" && pwd) | ||
BUILD_REPOSITORY_LOCALPATH=$(realpath ${BUILD_REPOSITORY_LOCALPATH:-$DIR/../..}) | ||
SCRIPT_NAME=$(basename "$0") | ||
|
||
############################################################################### | ||
# Print usage information pertaining to this script and exit | ||
############################################################################### | ||
function usage() { | ||
echo "$SCRIPT_NAME [options]" | ||
echo "" | ||
echo "options" | ||
echo "--registry-address Path where to put librocksdb folder containing built artifact." | ||
echo "--version Tag for built edge hub image." | ||
echo " -h, --help Print this help and exit." | ||
exit 1 | ||
} | ||
|
||
function print_help_and_exit() { | ||
echo "Run $SCRIPT_NAME --help for more information." | ||
exit 1 | ||
} | ||
|
||
############################################################################### | ||
# Obtain and validate the options supported by this script | ||
############################################################################### | ||
function process_args() { | ||
save_next_arg=0 | ||
for arg in "$@"; do | ||
if [ ${save_next_arg} -eq 1 ]; then | ||
REGISTRY_ADDRESS=$arg | ||
save_next_arg=0 | ||
elif [ ${save_next_arg} -eq 2 ]; then | ||
VERSION=$arg | ||
save_next_arg=0 | ||
else | ||
case "$arg" in | ||
"-h" | "--help") usage ;; | ||
"--registry-address") save_next_arg=1 ;; | ||
"--version") save_next_arg=2 ;; | ||
*) usage ;; | ||
esac | ||
fi | ||
done | ||
} | ||
|
||
process_args "$@" | ||
|
||
scripts/linux/buildBranch.sh | ||
scripts/linux/cross-platform-rust-build.sh --os alpine --arch amd64 --build-path mqtt/mqttd | ||
scripts/linux/cross-platform-rust-build.sh --os alpine --arch amd64 --build-path edge-hub/watchdog | ||
scripts/linux/consolidate-build-artifacts.sh --artifact-name "edge-hub" | ||
scripts/linux/buildRocksDb.sh --output-dir $(pwd)/target/publish/edge-hub --postfix amd64 --build-number debug --arch amd64 | ||
scripts/linux/buildImage.sh -r $REGISTRY_ADDRESS -i "azureiotedge-hub" -n "microsoft" -P "edge-hub" -v $VERSION --bin-dir "target" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
|
||
############################################################################### | ||
# This script builds cross compiles rocksdb .so file using docker buildx | ||
############################################################################### | ||
|
||
############################################################################### | ||
# Define Environment Variables | ||
############################################################################### | ||
# Get directory of running script | ||
DIR=$(cd "$(dirname "$0")" && pwd) | ||
|
||
BUILD_REPOSITORY_LOCALPATH=$(realpath ${BUILD_REPOSITORY_LOCALPATH:-$DIR/../..}) | ||
SCRIPT_NAME=$(basename "$0") | ||
|
||
############################################################################### | ||
# Print usage information pertaining to this script and exit | ||
############################################################################### | ||
function usage() { | ||
echo "$SCRIPT_NAME [options]" | ||
echo "" | ||
echo "options" | ||
echo "--output-dir Path where to put librocksdb folder containing built artifact." | ||
echo "--postfix Options: amd64, armhf, arm64." | ||
echo "--build-number Build number for which to tag image." | ||
echo "--arch Options: amd64, arm32v7, arm64v8." | ||
echo " -h, --help Print this help and exit." | ||
exit 1 | ||
} | ||
|
||
function print_help_and_exit() { | ||
echo "Run $SCRIPT_NAME --help for more information." | ||
exit 1 | ||
} | ||
|
||
############################################################################### | ||
# Obtain and validate the options supported by this script | ||
############################################################################### | ||
function process_args() { | ||
save_next_arg=0 | ||
for arg in "$@"; do | ||
if [ ${save_next_arg} -eq 1 ]; then | ||
OUTPUT_DIR=$arg | ||
save_next_arg=0 | ||
elif [ ${save_next_arg} -eq 2 ]; then | ||
POSTFIX=$arg | ||
save_next_arg=0 | ||
elif [ ${save_next_arg} -eq 3 ]; then | ||
BUILD_NUMBER=$arg | ||
save_next_arg=0 | ||
elif [ ${save_next_arg} -eq 4 ]; then | ||
ARCH=$arg | ||
save_next_arg=0 | ||
else | ||
case "$arg" in | ||
"-h" | "--help") usage ;; | ||
"--output-dir") save_next_arg=1 ;; | ||
"--postfix") save_next_arg=2 ;; | ||
"--build-number") save_next_arg=3 ;; | ||
"--arch") save_next_arg=4 ;; | ||
*) usage ;; | ||
esac | ||
fi | ||
done | ||
} | ||
|
||
process_args "$@" | ||
|
||
build_image=rocksdb-build:master-$POSTFIX-$BUILD_NUMBER | ||
mkdir -p $OUTPUT_DIR/librocksdb | ||
cd $BUILD_REPOSITORY_LOCALPATH/edge-util/docker/linux/$ARCH | ||
docker build --tag ${build_image} . | ||
docker run --rm -v $OUTPUT_DIR/librocksdb:/artifacts ${build_image} cp /publish/librocksdb.so.$POSTFIX /artifacts |