Add Dockerfile and target, change flag

This commit is contained in:
Fabian Reinartz 2015-11-12 15:03:09 +01:00
parent d6611651c4
commit d80fd26902
6 changed files with 110 additions and 35 deletions

22
Dockerfile Normal file
View File

@ -0,0 +1,22 @@
FROM sdurrheimer/alpine-glibc
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>
WORKDIR /gopath/src/github.com/prometheus/alertmanager
COPY . /gopath/src/github.com/prometheus/alertmanager
RUN apk add --update -t build-deps tar openssl git make bash \
&& source ./scripts/goenv.sh /go /gopath \
&& CGO_ENABLED=0 make build \
&& cp alertmanager /bin/ \
&& mkdir -p /etc/alertmanager/template \
&& mv ./doc/examples/simple.yml /etc/alertmanager/config.yml \
&& cp ./template/*.tmpl /etc/alertmanager/template/ \
&& apk del --purge build-deps \
&& rm -rf /go /gopath /var/cache/apk/*
EXPOSE 9093
VOLUME [ "/alertmanager" ]
WORKDIR /alertmanager
ENTRYPOINT [ "/bin/alertmanager" ]
CMD [ "-config.file=/etc/alertmanager/config.yml", \
"-storage.path=/alertmanager" ]

View File

@ -37,6 +37,9 @@ build:
@echo ">> building binaries"
@./scripts/build.sh
docker:
@docker build -t alertmanager:$(shell git rev-parse --short HEAD) .
assets:
@echo ">> writing assets"
@$(GO) get -u github.com/jteeuwen/go-bindata/...

View File

@ -40,8 +40,8 @@ import (
var (
showVersion = flag.Bool("version", false, "Print version information.")
configFile = flag.String("config.file", "config.yml", "The configuration file")
dataDir = flag.String("data.dir", "data/", "The data directory")
configFile = flag.String("config.file", "alertmanager.yml", "The configuration file")
dataDir = flag.String("storage.path", "data/", "The data directory")
externalURL = flag.String("web.external-url", "", "The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically.")
listenAddress = flag.String("web.listen-address", ":9093", "Address to listen on for the web interface and API.")

50
scripts/goenv.sh Executable file
View File

@ -0,0 +1,50 @@
# 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

View File

@ -237,7 +237,7 @@ func (am *Alertmanager) Start() {
"-config.file", am.confFile.Name(),
"-log.level", "debug",
"-web.listen-address", am.addr,
"-data.dir", am.dir,
"-storage.path", am.dir,
)
if am.cmd == nil {

View File

@ -301,7 +301,7 @@ func uiBindataGo() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "ui/bindata.go", size: 77824, mode: os.FileMode(420), modTime: time.Unix(1447261421, 0)}
info := bindataFileInfo{name: "ui/bindata.go", size: 77824, mode: os.FileMode(420), modTime: time.Unix(1447335099, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -578,6 +578,7 @@ type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
var _bintree = &bintree{nil, map[string]*bintree{
"ui": &bintree{nil, map[string]*bintree{
"app": &bintree{nil, map[string]*bintree{
@ -658,4 +659,3 @@ func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}