diff --git a/builds/misc/templates/build-rocksdb.yaml b/builds/misc/templates/build-rocksdb.yaml index a0354241417..55d0247f233 100644 --- a/builds/misc/templates/build-rocksdb.yaml +++ b/builds/misc/templates/build-rocksdb.yaml @@ -25,13 +25,7 @@ stages: arch: arm64v8 postfix: arm64 steps: - - bash: | - build_image=rocksdb-build:master-$(postfix)-$(Build.BuildNumber) && \ - mkdir -p $(Build.ArtifactStagingDirectory)/librocksdb && \ - cd $(System.DefaultWorkingDirectory)/edge-util/docker/linux/$(arch) && \ - docker build --tag ${build_image} . && \ - docker run --rm -v $(Build.ArtifactStagingDirectory)/librocksdb:/artifacts \ - ${build_image} cp /publish/librocksdb.so.$(postfix) /artifacts + - script: scripts/linux/buildRocksDb.sh --output-dir $(Build.ArtifactStagingDirectory) --postfix $(postfix) --build-number $(Build.BuildNumber) --arch $(arch) displayName: Build and copy out rocksdb lib - task: PublishBuildArtifacts@1 displayName: 'Publish Artifacts to VSTS' diff --git a/doc/devguide.md b/doc/devguide.md index fb9826bcf31..857acd3fb29 100644 --- a/doc/devguide.md +++ b/doc/devguide.md @@ -97,13 +97,9 @@ reportgenerator "-reports:TestResults\*\*.coveragexml" "-targetdir:report" ## Build Edge Hub Container Locally -Sometimes it is useful to build the Edge Hub container locally. If you want to do so you can run the below set of scripts: +Sometimes it is useful to build the Edge Hub container locally. If you want to do so you can run the below script: ``` -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/buildImage.sh -r "$(registry.address)" -u "$(registry.user)" -p "$(registry.password)" -i "${{ parameters.imageName }}" -n "${{ parameters.namespace }}" -P "${{ parameters.project }}" -v "${{ parameters.version }} --bin-dir target" +./scripts/linux/buildLocalEdgeHub.sh --registry-address "$(registry.address)" --version "$(version)" ``` ## Build Manifest Image diff --git a/scripts/linux/buildLocalEdgeHub.sh b/scripts/linux/buildLocalEdgeHub.sh new file mode 100755 index 00000000000..0fb0cb42f02 --- /dev/null +++ b/scripts/linux/buildLocalEdgeHub.sh @@ -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" diff --git a/scripts/linux/buildRocksDb.sh b/scripts/linux/buildRocksDb.sh new file mode 100755 index 00000000000..b0a9a0f3180 --- /dev/null +++ b/scripts/linux/buildRocksDb.sh @@ -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