Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bin-go:
@echo ">> building binaries"
ifeq ($(NO_DOCKER), 1)
if [ "$(BIN_GO_NAME)" = "frontend" ]; then pkg/ui/build.sh; fi
CGO_ENABLED=0 go build -tags builtinassets -o ./build/bin/$(BIN_GO_NAME) ./$(BIN_GO_DIR)/$(BIN_GO_NAME)/*.go
CGO_ENABLED=0 go build -o ./build/bin/$(BIN_GO_NAME) ./$(BIN_GO_DIR)/$(BIN_GO_NAME)/*.go
# If pushing, build and tag native arch image to GCR.
else ifeq ($(DOCKER_PUSH), 1)
$(call docker_build, --tag gmp/$(BIN_GO_NAME) -f ./$(BIN_GO_DIR)/$(BIN_GO_NAME)/Dockerfile .)
Expand Down
2 changes: 0 additions & 2 deletions cmd/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
RUN if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then \
apt install -y --no-install-recommends \
-tags builtinassets \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross; \
CC=aarch64-linux-gnu-gcc; \
fi && \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CC=${CC} \
go build \
-tags builtinassets \
-ldflags="-X github.com/prometheus/common/version.Version=$(cat charts/values.global.yaml | go tool yq ".version" ) \
-X github.com/prometheus/common/version.BuildDate=$(date --iso-8601=seconds)" \
-o frontend \
Expand Down
3 changes: 1 addition & 2 deletions pkg/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/build
/static
/embed.go
/static
4 changes: 2 additions & 2 deletions pkg/ui/assets_embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build builtinassets
// +build builtinassets
//go:build !localassets
// +build !localassets

Check failure on line 16 in pkg/ui/assets_embed.go

View workflow job for this annotation

GitHub Actions / golangci-lint

redundant-build-tag: The build tag "// +build" is redundant since Go 1.17 and can be removed (revive)

package ui

Expand Down
3 changes: 2 additions & 1 deletion pkg/ui/assets_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !builtinassets
//go:build localassets
// +build localassets

package ui

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build builtinassets
// +build builtinassets
//go:build !localassets
// +build !localassets

Check failure on line 15 in pkg/ui/embed.go

View workflow job for this annotation

GitHub Actions / golangci-lint

redundant-build-tag: The build tag "// +build" is redundant since Go 1.17 and can be removed (revive)

package ui

import "embed"

// Following line replaced by compress_assets.sh
//{{go:embed}}

Check failure on line 22 in pkg/ui/embed.go

View workflow job for this annotation

GitHub Actions / golangci-lint

comment-spacings: no space between comment delimiter and comment text (revive)

var EmbedFS embed.FS
6 changes: 3 additions & 3 deletions third_party/prometheus_ui/base/scripts/compress_assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
set -euo pipefail

cd web/ui
cp embed.go.tmpl embed.go

GZIP_OPTS="-fk"
# 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

find static -type f -name '*.gz' -delete
find static -type f -exec gzip $GZIP_OPTS '{}' \; -print0 | xargs -0 -I % echo %.gz | xargs echo //go:embed >> embed.go
echo var EmbedFS embed.FS >> embed.go
find static -type f -exec gzip $GZIP_OPTS '{}' \;
FILES=$(find static -name "*.gz" -type f | tr '\n' ' ')
sed -i "s|// {{go:embed}}|//go:embed $FILES|" embed.go
4 changes: 1 addition & 3 deletions third_party/prometheus_ui/base/web/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ into the Prometheus binary using the embed package.

During development it is more convenient to always use the files on disk to
directly see changes without recompiling.
To make this work, remove the `builtinassets` build tag in the `flags` entry
in `.promu.yml`, and then `make build` (or build Prometheus using
`go build ./cmd/prometheus`).
To make this work, add the `localassets` build tag in the `go build` command in `make` that builds the frontend (add `-tags localassets`) and then `make build` as usual.

This will serve all files from your local filesystem. This is for development purposes only.

Expand Down
Loading