github.com/grafana/pyroscope@v1.18.0/Makefile (about)

     1  GO ?= go
     2  SHELL := bash
     3  .DELETE_ON_ERROR:
     4  .SHELLFLAGS := -eu -o pipefail -c
     5  .DEFAULT_GOAL := all
     6  MAKEFLAGS += --warn-undefined-variables
     7  MAKEFLAGS += --no-builtin-rules
     8  MAKEFLAGS += --no-print-directory
     9  BIN := $(CURDIR)/.tmp/bin
    10  COPYRIGHT_YEARS := 2021-2022
    11  LICENSE_IGNORE := -e /testdata/
    12  GO_TEST_FLAGS ?= -v -race -cover
    13  
    14  GOOS ?= $(shell go env GOOS)
    15  GOARCH ?= $(shell go env GOARCH)
    16  IMAGE_PLATFORM = linux/$(GOARCH)
    17  BUILDX_ARGS =
    18  GOPRIVATE=github.com/grafana/frostdb
    19  
    20  # Boiler plate for building Docker containers.
    21  # All this must go at top of file I'm afraid.
    22  IMAGE_PREFIX ?= docker.io/grafana/
    23  
    24  IMAGE_TAG ?= $(shell ./tools/image-tag)
    25  GIT_REVISION := $(shell git rev-parse --short HEAD)
    26  GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
    27  GIT_LAST_COMMIT_DATE := $(shell git log -1 --date=iso-strict --format=%cd)
    28  EMBEDASSETS ?= embedassets
    29  
    30  UNAME_S := $(shell uname -s)
    31  ifeq ($(UNAME_S),Darwin)
    32  	NPROC := $(shell sysctl -n hw.physicalcpu)
    33  else
    34  	NPROC := $(shell nproc)
    35  endif
    36  
    37  # Build flags
    38  VPREFIX := github.com/grafana/pyroscope/pkg/util/build
    39  GO_LDFLAGS   := -X $(VPREFIX).Branch=$(GIT_BRANCH) -X $(VPREFIX).Version=$(IMAGE_TAG) -X $(VPREFIX).Revision=$(GIT_REVISION) -X $(VPREFIX).BuildDate=$(GIT_LAST_COMMIT_DATE)
    40  GO_GCFLAGS_DEBUG := all="-N -l"
    41  
    42  # Folders with go.mod file
    43  GO_MOD_PATHS := api/ lidia/ examples/language-sdk-instrumentation/golang-push/rideshare examples/language-sdk-instrumentation/golang-push/rideshare-alloy examples/language-sdk-instrumentation/golang-push/rideshare-k6 examples/language-sdk-instrumentation/golang-push/simple/ examples/tracing/golang-push/ examples/golang-pgo/
    44  
    45  # Add extra arguments to helm commands
    46  HELM_ARGS =
    47  
    48  HELM_FLAGS_V1 :=
    49  HELM_FLAGS_V1_MICROSERVICES := --set architecture.microservices.enabled=true --set minio.enabled=true
    50  HELM_FLAGS_V2 := --set architecture.storage.v1=false --set architecture.storage.v2=true
    51  HELM_FLAGS_V2_MICROSERVICES := $(HELM_FLAGS_V1_MICROSERVICES) $(HELM_FLAGS_V2)
    52  
    53  
    54  # Local deployment params
    55  KIND_CLUSTER = pyroscope-dev
    56  
    57  .PHONY: help
    58  help: ## Describe useful make targets
    59  	@grep -E '^[a-zA-Z_/-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ": .*?## "}; {printf "%-50s %s\n", $$1, $$2}'
    60  
    61  .PHONY: all
    62  all: lint test build ## Build, test, and lint (default)
    63  
    64  .PHONY: lint
    65  lint: go/lint helm/lint buf/lint goreleaser/lint ## Lint Go, Helm and protobuf
    66  
    67  .PHONY: test
    68  test: go/test ## Run unit tests
    69  
    70  .PHONY: generate
    71  generate: $(BIN)/buf $(BIN)/protoc-gen-go $(BIN)/protoc-gen-go-vtproto $(BIN)/protoc-gen-openapiv2 $(BIN)/protoc-gen-grpc-gateway $(BIN)/protoc-gen-connect-go $(BIN)/protoc-gen-connect-go-mux $(BIN)/gomodifytags $(BIN)/protoc-gen-connect-openapi ## Regenerate protobuf
    72  	rm -Rf api/openapiv2/gen/ api/gen
    73  	find pkg/ \( -name \*.pb.go -o -name \*.connect\*.go \) -delete
    74  	cd api/ && PATH=$(BIN) $(BIN)/buf generate
    75  	cd pkg && PATH=$(BIN) $(BIN)/buf generate
    76  	PATH="$(BIN):$(PATH)" ./tools/add-parquet-tags.sh
    77  	go run ./tools/doc-generator/ ./docs/sources/configure-server/reference-configuration-parameters/index.template > docs/sources/configure-server/reference-configuration-parameters/index.md
    78  	go run ./tools/api-docs-generator/
    79  
    80  .PHONY: buf/lint
    81  buf/lint: $(BIN)/buf
    82  	cd api/ && $(BIN)/buf lint || true # TODO: Fix linting problems and remove the always true
    83  	cd pkg && $(BIN)/buf lint || true # TODO: Fix linting problems and remove the always true
    84  
    85  .PHONY: go/test
    86  go/test: $(BIN)/gotestsum
    87  	$(BIN)/gotestsum --rerun-fails=2 --packages './... ./lidia/...' -- $(GO_TEST_FLAGS)
    88  
    89  # Run test on examples
    90  # This can also be used to run it on a subset of tests
    91  # $ make examples/test RUN=TestDockerComposeBuildRun/tracing/java
    92  .PHONY: examples/test
    93  examples/test: RUN := .*
    94  examples/test: $(BIN)/gotestsum
    95  	$(BIN)/gotestsum --format testname --rerun-fails=2 --packages ./examples -- --count 1 --parallel 2 --timeout 1h --tags examples -run "$(RUN)"
    96  
    97  .PHONY: build
    98  build: frontend/build go/bin ## Do a production build (requiring the frontend build to be present)
    99  
   100  .PHONY: build-dev
   101  build-dev: ## Do a dev build (without requiring the frontend)
   102  	$(MAKE) EMBEDASSETS="" go/bin
   103  
   104  .PHONY: frontend/build
   105  frontend/build:
   106  	docker build -f cmd/pyroscope/frontend.Dockerfile --output=public/build .
   107  
   108  .PHONY: frontend/shell
   109  frontend/shell:
   110  	docker build -f cmd/pyroscope/frontend.Dockerfile --iidfile .docker-image-digest-frontend --target builder .
   111  	docker run -t -i $$(cat .docker-image-digest-frontend) /bin/bash
   112  
   113  .PHONY: profilecli/build
   114  profilecli/build: go/bin-profilecli ## Build the profilecli binary
   115  
   116  .PHONY: pyroscope/build
   117  pyroscope/build: go/bin-pyroscope ## Build just the pyroscope binary
   118  
   119  .PHONY: release
   120  release/prereq: $(BIN)/goreleaser ## Ensure release pre requesites are met
   121  	# remove local git tags coming from helm chart release
   122  	git tag -d $(shell git tag -l "phlare-*" "api/*" "@pyroscope*")
   123  	# ensure there is a docker cli command
   124  	@which docker || { apt-get update && apt-get install -y docker.io; }
   125  	@docker info > /dev/null
   126  
   127  .PHONY: release
   128  release: release/prereq ## Create a release
   129  	$(BIN)/goreleaser release -p=$(NPROC) --clean
   130  
   131  .PHONY: release/prepare
   132  release/prepare: release/prereq ## Prepare a release
   133  	$(BIN)/goreleaser release -p=$(NPROC) --clean --snapshot
   134  
   135  .PHONY: release/build/all
   136  release/build/all: release/prereq ## Build all release binaries
   137  	$(BIN)/goreleaser build -p=$(NPROC) --clean --snapshot
   138  
   139  .PHONY: release/build
   140  release/build: release/prereq ## Build current platform release binaries
   141  	$(BIN)/goreleaser build -p=$(NPROC) --clean --snapshot --single-target
   142  
   143  .PHONY: go/deps
   144  go/deps:
   145  	$(GO) mod tidy
   146  
   147  define go_build_pyroscope
   148  	GOOS=$(GOOS) GOARCH=$(GOARCH) GOAMD64=v2 CGO_ENABLED=0 $(GO) build -tags "netgo $(EMBEDASSETS)" -ldflags "-extldflags \"-static\" $(1)" -gcflags=$(2) ./cmd/pyroscope
   149  endef
   150  
   151  define go_build_profilecli
   152  	GOOS=$(GOOS) GOARCH=$(GOARCH) GOAMD64=v2 CGO_ENABLED=0 $(GO) build -ldflags "-extldflags \"-static\" $(1)" -gcflags=$(2) ./cmd/profilecli
   153  endef
   154  
   155  .PHONY: go/bin-debug
   156  go/bin-debug:
   157  	$(call go_build_pyroscope,$(GO_LDFLAGS),$(GO_GCFLAGS_DEBUG))
   158  	$(call go_build_profilecli,$(GO_LDFLAGS),$(GO_GCFLAGS_DEBUG))
   159  
   160  .PHONY: go/bin
   161  go/bin:
   162  	$(call go_build_pyroscope,-s -w $(GO_LDFLAGS),)
   163  	$(call go_build_profilecli,-s -w $(GO_LDFLAGS),)
   164  
   165  .PHONY: go/bin-pyroscope-debug
   166  go/bin-pyroscope-debug:
   167  	$(call go_build_pyroscope,$(GO_LDFLAGS),$(GO_GCFLAGS_DEBUG))
   168  
   169  .PHONY: go/bin-profilecli-debug
   170  go/bin-profilecli-debug:
   171  	$(call go_build_profilecli,$(GO_LDFLAGS),$(GO_GCFLAGS_DEBUG))
   172  
   173  .PHONY: go/bin-pyroscope
   174  go/bin-pyroscope:
   175  	$(call go_build_pyroscope,-s -w $(GO_LDFLAGS),)
   176  
   177  .PHONY: go/bin-profilecli
   178  go/bin-profilecli:
   179  	$(call go_build_profilecli,-s -w $(GO_LDFLAGS),)
   180  
   181  .PHONY: go/lint
   182  go/lint: $(BIN)/golangci-lint
   183  	$(BIN)/golangci-lint run ./... ./lidia/...
   184  	$(GO) vet ./... ./lidia/...
   185  
   186  .PHONY: update-contributors
   187  update-contributors: ## Update the contributors in README.md
   188  	go run ./tools/update-contributors
   189  
   190  .PHONY: go/mod
   191  go/mod: $(foreach P,$(GO_MOD_PATHS),go/mod_tidy/$P)
   192  
   193  .PHONY: go/mod_tidy_root
   194  go/mod_tidy_root:
   195  	GO111MODULE=on go mod download
   196  	# doesn't work for go workspace
   197  	# GO111MODULE=on go mod verify
   198  	go work sync
   199  	GO111MODULE=on go mod tidy
   200  
   201  .PHONY: go/mod_tidy/%
   202  go/mod_tidy/%: go/mod_tidy_root
   203  	cd "$*" && GO111MODULE=on go mod download
   204  	cd "$*" && GO111MODULE=on go mod tidy
   205  
   206  .PHONY: fmt
   207  fmt: $(BIN)/golangci-lint $(BIN)/buf $(BIN)/tk ## Automatically fix some lint errors
   208  	git ls-files '*.go' | grep -v 'vendor/' | grep -v 'og/' | xargs gofmt -s -w
   209  	$(BIN)/golangci-lint run --fix
   210  	cd api/ && $(BIN)/buf format -w .
   211  	cd pkg && $(BIN)/buf format -w .
   212  	$(BIN)/tk fmt ./operations/pyroscope/jsonnet/
   213  
   214  .PHONY: check/unstaged-changes
   215  check/unstaged-changes:
   216  	@git --no-pager diff --exit-code || { echo ">> There are unstaged changes in the working tree"; exit 1; }
   217  
   218  .PHONY: check/go/mod
   219  check/go/mod: go/mod
   220  	@git --no-pager diff --exit-code -- go.sum go.mod vendor/ || { echo ">> There are unstaged changes in go vendoring run 'make go/mod'"; exit 1; }
   221  
   222  
   223  define docker_buildx
   224  	docker buildx build $(1) --platform $(IMAGE_PLATFORM) $(BUILDX_ARGS) --build-arg=revision=$(GIT_REVISION) -t $(IMAGE_PREFIX)$(shell basename $(@D)):$(2)$(IMAGE_TAG) -f cmd/$(shell basename $(@D))/$(2)Dockerfile .
   225  endef
   226  
   227  define deploy
   228  	$(BIN)/kind export kubeconfig --name $(KIND_CLUSTER) || $(BIN)/kind create cluster --name $(KIND_CLUSTER)
   229  	# Load image into nodes
   230  	$(BIN)/kind load docker-image --name $(KIND_CLUSTER) $(IMAGE_PREFIX)pyroscope:$(IMAGE_TAG)
   231  	kubectl get pods
   232  	$(BIN)/helm upgrade --install pyroscope ./operations/pyroscope/helm/pyroscope $(2) $(HELM_ARGS) \
   233  		--set architecture.deployUnifiedServices=true \
   234  		--set architecture.overwriteResources.requests.cpu=10m \
   235  		--set pyroscope.image.tag=$(IMAGE_TAG) \
   236  		--set pyroscope.image.repository=$(IMAGE_PREFIX)pyroscope \
   237  		--set pyroscope.podAnnotations.image-digest=$(shell cat .docker-image-digest-pyroscope) \
   238  		--set pyroscope.service.port_name=http-metrics \
   239  		--set-string pyroscope.podAnnotations."profiles\.grafana\.com/memory\.port_name"=http-metrics \
   240  		--set-string pyroscope.podAnnotations."profiles\.grafana\.com/cpu\.port_name"=http-metrics \
   241  		--set-string pyroscope.podAnnotations."profiles\.grafana\.com/goroutine\.port_name"=http-metrics \
   242  		--set-string pyroscope.podAnnotations."k8s\.grafana\.com/scrape"=true \
   243  		--set-string pyroscope.podAnnotations."k8s\.grafana\.com/metrics\.portName"=http-metrics \
   244  		--set-string pyroscope.podAnnotations."k8s\.grafana\.com/metrics\.scrapeInterval"=15s \
   245  		--set-string pyroscope.extraEnvVars.JAEGER_AGENT_HOST=pyroscope-monitoring-alloy-receiver \
   246  		--set pyroscope.extraEnvVars.JAEGER_SAMPLER_TYPE=const \
   247  		--set pyroscope.extraEnvVars.JAEGER_SAMPLER_PARAM=1 \
   248  		--set pyroscope.extraArgs."pyroscopedb\.max-block-duration"=5m
   249  endef
   250  
   251  # Function to handle multiarch image build. Depending on the
   252  # debug_build and push_image args, we run one of:
   253  #  - docker-image/pyroscope/build
   254  #  - docker-image/pyroscope/build-debug
   255  #  - docker-image/pyroscope/push
   256  #  - docker-image/pyroscope/push-debug
   257  define multiarch_build
   258  	$(eval push_image=$(1))
   259  	$(eval debug_build=$(2))
   260  	$(eval build_cmd=docker-image/pyroscope/$(if $(push_image),push,build)$(if $(debug_build),-debug))
   261  	$(eval image_name=$(IMAGE_PREFIX)$(shell basename $(@D)):$(if $(debug_build),debug.)$(IMAGE_TAG))
   262  
   263  	GOOS=linux GOARCH=arm64 IMAGE_TAG="$(IMAGE_TAG)-arm64" $(MAKE) $(build_cmd) IMAGE_PLATFORM=linux/arm64
   264  	GOOS=linux GOARCH=amd64 IMAGE_TAG="$(IMAGE_TAG)-amd64" $(MAKE) $(build_cmd) IMAGE_PLATFORM=linux/amd64
   265  
   266  	$(if $(push_image), docker buildx imagetools create --tag "$(image_name)" "$(image_name)-amd64" "$(image_name)-arm64")
   267  	$(if $(push_image), docker buildx imagetools inspect "$(image_name)" --format "{{json .Manifest.Digest}}" | tr -d '"' > .docker-image-digest-pyroscope)
   268  	$(if $(push_image), echo "$(image_name)" > .docker-image-name-pyroscope)
   269  endef
   270  
   271  .PHONY: docker-image/pyroscope/build-multiarch
   272  docker-image/pyroscope/build-multiarch:
   273  	$(call multiarch_build,,)
   274  
   275  .PHONY: docker-image/pyroscope/build-multiarch-debug
   276  docker-image/pyroscope/build-multiarch-debug:
   277  	$(call multiarch_build,,debug)
   278  
   279  .PHONY: docker-image/pyroscope/push-multiarch
   280  docker-image/pyroscope/push-multiarch:
   281  	$(call multiarch_build,push,)
   282  
   283  .PHONY: docker-image/pyroscope/push-multiarch-debug
   284  docker-image/pyroscope/push-multiarch-debug:
   285  	$(call multiarch_build,push,debug)
   286  
   287  .PHONY: docker-image/pyroscope/build-debug
   288  docker-image/pyroscope/build-debug: frontend/build go/bin-debug docker-image/pyroscope/dlv
   289  	$(call docker_buildx,--load,debug.)
   290  
   291  .PHONY: docker-image/pyroscope/push-debug
   292  docker-image/pyroscope/push-debug: frontend/build go/bin-debug docker-image/pyroscope/dlv
   293  	$(call docker_buildx,--push,debug.)
   294  
   295  .PHONY: docker-image/pyroscope/build
   296  docker-image/pyroscope/build: frontend/build
   297  	GOOS=linux $(MAKE) go/bin
   298  	$(call docker_buildx,--load --iidfile .docker-image-digest-pyroscope,)
   299  
   300  .PHONY: docker-image/pyroscope/push
   301  docker-image/pyroscope/push: frontend/build go/bin
   302  	$(call docker_buildx,--push,)
   303  
   304  .PHONY: docker-image/pyroscope/dlv
   305  docker-image/pyroscope/dlv:
   306  	# dlv is not intended for local use and is to be installed in the
   307  	# platform-specific docker image together with the main Pyroscope binary.
   308  	@mkdir -p $(@D)
   309  	GOPATH=$(CURDIR)/.tmp GOAMD64=v2 CGO_ENABLED=0 $(GO) install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@v1.25.2
   310  	mv $(CURDIR)/.tmp/bin/$(GOOS)_$(GOARCH)/dlv $(CURDIR)/.tmp/bin/dlv
   311  
   312  .PHONY: clean
   313  clean: ## Delete intermediate build artifacts
   314  	@# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs
   315  	git clean -Xdf
   316  
   317  .PHONY: reference-help
   318  reference-help: ## Generates the reference help documentation.
   319  reference-help: go/bin
   320  	@(./pyroscope -h || true) > cmd/pyroscope/help.txt.tmpl
   321  	@(./pyroscope -help-all || true) > cmd/pyroscope/help-all.txt.tmpl
   322  
   323  $(BIN)/buf: Makefile
   324  	@mkdir -p $(@D)
   325  	GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/buf/cmd/buf@v1.31.0
   326  
   327  $(BIN)/golangci-lint: Makefile
   328  	@mkdir -p $(@D)
   329  	GOBIN=$(abspath $(@D)) $(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.2
   330  
   331  $(BIN)/protoc-gen-go: Makefile go.mod
   332  	@mkdir -p $(@D)
   333  	GOBIN=$(abspath $(@D)) $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.10
   334  
   335  $(BIN)/protoc-gen-connect-go: Makefile go.mod
   336  	@mkdir -p $(@D)
   337  	GOBIN=$(abspath $(@D)) $(GO) install connectrpc.com/connect/cmd/protoc-gen-connect-go@v1.19.1
   338  
   339  $(BIN)/protoc-gen-connect-go-mux: Makefile go.mod
   340  	@mkdir -p $(@D)
   341  	GOBIN=$(abspath $(@D)) $(GO) install github.com/grafana/connect-go-mux/cmd/protoc-gen-connect-go-mux@v0.2.0
   342  
   343  $(BIN)/protoc-gen-go-vtproto: Makefile go.mod
   344  	@mkdir -p $(@D)
   345  	GOBIN=$(abspath $(@D)) $(GO) install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@v0.6.0
   346  
   347  $(BIN)/protoc-gen-openapiv2: Makefile go.mod
   348  	@mkdir -p $(@D)
   349  	GOBIN=$(abspath $(@D)) $(GO) install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.27.3
   350  
   351  $(BIN)/protoc-gen-grpc-gateway: Makefile go.mod
   352  	@mkdir -p $(@D)
   353  	GOBIN=$(abspath $(@D)) $(GO) install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.27.3
   354  
   355  $(BIN)/protoc-gen-connect-openapi: Makefile go.mod
   356  	@mkdir -p $(@D)
   357  	GOBIN=$(abspath $(@D)) $(GO) install github.com/sudorandom/protoc-gen-connect-openapi@v0.21.2
   358  
   359  $(BIN)/gomodifytags: Makefile go.mod
   360  	@mkdir -p $(@D)
   361  	GOBIN=$(abspath $(@D)) $(GO) install github.com/fatih/gomodifytags@v1.16.0
   362  
   363  $(BIN)/kind: Makefile go.mod
   364  	@mkdir -p $(@D)
   365  	GOBIN=$(abspath $(@D)) $(GO) install sigs.k8s.io/kind@v0.25.0
   366  
   367  $(BIN)/tk: Makefile go.mod $(BIN)/jb
   368  	@mkdir -p $(@D)
   369  	GOBIN=$(abspath $(@D)) $(GO) install github.com/grafana/tanka/cmd/tk@v0.24.0
   370  
   371  $(BIN)/jb: Makefile go.mod
   372  	@mkdir -p $(@D)
   373  	GOBIN=$(abspath $(@D)) $(GO) install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@v0.5.1
   374  
   375  $(BIN)/helm: Makefile go.mod
   376  	@mkdir -p $(@D)
   377  	CGO_ENABLED=0 GOBIN=$(abspath $(@D)) $(GO) install helm.sh/helm/v3/cmd/helm@v3.19.2
   378  
   379  $(BIN)/kubeconform: Makefile go.mod
   380  	@mkdir -p $(@D)
   381  	GOBIN=$(abspath $(@D)) $(GO) install github.com/yannh/kubeconform/cmd/kubeconform@v0.6.4
   382  
   383  $(BIN)/mage: Makefile go.mod
   384  	@mkdir -p $(@D)
   385  	GOBIN=$(abspath $(@D)) $(GO) install github.com/magefile/mage@v1.13.0
   386  
   387  $(BIN)/mockery: Makefile go.mod
   388  	@mkdir -p $(@D)
   389  	GOBIN=$(abspath $(@D)) $(GO) install github.com/vektra/mockery/v2@v2.53.4
   390  
   391  # Note: When updating the goreleaser version also update .github/workflow/release.yml and .git/workflow/weekly-release.yaml
   392  $(BIN)/goreleaser: Makefile go.mod
   393  	@mkdir -p $(@D)
   394  	GOTOOLCHAIN=go1.25.5 GOBIN=$(abspath $(@D)) $(GO) install github.com/goreleaser/goreleaser/v2@v2.13.2
   395  
   396  $(BIN)/gotestsum: Makefile go.mod
   397  	@mkdir -p $(@D)
   398  	GOBIN=$(abspath $(@D)) $(GO) install gotest.tools/gotestsum@v1.12.3
   399  
   400  $(BIN)/helm-docs: Makefile go.mod
   401  	@mkdir -p $(@D)
   402  	GOBIN=$(abspath $(@D)) $(GO) install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.14.2
   403  
   404  .PHONY: cve/check
   405  cve/check:
   406  	docker run -t -i --rm --volume "$(CURDIR)/:/repo" -u "$(shell id -u)" aquasec/trivy:0.45.1 filesystem --cache-dir /repo/.cache/trivy --scanners vuln --skip-dirs .tmp/ --skip-dirs node_modules/ /repo
   407  
   408  .PHONY: helm/lint
   409  helm/lint: $(BIN)/helm
   410  	$(BIN)/helm lint ./operations/pyroscope/helm/pyroscope
   411  	$(BIN)/helm lint ./operations/monitoring/helm/pyroscope-monitoring
   412  
   413  .PHONY: helm/docs
   414  helm/docs: $(BIN)/helm-docs
   415  	$(BIN)/helm-docs -c operations/pyroscope/helm/pyroscope
   416  	$(BIN)/helm-docs -c operations/monitoring/helm/pyroscope-monitoring
   417  
   418  .PHONY: goreleaser/lint
   419  goreleaser/lint: $(BIN)/goreleaser
   420  	$(BIN)/goreleaser check
   421  
   422  .PHONY: helm/check
   423  helm/check: $(BIN)/kubeconform $(BIN)/helm
   424  	$(BIN)/helm repo add --force-update minio https://charts.min.io/
   425  	$(BIN)/helm repo add --force-update grafana https://grafana.github.io/helm-charts
   426  	$(BIN)/helm dependency update ./operations/pyroscope/helm/pyroscope/
   427  	$(BIN)/helm dependency build ./operations/pyroscope/helm/pyroscope/
   428  	$(BIN)/helm dependency update ./operations/monitoring/helm/pyroscope-monitoring/
   429  	$(BIN)/helm dependency build ./operations/monitoring/helm/pyroscope-monitoring/
   430  	mkdir -p ./operations/pyroscope/helm/pyroscope/rendered/
   431  	$(BIN)/helm template -n default --kube-version "1.23.0" pyroscope-dev ./operations/pyroscope/helm/pyroscope/ $(HELM_FLAGS_V1) \
   432  		| tee ./operations/pyroscope/helm/pyroscope/rendered/single-binary.yaml \
   433  		| $(BIN)/kubeconform --summary --strict --kubernetes-version 1.23.0
   434  	$(BIN)/helm template -n default --kube-version "1.23.0" pyroscope-dev ./operations/pyroscope/helm/pyroscope/ $(HELM_FLAGS_V2) \
   435  		| tee ./operations/pyroscope/helm/pyroscope/rendered/single-binary-v2.yaml \
   436  		| $(BIN)/kubeconform --summary --strict --kubernetes-version 1.23.0
   437  	$(BIN)/helm template -n default --kube-version "1.23.0" pyroscope-dev ./operations/pyroscope/helm/pyroscope/ $(HELM_FLAGS_V1_MICROSERVICES) \
   438  		| tee ./operations/pyroscope/helm/pyroscope/rendered/micro-services.yaml \
   439  		| $(BIN)/kubeconform --summary --strict --kubernetes-version 1.23.0
   440  	$(BIN)/helm template -n default --kube-version "1.23.0" pyroscope-dev ./operations/pyroscope/helm/pyroscope/ $(HELM_FLAGS_V2_MICROSERVICES) \
   441  		| tee ./operations/pyroscope/helm/pyroscope/rendered/micro-services-v2.yaml \
   442  		| $(BIN)/kubeconform --summary --strict --kubernetes-version 1.23.0
   443  	$(BIN)/helm template -n default --kube-version "1.23.0" pyroscope-dev ./operations/pyroscope/helm/pyroscope/ --values operations/pyroscope/helm/pyroscope/values-micro-services.yaml \
   444  		| tee ./operations/pyroscope/helm/pyroscope/rendered/legacy-micro-services.yaml \
   445  		| $(BIN)/kubeconform --summary --strict --kubernetes-version 1.23.0
   446  	$(BIN)/helm template -n default --kube-version "1.23.0" pyroscope-dev ./operations/pyroscope/helm/pyroscope/ --values operations/pyroscope/helm/pyroscope/values-micro-services-hpa.yaml \
   447  		| tee ./operations/pyroscope/helm/pyroscope/rendered/legacy-micro-services-hpa.yaml \
   448  		| $(BIN)/kubeconform --summary --strict --kubernetes-version 1.23.0
   449  	cat operations/pyroscope/helm/pyroscope/values-micro-services.yaml \
   450  		| go run ./tools/yaml-to-json \
   451  		> ./operations/pyroscope/jsonnet/values-micro-services.json
   452  		cat operations/pyroscope/helm/pyroscope/values-micro-services-hpa.yaml \
   453  		| go run ./tools/yaml-to-json \
   454  		> ./operations/pyroscope/jsonnet/values-micro-services-hpa.json
   455  	cat operations/pyroscope/helm/pyroscope/values.yaml \
   456  		| go run ./tools/yaml-to-json \
   457  		> ./operations/pyroscope/jsonnet/values.json
   458  	# Generate dashboards and rules
   459  	$(BIN)/helm template pyroscope-monitoring --show-only templates/dashboards.yaml --show-only templates/rules.yaml operations/monitoring/helm/pyroscope-monitoring \
   460  		| go run ./tools/monitoring-chart-extractor
   461  
   462  .PHONY: deploy
   463  deploy: $(BIN)/kind $(BIN)/helm docker-image/pyroscope/build
   464  	$(call deploy,pyroscope-dev,$(HELM_FLAGS_V2))
   465  
   466  .PHONY: deploy-v1
   467  deploy-v1: $(BIN)/kind $(BIN)/helm docker-image/pyroscope/build
   468  	$(call deploy,pyroscope-dev,$(HELM_FLAGS_V1))
   469  
   470  .PHONY: deploy-micro-services
   471  deploy-micro-services: $(BIN)/kind $(BIN)/helm docker-image/pyroscope/build
   472  	$(call deploy,pyroscope-micro-services,$(HELM_FLAGS_V2_MICROSERVICES))
   473  
   474  .PHONY: deploy-micro-services-v1
   475  deploy-micro-services-v1: $(BIN)/kind $(BIN)/helm docker-image/pyroscope/build
   476  	$(call deploy,pyroscope-micro-services,$(HELM_FLAGS_V1_MICROSERVICES))
   477  
   478  .PHONY: deploy-monitoring
   479  deploy-monitoring: $(BIN)/kind $(BIN)/helm
   480  	$(BIN)/kind export kubeconfig --name $(KIND_CLUSTER) || $(BIN)/kind create cluster --name $(KIND_CLUSTER)
   481  	$(BIN)/helm upgrade --install pyroscope-monitoring ./operations/monitoring/helm/pyroscope-monitoring
   482  
   483  include Makefile.examples
   484  
   485  .PHONY: docs/%
   486  docs/%:
   487  	$(MAKE) -C docs $*
   488  
   489  .PHONY: run
   490  run: ## Run the pyroscope binary (pass parameters with 'make run PARAMS=-myparam')
   491  	./pyroscope $(PARAMS)
   492  
   493  .PHONY: mockery
   494  mockery: $(BIN)/mockery
   495  	$(BIN)/mockery