Browse Source

Small size docker image refactoring

Signed-off-by: Steve Durrheimer <s.durrheimer@gmail.com>
pull/649/head
Steve Durrheimer 10 years ago
parent
commit
af99960974
  1. 41
      Dockerfile

41
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 \
&& $GOPATH/bin/godep restore && go get -d \
&& ./utility/embed-static.sh web/static web/templates | gofmt > web/blob/files.go \
&& go build -ldflags " \
-X main.buildVersion $(cat VERSION) \ -X main.buildVersion $(cat VERSION) \
-X main.buildRevision $(git rev-parse --short HEAD) \ -X main.buildRevision $(git rev-parse --short HEAD) \
-X main.buildBranch $(git rev-parse --abbrev-ref HEAD) \ -X main.buildBranch $(git rev-parse --abbrev-ref HEAD) \
-X main.buildUser root \ -X main.buildUser root \
-X main.buildDate $(date +%Y%m%d-%H:%M:%S) \ -X main.buildDate $(date +%Y%m%d-%H:%M:%S) \
-X main.goVersion $GOLANG_VERSION \ -X main.goVersion $(go version | awk '{print substr($3,3)}') \
" " -o /bin/prometheus \
RUN cd tools/rule_checker && go build && cd tools/rule_checker && go build && cd ../.. \
ADD ./documentation/examples/prometheus.conf /prometheus.conf && 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