use official prometheus repo
This commit is contained in:
parent
cf605f3d29
commit
296f7609da
@ -1,3 +1,2 @@
|
||||
PROMETHEUS_CONFIG_FILE_PATH=/path/to/prometheus/config/prometheus.yaml
|
||||
PROMETHEUS_DATA_PATH=/path/to/prometheus/data
|
||||
PROMETHEUS_REPO='https://github.com/prometheus/prometheus.git'
|
||||
|
47
Dockerfile
47
Dockerfile
@ -1,47 +0,0 @@
|
||||
ARG GO_VERSION=alpine
|
||||
|
||||
FROM golang:${GO_VERSION} as build
|
||||
|
||||
ARG PROMETHEUS_VERSION=
|
||||
ARG PROMETHEUS_REPO
|
||||
|
||||
RUN \
|
||||
apk update --no-cache &&\
|
||||
apk add --no-cache \
|
||||
bash \
|
||||
curl \
|
||||
git \
|
||||
make \
|
||||
yarn && \
|
||||
git config --global advice.detachedHead false
|
||||
RUN \
|
||||
echo "selected repo: ${PROMETHEUS_REPO}" && \
|
||||
if [ -z "${PROMETHEUS_VERSION}" ]; then \
|
||||
PROMETHEUS_VERSION=$( \
|
||||
git ls-remote "${PROMETHEUS_REPO}" | \
|
||||
awk '$2 ~ /^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+$/ { print substr($2,11) }' | sort -V | tail -n1 \
|
||||
) ; \
|
||||
fi && \
|
||||
echo "selected prometheus branch: ${PROMETHEUS_VERSION}" && \
|
||||
cd / && \
|
||||
git clone \
|
||||
--branch="${PROMETHEUS_VERSION}" \
|
||||
--depth=1 \
|
||||
"${PROMETHEUS_REPO}" \
|
||||
prometheus && \
|
||||
cd prometheus && \
|
||||
CGO_ENABLED=0 make build
|
||||
|
||||
FROM alpine:3
|
||||
|
||||
COPY --from=build /prometheus/prometheus /prometheus
|
||||
RUN mkdir /data
|
||||
|
||||
ENV UID=1000
|
||||
ENV GID=1000
|
||||
|
||||
CMD (grep -qE '^prometheus:x:'"${UID}"':prometheus$' /etc/group || addgroup -g "${GID}" prometheus) && \
|
||||
(grep -qE '^prometheus:x:'"${UID}"':'"${GID}"':.*$' /etc/passwd || adduser -D -u "${UID}" -G prometheus prometheus) && \
|
||||
chmod 700 /prometheus && chown prometheus:prometheus /prometheus && \
|
||||
chown prometheus:prometheus /data && \
|
||||
su prometheus -c '/prometheus --config.file=/config/prometheus.yaml --storage.tsdb.path=/data/' 2>&1
|
@ -2,12 +2,13 @@ version: '3'
|
||||
|
||||
services:
|
||||
prometheus:
|
||||
build:
|
||||
context: ./
|
||||
args:
|
||||
- PROMETHEUS_REPO=${PROMETHEUS_REPO}
|
||||
container_name: prometheus
|
||||
image: prometheus:local
|
||||
image: prom/prometheus
|
||||
command: >
|
||||
--storage.tsdb.path=/prometheus
|
||||
--config.file=/etc/prometheus/prometheus.yml
|
||||
--storage.tsdb.retention.time=30d
|
||||
--storage.tsdb.retention.size=2GB
|
||||
logging:
|
||||
driver: journald
|
||||
options:
|
||||
@ -16,6 +17,6 @@ services:
|
||||
ports:
|
||||
- 9090:9090
|
||||
volumes:
|
||||
- ${PROMETHEUS_CONFIG_FILE_PATH}:/config/prometheus.yaml:ro
|
||||
- ${PROMETHEUS_DATA_PATH}:/data:rw
|
||||
- ${PROMETHEUS_CONFIG_FILE_PATH}:/etc/prometheus/prometheus.yml:ro
|
||||
- ${PROMETHEUS_DATA_PATH}:/prometheus:rw
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user