Skip to content

Commit

Permalink
Merge pull request prometheus#1 from simonpasquier/cd-build-auto
Browse files Browse the repository at this point in the history
Modify upstream for auto build
  • Loading branch information
simonpasquier authored Jun 25, 2018
2 parents 1322a5a + 8acc2f6 commit cfc9236
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 1 deletion.
1 change: 1 addition & 0 deletions .promu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ build:
path: ./cmd/amtool
flags: -a -tags netgo
ldflags: |
-s
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}}
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile.rhel7
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM rhel7:7-released
LABEL maintainer="OpenShift Development <[email protected]>" \
com.redhat.component="golang-github-prometheus-alertmanager-docker" \
name="openshift3/prometheus-alertmanager" \
version="v0.15.0" \
architecture=x86_64

RUN yum-config-manager --enable rhel-7-server-ose-3.9-rpms && \
yum install -y prometheus-alertmanager && \
yum clean all

EXPOSE 9093
WORKDIR /alertmanager
VOLUME [ "/alertmanager" ]
ENTRYPOINT [ "/bin/alertmanager" ]
CMD [ "--config.file=/etc/alertmanager/config.yml", \
"--storage.path=/alertmanager" ]
10 changes: 9 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ unexport GOBIN
GO ?= go
GOFMT ?= $(GO)fmt
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
PROMU := $(FIRST_GOPATH)/bin/promu
ifeq ($(BUILD_PROMU),false)
PROMU := promu
else
PROMU := $(FIRST_GOPATH)/bin/promu
endif
STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
GOVENDOR := $(FIRST_GOPATH)/bin/govendor
pkgs = ./...
Expand Down Expand Up @@ -102,7 +106,11 @@ docker:

.PHONY: promu
promu:
ifeq ($(BUILD_PROMU),false)
@echo "using installed promu $(shell which promu)"
else
GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu
endif

.PHONY: $(STATICCHECK)
$(STATICCHECK):
Expand Down
110 changes: 110 additions & 0 deletions golang-github-prometheus-alertmanager.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@

%global debug_package %{nil}

%global provider github
%global provider_tld com
%global project prometheus
%global repo alertmanager
# https://github.com/prometheus/alertmanager
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
# %commit is intended to be set by tito. The values in this spec file will not be kept up to date.
%{!?commit:
%global commit 5e86f61bd73c6325d6049ab3dbcb468ede26dfe0
}
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global gopathdir %{_sourcedir}/go
%global upstream_ver 0.15.0
%global rpm_ver %(v=%{upstream_ver}; echo ${v//-/_})
%global download_prefix %{provider}.%{provider_tld}/openshift/%{repo}

Name: golang-%{provider}-%{project}-%{repo}
# Version and release information will be automatically managed by CD
# It will be kept in sync with OCP builds.
Version: %{rpm_ver}
Release: 1.git%{shortcommit}%{?dist}
Summary: The Prometheus Alertmanager handles alerts sent by client applications such as the Prometheus server.
License: ASL 2.0
URL: https://prometheus.io/
Source0: https://%{download_prefix}/archive/%{commit}/%{repo}-%{commit}.tar.gz

# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
# promu-based packages FTBFS on aarch64 (#1487462)
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm} ppc64le s390x}
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
BuildRequires: glibc-static
BuildRequires: prometheus-promu

%description
%{summary}

%package -n %{project}-alertmanager
Summary: %{summary}
Provides: prometheus-alertmanager = %{version}-%{release}
Obsoletes: prometheus-alertmanager < %{version}-%{release}

%description -n %{project}-alertmanager
%{summary}

%prep
%setup -q -n %{repo}-%{commit}

%build
# Go expects a full path to the sources which is not included in the source
# tarball so create a link with the expected path
mkdir -p %{gopathdir}/src/%{provider}.%{provider_tld}/%{project}
GOSRCDIR=%{gopathdir}/src/%{import_path}
if [ ! -e "$GOSRCDIR" ]; then
ln -s `pwd` "$GOSRCDIR"
fi
export GOPATH=%{gopathdir}

make build BUILD_PROMU=false

%install
install -d %{buildroot}%{_bindir}
install -D -p -m 0755 alertmanager %{buildroot}%{_bindir}/alertmanager
install -D -p -m 0755 amtool %{buildroot}%{_bindir}/amtool
install -D -p -m 0644 doc/examples/simple.yml \
%{buildroot}%{_sysconfdir}/prometheus/alertmanager.yml
install -D -p -m 0644 prometheus-alertmanager.service \
%{buildroot}%{_unitdir}/prometheus-alertmanager.service
install -D -p -m 0644 prometheus-alertmanager.sysconfig \
%{buildroot}%{_sysconfdir}/sysconfig/prometheus-alertmanager
install -d %{buildroot}%{_sharedstatedir}/prometheus-alertmanager

%files -n %{project}-alertmanager
%license LICENSE NOTICE
%doc CHANGELOG.md CONTRIBUTING.md MAINTAINERS.md README.md
%{_bindir}/alertmanager
%{_bindir}/amtool
%{_sysconfdir}/prometheus/alertmanager.yml
%{_unitdir}/prometheus-alertmanager.service
%{_sysconfdir}/sysconfig/prometheus-alertmanager
%{_sharedstatedir}/prometheus-alertmanager

%changelog
* Mon Jun 18 2018 Simon Pasquier <[email protected]> - 0.15.0-1
- Upgrade to 0.15.0

* Tue Feb 13 2018 Simon Pasquier <[email protected]> - 0.14.0-1
- Upgrade to 0.14.0

* Wed Jan 31 2018 Paul Gier <[email protected]> - 0.13.0-1
- Upgrade to 0.13.0 and include amtool

* Thu Jan 18 2018 Simon Pasquier <[email protected]> - 0.12.0-1
- Upgrade to 0.12.0

* Wed Jan 10 2018 Yaakov Selkowitz <[email protected]> - 0.9.1-3
- Rebuilt for ppc64le, s390x enablement

* Wed Nov 08 2017 Paul Gier <[email protected]> - 0.9.1-2
- upgrade to 0.9.1

* Fri Sep 01 2017 Paul Gier <[email protected]> - 0.8.0-2
- Strip debug and remove duplicate package

* Fri Aug 25 2017 Paul Gier <[email protected]> - 0.8.0-1
- First package for Openshift
13 changes: 13 additions & 0 deletions prometheus-alertmanager.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Prometheus Alertmanager handling alerts sent by client applications such as the Prometheus server.
Documentation=https://github.com/prometheus/alertmanager

[Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/prometheus-alertmanager
ExecStart=/usr/bin/alertmanager $CONFIG_FILE $STORAGE_PATH $CLUSTER_PEERS $OTHER_ARGS
ExecReload=/bin/kill -SIGHUP $MAINPID
ExecStop=/bin/kill -SIGKILL $MAINPID

[Install]
WantedBy=multi-user.target
16 changes: 16 additions & 0 deletions prometheus-alertmanager.sysconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is a systemd environment file which provides arguments to the systemd
# prometheus alertmanager service.
# For more info see: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=

# The location of the configuration file.
CONFIG_FILE="--config.file=/etc/prometheus/alertmanager.yml"

# The path for storing data.
STORAGE_PATH="--storage.path=/var/lib/prometheus-alertmanager"

# The list of peers to connect to.
# CLUSTER_PEERS="--cluster.peer=peer1:9094 --cluster.peer=peer2:9094"
CLUSTER_PEERS=""

# Other arguments.
OTHER_ARGS=""

0 comments on commit cfc9236

Please sign in to comment.