Browse Source

Merge pull request #649 from sdurrheimer/master

Small size docker image refactoring
pull/664/head
Johannes 'fish' Ziemke 10 years ago
parent
commit
2bb3efc69d
  1. 51
      Dockerfile

51
Dockerfile

@ -1,30 +1,35 @@
FROM golang:1.4 FROM alpine:edge
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com> MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>
RUN apt-get -qy update && apt-get -qy install vim-common && rm -rf /var/lib/apt/lists/* && \
go get github.com/tools/godep
WORKDIR /go/src/github.com/prometheus/prometheus ENV GOPATH /go
ADD . /go/src/github.com/prometheus/prometheus COPY . /go/src/github.com/prometheus/prometheus
RUN godep restore && go get -d RUN apk add --update -t build-deps go git mercurial vim \
RUN ./utility/embed-static.sh web/static web/templates | gofmt > web/blob/files.go && apk add -u musl && rm -rf /var/cache/apk/* \
&& go get github.com/tools/godep \
RUN go build -ldflags " \ && cd /go/src/github.com/prometheus/prometheus \
-X main.buildVersion $(cat VERSION) \ && $GOPATH/bin/godep restore && go get -d \
-X main.buildRevision $(git rev-parse --short HEAD) \ && ./utility/embed-static.sh web/static web/templates | gofmt > web/blob/files.go \
-X main.buildBranch $(git rev-parse --abbrev-ref HEAD) \ && go build -ldflags " \
-X main.buildUser root \ -X main.buildVersion $(cat VERSION) \
-X main.buildDate $(date +%Y%m%d-%H:%M:%S) \ -X main.buildRevision $(git rev-parse --short HEAD) \
-X main.goVersion $GOLANG_VERSION \ -X main.buildBranch $(git rev-parse --abbrev-ref HEAD) \
" -X main.buildUser root \
RUN cd tools/rule_checker && go build -X main.buildDate $(date +%Y%m%d-%H:%M:%S) \
ADD ./documentation/examples/prometheus.conf /prometheus.conf -X main.goVersion $(go version | awk '{print substr($3,3)}') \
" -o /bin/prometheus \
&& cd tools/rule_checker && go build && cd ../.. \
&& mkdir -p /etc/prometheus \
&& mv ./documentation/examples/prometheus.conf /etc/prometheus/prometheus.conf \
&& mv ./console_libraries/ ./consoles/ /etc/prometheus/ \
&& rm -rf /go \
&& apk del --purge build-deps
EXPOSE 9090 EXPOSE 9090
VOLUME [ "/prometheus" ] VOLUME [ "/prometheus", "/etc/prometheus" ]
WORKDIR /prometheus WORKDIR /prometheus
ENTRYPOINT [ "/go/src/github.com/prometheus/prometheus/prometheus" ] ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "-logtostderr", "-config.file=/prometheus.conf", \ CMD [ "-logtostderr", "-config.file=/etc/prometheus/prometheus.conf", \
"-storage.local.path=/prometheus", \ "-storage.local.path=/prometheus", \
"-web.console.libraries=/go/src/github.com/prometheus/prometheus/console_libraries", \ "-web.console.libraries=/etc/prometheus/console_libraries", \
"-web.console.templates=/go/src/github.com/prometheus/prometheus/consoles" ] "-web.console.templates=/etc/prometheus/consoles" ]

Loading…
Cancel
Save