| 1 |
# This Dockerfile builds an image for a client_golang example. |
| 2 |
# |
| 3 |
# Use as (from the root for the client_golang repository): |
| 4 |
# docker build -f Dockerfile -t prometheus/golang-example . |
| 5 |
|
| 6 |
# Run as |
| 7 |
# docker run -P prometheus/golang-example /random |
| 8 |
# or |
| 9 |
# docker run -P prometheus/golang-example /simple |
| 10 |
|
| 11 |
# Test as |
| 12 |
# curl $ip:$port/metrics |
| 13 |
|
| 14 |
# Builder image, where we build the example. |
| 15 |
FROM golang:1 AS builder |
| 16 |
WORKDIR /go/src/github.com/prometheus/client_golang |
| 17 |
COPY . . |
| 18 |
WORKDIR /go/src/github.com/prometheus/client_golang/prometheus |
| 19 |
RUN go get -d |
| 20 |
WORKDIR /go/src/github.com/prometheus/client_golang/examples/random |
| 21 |
RUN CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags '-w' |
| 22 |
WORKDIR /go/src/github.com/prometheus/client_golang/examples/simple |
| 23 |
RUN CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags '-w' |
| 24 |
WORKDIR /go/src/github.com/prometheus/client_golang/examples/gocollector |
| 25 |
RUN CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags '-w' |
| 26 |
|
| 27 |
# Final image. |
| 28 |
FROM quay.io/prometheus/busybox:latest |
| 29 |
LABEL maintainer="The Prometheus Authors <[email protected]>" |
| 30 |
COPY --from=builder /go/src/github.com/prometheus/client_golang/examples/random \ |
| 31 |
/go/src/github.com/prometheus/client_golang/examples/simple \ |
| 32 |
/go/src/github.com/prometheus/client_golang/examples/gocollector ./ |
| 33 |
EXPOSE 8080 |
| 34 |
CMD ["echo", "Please run an example. Either /random, /simple or /gocollector"] |