Repository: prometheus/prometheus (language: go)

Issue:
Build fails due to invalid gzip option -k
### What did you do?

Attempt to build Prometheus on a CentOS 7 platform

### What did you expect to see?

A successful build. It last worked on version 2.30.3 that I've tested.

### What did you see instead? Under which circumstances?

```
gzip: invalid option -- 'k'
Try `gzip --help' for more information.
>> building binaries
/home/kitchen/recipes/prometheus/tmp-build/bin/promu build --prefix /home/kitchen/recipes/prometheus/tmp-build/src/github.com/prometheus/prometheus
 >   prometheus
# github.com/prometheus/prometheus/web/ui
web/ui/embed.go:21:3: usage: //go:embed pattern...
!! command failed: build -o /home/kitchen/recipes/prometheus/tmp-build/src/github.com/prometheus/prometheus/prometheus -ldflags -X github.com/prometheus/common/version.Version=2.37.0 -X github.com/prometheus/common/version.Revision=b41e0750abf5cc18d8233161560731de05199330 -X github.com/prometheus/common/version.Branch=HEAD -X github.com/prometheus/common/version.BuildUser=kitchen@3460a3706333 -X github.com/prometheus/common/version.BuildDate=20220721-14:47:40  -extldflags '-static' -a -tags netgo,builtinassets github.com/prometheus/prometheus/cmd/prometheus: exit status 2
make: *** [common-build] Error 1
```

This comes from:
```
scripts/compress_assets.sh:find static -type f -exec gzip -fk '{}' \; -print0 | xargs -0 -I % echo %.gz | xargs echo //go:embed >> embed.go
```

It seems when building on CentOS 7, the available gzip version does not include the `-k` option, which causes the build to fail. Builds should not be host dependent, outside of the Go / Node versions.

### System information

CentOS 7

### Prometheus version

```text
2.37.0
```


### Prometheus configuration file

```yaml
N/A
```


### Alertmanager version

```text
N/A
```


### Alertmanager configuration file

```yaml
N/A
```


### Logs

```text
N/A
```



Discussion / hints:
Looks like this commit did it https://github.com/prometheus/prometheus/commit/c901ebaf8dd1273de415f8a32617d708c4256683#diff-f1246c05076255a228b984c4340d456ab0a455a117c50fedb89f4402148e0611R10
gzip -k is necessary to speedup subsequent build. You could use our own docker image golang-builder to build prometheus or remove it during our build. However, this is a useful feature to have upstream.
It may be useful for subsequent builds but for those of us that aren't building these on repeat and are still using a still-supported OS, it makes no sense to force us to move to an entirely new build platform because of an option which isn't available everywhere. It's just as easy to add a check to make it compatible with RHEL 7 based build platforms.
Sure, if you want to send a pull request, I'd gladly merge it.

Fix patch:
diff --git a/scripts/compress_assets.sh b/scripts/compress_assets.sh
index 58486089e13..615e30c43c5 100755
--- a/scripts/compress_assets.sh
+++ b/scripts/compress_assets.sh
@@ -6,6 +6,11 @@ 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 -fk '{}' \; -print0 | xargs -0 -I % echo %.gz | xargs echo //go:embed >> embed.go
+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


Test patch: