New release process using docker, circleci and a centralized
building tool
This commit is contained in:
parent
3d22b5fb5f
commit
9d4dccae7c
|
@ -0,0 +1,4 @@
|
||||||
|
.build/
|
||||||
|
.tarballs/
|
||||||
|
|
||||||
|
!.build/linux-amd64/
|
|
@ -1,4 +1,12 @@
|
||||||
data/
|
/data/
|
||||||
alertmanager
|
/alertmanager
|
||||||
*.yml
|
*.yml
|
||||||
*.yaml
|
*.yaml
|
||||||
|
/.build
|
||||||
|
/.release
|
||||||
|
/.tarballs
|
||||||
|
|
||||||
|
!/doc/examples/simple.yml
|
||||||
|
!/circle.yml
|
||||||
|
!/.travis.yml
|
||||||
|
!/.promu.yml
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
go: 1.5.4
|
||||||
|
repository:
|
||||||
|
path: github.com/prometheus/alertmanager
|
||||||
|
build:
|
||||||
|
ldflags: |
|
||||||
|
-X {{repoPath}}/version.Version={{.Version}}
|
||||||
|
-X {{repoPath}}/version.Revision={{.Revision}}
|
||||||
|
-X {{repoPath}}/version.Branch={{.Branch}}
|
||||||
|
-X {{repoPath}}/version.BuildUser={{user}}@{{host}}
|
||||||
|
-X {{repoPath}}/version.BuildDate={{date "20060102-15:04:05"}}
|
||||||
|
tarball:
|
||||||
|
files:
|
||||||
|
- doc/examples/simple.yml
|
||||||
|
- LICENSE
|
||||||
|
- NOTICE
|
||||||
|
crossbuild:
|
||||||
|
platforms:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/386
|
||||||
|
- darwin/amd64
|
||||||
|
- darwin/386
|
||||||
|
- windows/amd64
|
||||||
|
- windows/386
|
||||||
|
- linux/arm
|
||||||
|
- linux/arm64
|
13
Dockerfile
13
Dockerfile
|
@ -1,15 +1,8 @@
|
||||||
FROM golang:1.5.3
|
FROM prom/busybox:latest
|
||||||
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>
|
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/prometheus/alertmanager
|
COPY alertmanager /bin/alertmanager
|
||||||
COPY . /go/src/github.com/prometheus/alertmanager
|
COPY doc/examples/simple.yml /etc/alertmanager/config.yml
|
||||||
|
|
||||||
RUN apt-get install make \
|
|
||||||
&& make build \
|
|
||||||
&& cp alertmanager /bin/ \
|
|
||||||
&& mkdir -p /etc/alertmanager/template \
|
|
||||||
&& mv ./doc/examples/simple.yml /etc/alertmanager/config.yml \
|
|
||||||
&& rm -rf /go
|
|
||||||
|
|
||||||
EXPOSE 9093
|
EXPOSE 9093
|
||||||
VOLUME [ "/alertmanager" ]
|
VOLUME [ "/alertmanager" ]
|
||||||
|
|
32
Makefile
32
Makefile
|
@ -11,8 +11,14 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
GO := GO15VENDOREXPERIMENT=1 go
|
GO := GO15VENDOREXPERIMENT=1 go
|
||||||
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
|
PROMU := $(GOPATH)/bin/promu
|
||||||
|
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
|
||||||
|
|
||||||
|
PREFIX ?= $(shell pwd)
|
||||||
|
BIN_DIR ?= $(shell pwd)
|
||||||
|
DOCKER_IMAGE_NAME ?= alertmanager
|
||||||
|
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
bindata_flags = -debug
|
bindata_flags = -debug
|
||||||
|
@ -25,6 +31,10 @@ test:
|
||||||
@echo ">> running tests"
|
@echo ">> running tests"
|
||||||
@$(GO) test -short $(pkgs)
|
@$(GO) test -short $(pkgs)
|
||||||
|
|
||||||
|
style:
|
||||||
|
@echo ">> checking code style"
|
||||||
|
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
|
||||||
|
|
||||||
format:
|
format:
|
||||||
@echo ">> formatting code"
|
@echo ">> formatting code"
|
||||||
@$(GO) fmt $(pkgs)
|
@$(GO) fmt $(pkgs)
|
||||||
|
@ -33,12 +43,17 @@ vet:
|
||||||
@echo ">> vetting code"
|
@echo ">> vetting code"
|
||||||
@$(GO) vet $(pkgs)
|
@$(GO) vet $(pkgs)
|
||||||
|
|
||||||
build:
|
build: promu
|
||||||
@echo ">> building binaries"
|
@echo ">> building binaries"
|
||||||
@./scripts/build.sh
|
@$(PROMU) build --prefix $(PREFIX)
|
||||||
|
|
||||||
|
tarball: promu
|
||||||
|
@echo ">> building release tarball"
|
||||||
|
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
@docker build -t alertmanager:$(shell git rev-parse --short HEAD) .
|
@echo ">> building docker image"
|
||||||
|
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
|
||||||
|
|
||||||
assets:
|
assets:
|
||||||
@echo ">> writing assets"
|
@echo ">> writing assets"
|
||||||
|
@ -46,5 +61,10 @@ assets:
|
||||||
@go-bindata $(bindata_flags) -pkg ui -o ui/bindata.go ui/...
|
@go-bindata $(bindata_flags) -pkg ui -o ui/bindata.go ui/...
|
||||||
@go-bindata $(bindata_flags) -pkg deftmpl -o template/internal/deftmpl/bindata.go template/default.tmpl
|
@go-bindata $(bindata_flags) -pkg deftmpl -o template/internal/deftmpl/bindata.go template/default.tmpl
|
||||||
|
|
||||||
|
promu:
|
||||||
|
@GOOS=$(shell uname -s | tr A-Z a-z) \
|
||||||
|
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
|
||||||
|
$(GO) get -u github.com/prometheus/promu
|
||||||
|
|
||||||
.PHONY: all format build test vet assets
|
|
||||||
|
.PHONY: all style format build test vet assets tarball docker promu
|
||||||
|
|
13
README.md
13
README.md
|
@ -1,4 +1,10 @@
|
||||||
# Alertmanager
|
# Alertmanager [![Build Status](https://travis-ci.org/prometheus/alertmanager.svg)][travis]
|
||||||
|
|
||||||
|
[![CircleCI](https://circleci.com/gh/prometheus/alertmanager/tree/master.svg?style=shield)][circleci]
|
||||||
|
[![Docker Stars](https://img.shields.io/docker/stars/prom/alertmanager.svg)][hub]
|
||||||
|
[![Docker Pulls](https://img.shields.io/docker/pulls/prom/alertmanager.svg)][hub]
|
||||||
|
[![Image Size](https://img.shields.io/imagelayers/image-size/prom/alertmanager/latest.svg)][imagelayers]
|
||||||
|
[![Image Layers](https://img.shields.io/imagelayers/layers/prom/alertmanager/latest.svg)][imagelayers]
|
||||||
|
|
||||||
The Alertmanager handles alerts sent by client applications such as the Prometheus server. It takes care of deduplicating, grouping, and routing them to the correct receiver integration such as email, PagerDuty, or OpsGenie. It also takes care of silencing and inhibition of alerts.
|
The Alertmanager handles alerts sent by client applications such as the Prometheus server. It takes care of deduplicating, grouping, and routing them to the correct receiver integration such as email, PagerDuty, or OpsGenie. It also takes care of silencing and inhibition of alerts.
|
||||||
|
|
||||||
|
@ -184,3 +190,8 @@ server {
|
||||||
|
|
||||||
![](https://raw.githubusercontent.com/prometheus/alertmanager/4e6695682acd2580773a904e4aa2e3b927ee27b7/doc/arch.jpg)
|
![](https://raw.githubusercontent.com/prometheus/alertmanager/4e6695682acd2580773a904e4aa2e3b927ee27b7/doc/arch.jpg)
|
||||||
|
|
||||||
|
|
||||||
|
[travis]: https://travis-ci.org/prometheus/alertmanager
|
||||||
|
[hub]: https://hub.docker.com/r/prom/alertmanager/
|
||||||
|
[circleci]: https://circleci.com/gh/prometheus/alertmanager
|
||||||
|
[imagelayers]: https://imagelayers.io/?images=prom/alertmanager:latest
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
machine:
|
||||||
|
environment:
|
||||||
|
DOCKER_IMAGE_NAME: prom/alertmanager
|
||||||
|
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.5.4-main
|
||||||
|
REPO_PATH: github.com/prometheus/alertmanager
|
||||||
|
pre:
|
||||||
|
- sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci'
|
||||||
|
- sudo chmod 0755 /usr/bin/docker
|
||||||
|
- sudo curl -L 'https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2' | tar xvjf - --strip-components 3 -C $HOME/bin
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
pre:
|
||||||
|
- go get -u github.com/prometheus/promu
|
||||||
|
- docker info
|
||||||
|
override:
|
||||||
|
- promu crossbuild
|
||||||
|
- ln -s .build/linux-amd64/alertmanager alertmanager
|
||||||
|
- |
|
||||||
|
if [ -n "$CIRCLE_TAG" ]; then
|
||||||
|
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG
|
||||||
|
else
|
||||||
|
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME
|
||||||
|
fi
|
||||||
|
post:
|
||||||
|
- mkdir $CIRCLE_ARTIFACTS/binaries/ && cp -a .build/* $CIRCLE_ARTIFACTS/binaries/
|
||||||
|
- docker images
|
||||||
|
|
||||||
|
test:
|
||||||
|
override:
|
||||||
|
- docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T
|
||||||
|
|
||||||
|
deployment:
|
||||||
|
hub_branch:
|
||||||
|
branch: master
|
||||||
|
owner: prometheus
|
||||||
|
commands:
|
||||||
|
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
|
||||||
|
- docker push $DOCKER_IMAGE_NAME
|
||||||
|
hub_tag:
|
||||||
|
tag: /^[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
|
||||||
|
owner: prometheus
|
||||||
|
commands:
|
||||||
|
- promu crossbuild tarballs
|
||||||
|
- promu release .tarballs
|
||||||
|
- mkdir $CIRCLE_ARTIFACTS/releases/ && cp -a .tarballs/* $CIRCLE_ARTIFACTS/releases/
|
||||||
|
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
|
||||||
|
- |
|
||||||
|
if [[ "$CIRCLE_TAG" =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then
|
||||||
|
docker tag "$DOCKER_IMAGE_NAME:$CIRCLE_TAG" "$DOCKER_IMAGE_NAME:latest"
|
||||||
|
fi
|
||||||
|
- docker push $DOCKER_IMAGE_NAME
|
|
@ -1,47 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Copyright 2015 The Prometheus Authors
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
repo_path="github.com/prometheus/alertmanager"
|
|
||||||
|
|
||||||
version=$( cat version/VERSION )
|
|
||||||
revision=$( git rev-parse --short HEAD 2> /dev/null || echo 'unknown' )
|
|
||||||
branch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown' )
|
|
||||||
host=$( hostname -f )
|
|
||||||
build_date=$( date +%Y%m%d-%H:%M:%S )
|
|
||||||
go_version=$( go version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/' )
|
|
||||||
|
|
||||||
if [ "$(go env GOOS)" = "windows" ]; then
|
|
||||||
ext=".exe"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ldflags="
|
|
||||||
-X ${repo_path}/version.Version=${version}
|
|
||||||
-X ${repo_path}/version.Revision=${revision}
|
|
||||||
-X ${repo_path}/version.Branch=${branch}
|
|
||||||
-X ${repo_path}/version.BuildUser=${USER}@${host}
|
|
||||||
-X ${repo_path}/version.BuildDate=${build_date}"
|
|
||||||
|
|
||||||
if [ "$(go env GOOS)" != "darwin" ]; then
|
|
||||||
ldflags="${ldflags} -extldflags \"-static\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
export GO15VENDOREXPERIMENT="1"
|
|
||||||
|
|
||||||
echo " > alertmanager"
|
|
||||||
go build -ldflags "${ldflags}" -o alertmanager${ext} ${repo_path}
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -1,50 +0,0 @@
|
||||||
# Copyright 2015 The Prometheus Authors
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
goroot="$1"
|
|
||||||
gopath="$2"
|
|
||||||
|
|
||||||
go_version_min="1.5"
|
|
||||||
go_version_install="1.5.1"
|
|
||||||
|
|
||||||
vernum() {
|
|
||||||
printf "%03d%03d%03d" $(echo "$1" | tr '.' ' ')
|
|
||||||
}
|
|
||||||
|
|
||||||
if command -v "go" >/dev/null; then
|
|
||||||
go_version=$(go version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/')
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If we satisfy the version requirement, there is nothing to do. Otherwise
|
|
||||||
# proceed downloading and installing a go environment.
|
|
||||||
if [ $(vernum ${go_version}) -ge $(vernum ${go_version_min}) ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
export GOPATH="${gopath}"
|
|
||||||
export GOROOT="${goroot}/${go_version_install}"
|
|
||||||
|
|
||||||
export PATH="$PATH:$GOROOT/bin"
|
|
||||||
|
|
||||||
if [ ! -x "${GOROOT}/bin/go" ]; then
|
|
||||||
|
|
||||||
mkdir -p "${GOROOT}"
|
|
||||||
|
|
||||||
os=$(uname | tr A-Z a-z)
|
|
||||||
arch=$(uname -m | sed -e 's/x86_64/amd64/' | sed -e 's/i.86/386/')
|
|
||||||
|
|
||||||
url="https://golang.org/dl"
|
|
||||||
tarball="go${go_version_install}.${os}-${arch}.tar.gz"
|
|
||||||
|
|
||||||
wget -qO- "${url}/${tarball}" | tar -C "${GOROOT}" --strip 1 -xz
|
|
||||||
fi
|
|
Loading…
Reference in New Issue