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. 51
      Dockerfile

51
Dockerfile

@ -1,30 +1,35 @@
FROM golang:1.4
FROM alpine:edge
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
ADD . /go/src/github.com/prometheus/prometheus
ENV GOPATH /go
COPY . /go/src/github.com/prometheus/prometheus
RUN godep restore && go get -d
RUN ./utility/embed-static.sh web/static web/templates | gofmt > web/blob/files.go
RUN go build -ldflags " \
-X main.buildVersion $(cat VERSION) \
-X main.buildRevision $(git rev-parse --short HEAD) \
-X main.buildBranch $(git rev-parse --abbrev-ref HEAD) \
-X main.buildUser root \
-X main.buildDate $(date +%Y%m%d-%H:%M:%S) \
-X main.goVersion $GOLANG_VERSION \
"
RUN cd tools/rule_checker && go build
ADD ./documentation/examples/prometheus.conf /prometheus.conf
RUN apk add --update -t build-deps go git mercurial vim \
&& apk add -u musl && rm -rf /var/cache/apk/* \
&& go get github.com/tools/godep \
&& 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.buildRevision $(git rev-parse --short HEAD) \
-X main.buildBranch $(git rev-parse --abbrev-ref HEAD) \
-X main.buildUser root \
-X main.buildDate $(date +%Y%m%d-%H:%M:%S) \
-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
VOLUME [ "/prometheus" ]
VOLUME [ "/prometheus", "/etc/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/go/src/github.com/prometheus/prometheus/prometheus" ]
CMD [ "-logtostderr", "-config.file=/prometheus.conf", \
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "-logtostderr", "-config.file=/etc/prometheus/prometheus.conf", \
"-storage.local.path=/prometheus", \
"-web.console.libraries=/go/src/github.com/prometheus/prometheus/console_libraries", \
"-web.console.templates=/go/src/github.com/prometheus/prometheus/consoles" ]
"-web.console.libraries=/etc/prometheus/console_libraries", \
"-web.console.templates=/etc/prometheus/consoles" ]

Loading…
Cancel
Save