oliver006 / rethinkdb_exporter

Prometheus exporter for RethinkDB cluster and table metrics. Supports RethinkDB 2.x

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multi-stage Dockerfile

dpgeekzero opened this issue · comments

commented

https://docs.docker.com/engine/userguide/eng-image/multistage-build/


FROM golang:1.7 as builder

MAINTAINER Oliver o@21zoo.com

WORKDIR /go/src/github.com/oliver006/rethinkdb_exporter
ENV GOPATH /go
COPY . /go/src/github.com/oliver006/rethinkdb_exporter

RUN go get
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o rethinkdb_exporter .

FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /go/src/github.com/oliver006/rethinkdb_exporter/rethinkdb_exporter .
ENTRYPOINT ["./rethinkdb_exporter"]

Thanks!

I'll have a look into multi-stage as this might come in handy to reduce the image size. An alternative way to do this would be to change the build process and not build the binary in the docker image but separately and then just COPY it in (see redis_exporter as an example here: https://github.com/oliver006/redis_exporter/blob/master/Dockerfile#L1-L7)

Also, I'm not sure if CircleCI is on the latest docker version yet that's needed for multi-stage builds.