diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..348884f9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM sdurrheimer/alpine-glibc +MAINTAINER The Prometheus Authors + +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" ] \ No newline at end of file diff --git a/Makefile b/Makefile index c7f7a2f1..ec1bda53 100644 --- a/Makefile +++ b/Makefile @@ -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/... diff --git a/main.go b/main.go index 726a97ba..5454defa 100644 --- a/main.go +++ b/main.go @@ -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.") diff --git a/scripts/goenv.sh b/scripts/goenv.sh new file mode 100755 index 00000000..801bcdfa --- /dev/null +++ b/scripts/goenv.sh @@ -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 diff --git a/test/acceptance.go b/test/acceptance.go index 4615bb98..948e4651 100644 --- a/test/acceptance.go +++ b/test/acceptance.go @@ -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 { diff --git a/ui/bindata.go b/ui/bindata.go index d406e4ab..0d52d7fe 100644 --- a/ui/bindata.go +++ b/ui/bindata.go @@ -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 } @@ -518,25 +518,25 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ - "ui/app/css/main.css": uiAppCssMainCss, - "ui/app/index.html": uiAppIndexHtml, - "ui/app/js/app.js": uiAppJsAppJs, - "ui/app/partials/alert.html": uiAppPartialsAlertHtml, - "ui/app/partials/alerts.html": uiAppPartialsAlertsHtml, - "ui/app/partials/route.html": uiAppPartialsRouteHtml, + "ui/app/css/main.css": uiAppCssMainCss, + "ui/app/index.html": uiAppIndexHtml, + "ui/app/js/app.js": uiAppJsAppJs, + "ui/app/partials/alert.html": uiAppPartialsAlertHtml, + "ui/app/partials/alerts.html": uiAppPartialsAlertsHtml, + "ui/app/partials/route.html": uiAppPartialsRouteHtml, "ui/app/partials/silence-form.html": uiAppPartialsSilenceFormHtml, - "ui/app/partials/silence.html": uiAppPartialsSilenceHtml, - "ui/app/partials/silences.html": uiAppPartialsSilencesHtml, - "ui/app/partials/status.html": uiAppPartialsStatusHtml, - "ui/bindata.go": uiBindataGo, - "ui/lib/angular-moment.min.js": uiLibAngularMomentMinJs, - "ui/lib/angular-resource.min.js": uiLibAngularResourceMinJs, - "ui/lib/angular-route.min.js": uiLibAngularRouteMinJs, - "ui/lib/angular-sanitize.min.js": uiLibAngularSanitizeMinJs, - "ui/lib/angular.min.js": uiLibAngularMinJs, - "ui/lib/jquery.min.js": uiLibJqueryMinJs, - "ui/lib/kube.min.css": uiLibKubeMinCss, - "ui/lib/moment.min.js": uiLibMomentMinJs, + "ui/app/partials/silence.html": uiAppPartialsSilenceHtml, + "ui/app/partials/silences.html": uiAppPartialsSilencesHtml, + "ui/app/partials/status.html": uiAppPartialsStatusHtml, + "ui/bindata.go": uiBindataGo, + "ui/lib/angular-moment.min.js": uiLibAngularMomentMinJs, + "ui/lib/angular-resource.min.js": uiLibAngularResourceMinJs, + "ui/lib/angular-route.min.js": uiLibAngularRouteMinJs, + "ui/lib/angular-sanitize.min.js": uiLibAngularSanitizeMinJs, + "ui/lib/angular.min.js": uiLibAngularMinJs, + "ui/lib/jquery.min.js": uiLibJqueryMinJs, + "ui/lib/kube.min.css": uiLibKubeMinCss, + "ui/lib/moment.min.js": uiLibMomentMinJs, } // AssetDir returns the file names below a certain @@ -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{ @@ -589,25 +590,25 @@ var _bintree = &bintree{nil, map[string]*bintree{ "app.js": &bintree{uiAppJsAppJs, map[string]*bintree{}}, }}, "partials": &bintree{nil, map[string]*bintree{ - "alert.html": &bintree{uiAppPartialsAlertHtml, map[string]*bintree{}}, - "alerts.html": &bintree{uiAppPartialsAlertsHtml, map[string]*bintree{}}, - "route.html": &bintree{uiAppPartialsRouteHtml, map[string]*bintree{}}, + "alert.html": &bintree{uiAppPartialsAlertHtml, map[string]*bintree{}}, + "alerts.html": &bintree{uiAppPartialsAlertsHtml, map[string]*bintree{}}, + "route.html": &bintree{uiAppPartialsRouteHtml, map[string]*bintree{}}, "silence-form.html": &bintree{uiAppPartialsSilenceFormHtml, map[string]*bintree{}}, - "silence.html": &bintree{uiAppPartialsSilenceHtml, map[string]*bintree{}}, - "silences.html": &bintree{uiAppPartialsSilencesHtml, map[string]*bintree{}}, - "status.html": &bintree{uiAppPartialsStatusHtml, map[string]*bintree{}}, + "silence.html": &bintree{uiAppPartialsSilenceHtml, map[string]*bintree{}}, + "silences.html": &bintree{uiAppPartialsSilencesHtml, map[string]*bintree{}}, + "status.html": &bintree{uiAppPartialsStatusHtml, map[string]*bintree{}}, }}, }}, "bindata.go": &bintree{uiBindataGo, map[string]*bintree{}}, "lib": &bintree{nil, map[string]*bintree{ - "angular-moment.min.js": &bintree{uiLibAngularMomentMinJs, map[string]*bintree{}}, + "angular-moment.min.js": &bintree{uiLibAngularMomentMinJs, map[string]*bintree{}}, "angular-resource.min.js": &bintree{uiLibAngularResourceMinJs, map[string]*bintree{}}, - "angular-route.min.js": &bintree{uiLibAngularRouteMinJs, map[string]*bintree{}}, + "angular-route.min.js": &bintree{uiLibAngularRouteMinJs, map[string]*bintree{}}, "angular-sanitize.min.js": &bintree{uiLibAngularSanitizeMinJs, map[string]*bintree{}}, - "angular.min.js": &bintree{uiLibAngularMinJs, map[string]*bintree{}}, - "jquery.min.js": &bintree{uiLibJqueryMinJs, map[string]*bintree{}}, - "kube.min.css": &bintree{uiLibKubeMinCss, map[string]*bintree{}}, - "moment.min.js": &bintree{uiLibMomentMinJs, map[string]*bintree{}}, + "angular.min.js": &bintree{uiLibAngularMinJs, map[string]*bintree{}}, + "jquery.min.js": &bintree{uiLibJqueryMinJs, map[string]*bintree{}}, + "kube.min.css": &bintree{uiLibKubeMinCss, map[string]*bintree{}}, + "moment.min.js": &bintree{uiLibMomentMinJs, 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, "/")...)...) } -