mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Merge pull request #14901 from roidelapluie/prebuiltui
makefile: Add support for skipping UI build when prebuilt assets are provided
This commit is contained in:
commit
31ce9dacf4
29
Makefile
29
Makefile
|
@ -30,6 +30,11 @@ include Makefile.common
|
||||||
|
|
||||||
DOCKER_IMAGE_NAME ?= prometheus
|
DOCKER_IMAGE_NAME ?= prometheus
|
||||||
|
|
||||||
|
# Only build UI if PREBUILT_ASSETS_STATIC_DIR is not set
|
||||||
|
ifdef PREBUILT_ASSETS_STATIC_DIR
|
||||||
|
SKIP_UI_BUILD = true
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: update-npm-deps
|
.PHONY: update-npm-deps
|
||||||
update-npm-deps:
|
update-npm-deps:
|
||||||
@echo ">> updating npm dependencies"
|
@echo ">> updating npm dependencies"
|
||||||
|
@ -75,8 +80,24 @@ ui-lint:
|
||||||
cd $(UI_PATH)/react-app && npm run lint
|
cd $(UI_PATH)/react-app && npm run lint
|
||||||
|
|
||||||
.PHONY: assets
|
.PHONY: assets
|
||||||
|
ifndef SKIP_UI_BUILD
|
||||||
assets: ui-install ui-build
|
assets: ui-install ui-build
|
||||||
|
|
||||||
|
.PHONY: npm_licenses
|
||||||
|
npm_licenses: ui-install
|
||||||
|
@echo ">> bundling npm licenses"
|
||||||
|
rm -f $(REACT_APP_NPM_LICENSES_TARBALL) npm_licenses
|
||||||
|
ln -s . npm_licenses
|
||||||
|
find npm_licenses/$(UI_NODE_MODULES_PATH) -iname "license*" | tar cfj $(REACT_APP_NPM_LICENSES_TARBALL) --files-from=-
|
||||||
|
rm -f npm_licenses
|
||||||
|
else
|
||||||
|
assets:
|
||||||
|
@echo '>> skipping assets build, pre-built assets provided'
|
||||||
|
|
||||||
|
npm_licenses:
|
||||||
|
@echo '>> skipping assets npm licenses, pre-built assets provided'
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: assets-compress
|
.PHONY: assets-compress
|
||||||
assets-compress: assets
|
assets-compress: assets
|
||||||
@echo '>> compressing assets'
|
@echo '>> compressing assets'
|
||||||
|
@ -125,14 +146,6 @@ else
|
||||||
test: check-generated-parser common-test ui-build-module ui-test ui-lint check-go-mod-version
|
test: check-generated-parser common-test ui-build-module ui-test ui-lint check-go-mod-version
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: npm_licenses
|
|
||||||
npm_licenses: ui-install
|
|
||||||
@echo ">> bundling npm licenses"
|
|
||||||
rm -f $(REACT_APP_NPM_LICENSES_TARBALL) npm_licenses
|
|
||||||
ln -s . npm_licenses
|
|
||||||
find npm_licenses/$(UI_NODE_MODULES_PATH) -iname "license*" | tar cfj $(REACT_APP_NPM_LICENSES_TARBALL) --files-from=-
|
|
||||||
rm -f npm_licenses
|
|
||||||
|
|
||||||
.PHONY: tarball
|
.PHONY: tarball
|
||||||
tarball: npm_licenses common-tarball
|
tarball: npm_licenses common-tarball
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
export STATIC_DIR=static
|
||||||
|
PREBUILT_ASSETS_STATIC_DIR=${PREBUILT_ASSETS_STATIC_DIR:-}
|
||||||
|
if [ -n "$PREBUILT_ASSETS_STATIC_DIR" ]; then
|
||||||
|
STATIC_DIR=$(realpath $PREBUILT_ASSETS_STATIC_DIR)
|
||||||
|
fi
|
||||||
|
|
||||||
cd web/ui
|
cd web/ui
|
||||||
cp embed.go.tmpl embed.go
|
cp embed.go.tmpl embed.go
|
||||||
|
|
||||||
|
@ -11,6 +17,19 @@ GZIP_OPTS="-fk"
|
||||||
# gzip option '-k' may not always exist in the latest gzip available on different distros.
|
# gzip option '-k' may not always exist in the latest gzip available on different distros.
|
||||||
if ! gzip -k -h &>/dev/null; then GZIP_OPTS="-f"; fi
|
if ! gzip -k -h &>/dev/null; then GZIP_OPTS="-f"; fi
|
||||||
|
|
||||||
|
mkdir -p static
|
||||||
find static -type f -name '*.gz' -delete
|
find static -type f -name '*.gz' -delete
|
||||||
find static -type f -exec gzip $GZIP_OPTS '{}' \; -print0 | xargs -0 -I % echo %.gz | sort | xargs echo //go:embed >> embed.go
|
|
||||||
|
# Compress files from the prebuilt static directory and replicate the structure in the current static directory
|
||||||
|
find "${STATIC_DIR}" -type f ! -name '*.gz' -exec bash -c '
|
||||||
|
for file; do
|
||||||
|
dest="${file#${STATIC_DIR}}"
|
||||||
|
mkdir -p "static/$(dirname "$dest")"
|
||||||
|
gzip '"$GZIP_OPTS"' "$file" -c > "static/${dest}.gz"
|
||||||
|
done
|
||||||
|
' bash {} +
|
||||||
|
|
||||||
|
# Append the paths of gzipped files to embed.go
|
||||||
|
find static -type f -name '*.gz' -print0 | sort -z | xargs -0 echo //go:embed >> embed.go
|
||||||
|
|
||||||
echo var EmbedFS embed.FS >> embed.go
|
echo var EmbedFS embed.FS >> embed.go
|
||||||
|
|
Loading…
Reference in a new issue