build(dashboard): get dashboard script support enterprise
This commit is contained in:
parent
9f0c88cda9
commit
059d9fcaeb
|
@ -44,3 +44,4 @@ elvis
|
|||
emqx_dialyzer_*_plt
|
||||
*/emqx_dashboard/priv/www
|
||||
dist.zip
|
||||
scripts/git-token
|
||||
|
|
|
@ -18,7 +18,8 @@ RUN apk add --no-cache \
|
|||
bsd-compat-headers \
|
||||
libc-dev \
|
||||
libstdc++ \
|
||||
bash
|
||||
bash \
|
||||
jq
|
||||
|
||||
COPY . /emqx
|
||||
|
||||
|
|
|
@ -5,18 +5,17 @@ set -euo pipefail
|
|||
# ensure dir
|
||||
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
if [[ "$1" == https://* ]]; then
|
||||
VERSION='*' # alwyas download
|
||||
DOWNLOAD_URL="$1"
|
||||
else
|
||||
VERSION="$1"
|
||||
DOWNLOAD_URL="https://github.com/emqx/emqx-dashboard-frontend/releases/download/${VERSION}/emqx-dashboard.zip"
|
||||
fi
|
||||
RELEASE_ASSET_FILE="emqx-dashboard.zip"
|
||||
|
||||
if [ -f 'EMQX_ENTERPRISE' ]; then
|
||||
DASHBOARD_PATH='lib-ee/emqx_dashboard/priv'
|
||||
DASHBOARD_REPO='emqx-enterprise-dashboard-frontend-src'
|
||||
AUTH="Authorization: token $(cat scripts/git-token)"
|
||||
else
|
||||
DASHBOARD_PATH='lib-ce/emqx_dashboard/priv'
|
||||
DASHBOARD_REPO='emqx-dashboard-frontend'
|
||||
AUTH=""
|
||||
fi
|
||||
|
||||
case $(uname) in
|
||||
|
@ -32,8 +31,27 @@ if [ -d "$DASHBOARD_PATH/www" ] && [ "$(version)" = "$VERSION" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
curl -f -L "${DOWNLOAD_URL}" -o ./emqx-dashboard.zip
|
||||
unzip -q ./emqx-dashboard.zip -d "$DASHBOARD_PATH"
|
||||
get_assets(){
|
||||
# Get the download URL of our desired asset
|
||||
download_url="$(curl --silent --show-error \
|
||||
--header "${AUTH}" \
|
||||
--header "Accept: application/vnd.github.v3+json" \
|
||||
"https://api.github.com/repos/emqx/${DASHBOARD_REPO}/releases/tags/${VERSION}" \
|
||||
| jq --raw-output ".assets[] | select(.name==\"${RELEASE_ASSET_FILE}\").url")"
|
||||
# Get GitHub's S3 redirect URL
|
||||
redirect_url=$(curl --silent --show-error \
|
||||
--header "${AUTH}" \
|
||||
--header "Accept: application/octet-stream" \
|
||||
--write-out "%{redirect_url}" \
|
||||
"$download_url")
|
||||
curl --silent --show-error \
|
||||
--header "Accept: application/octet-stream" \
|
||||
--output "${RELEASE_ASSET_FILE}" \
|
||||
"$redirect_url"
|
||||
}
|
||||
|
||||
get_assets
|
||||
unzip -q "$RELEASE_ASSET_FILE" -d "$DASHBOARD_PATH"
|
||||
rm -rf "$DASHBOARD_PATH/www"
|
||||
mv "$DASHBOARD_PATH/dist" "$DASHBOARD_PATH/www"
|
||||
rm -rf emqx-dashboard.zip
|
||||
rm -rf "$RELEASE_ASSET_FILE"
|
||||
|
|
Loading…
Reference in New Issue