mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Add goenv script and fix Docker
This commit is contained in:
parent
ad64474076
commit
c8a092ebcc
|
@ -1,17 +1,18 @@
|
||||||
FROM sdurrheimer/alpine-glibc
|
FROM sdurrheimer/alpine-glibc
|
||||||
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>
|
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /gopath/src/github.com/prometheus/prometheus
|
||||||
COPY . /app
|
COPY . /gopath/src/github.com/prometheus/prometheus
|
||||||
|
|
||||||
RUN apk add --update -t build-deps git make bash go \
|
RUN apk add --update -t build-deps tar openssl git make bash \
|
||||||
|
&& source ./scripts/goenv.sh /go /gopath \
|
||||||
&& make build \
|
&& make build \
|
||||||
&& cp prometheus promtool /bin/ \
|
&& cp prometheus promtool /bin/ \
|
||||||
&& mkdir -p /etc/prometheus \
|
&& mkdir -p /etc/prometheus \
|
||||||
&& mv ./documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml \
|
&& mv ./documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml \
|
||||||
&& mv ./console_libraries/ ./consoles/ /etc/prometheus/ \
|
&& mv ./console_libraries/ ./consoles/ /etc/prometheus/ \
|
||||||
&& apk del --purge build-deps \
|
&& apk del --purge build-deps \
|
||||||
&& rm -rf /app /var/cache/apk/*
|
&& rm -rf /go /gopath /var/cache/apk/*
|
||||||
|
|
||||||
EXPOSE 9090
|
EXPOSE 9090
|
||||||
VOLUME [ "/prometheus" ]
|
VOLUME [ "/prometheus" ]
|
||||||
|
|
|
@ -36,7 +36,7 @@ Debian and RPM packages are being worked on.
|
||||||
### Building from source
|
### Building from source
|
||||||
|
|
||||||
To build Prometheus from the source code yourself you need to have a working
|
To build Prometheus from the source code yourself you need to have a working
|
||||||
go environment with [version 1.5 or greater installed](http://golang.org/doc/install).
|
Go environment with [version 1.5 or greater installed](http://golang.org/doc/install).
|
||||||
|
|
||||||
You can directly use the `go` tool to download and install the `prometheus`
|
You can directly use the `go` tool to download and install the `prometheus`
|
||||||
and `promtool` binaries into your `GOPATH`:
|
and `promtool` binaries into your `GOPATH`:
|
||||||
|
@ -53,7 +53,7 @@ You can also clone the repository yourself and build using `make`:
|
||||||
$ make
|
$ make
|
||||||
$ ./prometheus -config.file=your_config.yml
|
$ ./prometheus -config.file=your_config.yml
|
||||||
|
|
||||||
The makefile provides several targets:
|
The Makefile provides several targets:
|
||||||
|
|
||||||
* *build*: build the `prometheus` and `promtool` binaries
|
* *build*: build the `prometheus` and `promtool` binaries
|
||||||
* *test*: run the tests
|
* *test*: run the tests
|
||||||
|
|
50
scripts/goenv.sh
Executable file
50
scripts/goenv.sh
Executable 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
|
Loading…
Reference in a new issue