...
1# Copyright 2015 The Prometheus Authors
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14# Needs to be defined before including Makefile.common to auto-generate targets
15DOCKER_ARCHS ?= amd64 armv7 arm64 ppc64le s390x
16
17include Makefile.common
18
19FRONTEND_DIR = $(BIN_DIR)/ui/app
20TEMPLATE_DIR = $(BIN_DIR)/template
21DOCKER_IMAGE_NAME ?= alertmanager
22
23STATICCHECK_IGNORE =
24
25.PHONY: build-all
26# Will build both the front-end as well as the back-end
27build-all: assets apiv2 build
28
29.PHONY: assets
30assets: asset/assets_vfsdata.go
31
32.PHONY: assets-tarball
33assets-tarball: ui/app/script.js ui/app/index.html
34 scripts/package_assets.sh
35
36asset/assets_vfsdata.go: ui/app/script.js ui/app/index.html ui/app/lib template/default.tmpl template/email.tmpl
37 GO111MODULE=$(GO111MODULE) $(GO) generate $(GOOPTS) ./asset
38 @$(GOFMT) -w ./asset
39
40ui/app/script.js: $(shell find ui/app/src -iname *.elm) api/v2/openapi.yaml
41 cd $(FRONTEND_DIR) && $(MAKE) script.js
42
43template/email.tmpl: template/email.html
44 cd $(TEMPLATE_DIR) && $(MAKE) email.tmpl
45
46.PHONY: apiv2
47apiv2: api/v2/models api/v2/restapi api/v2/client
48
49SWAGGER = docker run \
50 --user=$(shell id -u $(USER)):$(shell id -g $(USER)) \
51 --rm \
52 -v $(shell pwd):/go/src/github.com/prometheus/alertmanager \
53 -w /go/src/github.com/prometheus/alertmanager quay.io/goswagger/swagger:v0.30.3
54
55api/v2/models api/v2/restapi api/v2/client: api/v2/openapi.yaml
56 -rm -r api/v2/{client,models,restapi}
57 $(SWAGGER) generate server -f api/v2/openapi.yaml --copyright-file=COPYRIGHT.txt --exclude-main -A alertmanager --target api/v2/
58 $(SWAGGER) generate client -f api/v2/openapi.yaml --copyright-file=COPYRIGHT.txt --skip-models --target api/v2
59
60.PHONY: clean
61clean:
62 - @rm -rf asset/assets_vfsdata.go \
63 api/v2/models api/v2/restapi api/v2/client
64 - @cd $(FRONTEND_DIR) && $(MAKE) clean
View as plain text