update Dockerfile

This commit is contained in:
2024-03-01 18:01:03 +08:00
parent 3d86e6efe6
commit ac96dad00a

View File

@ -1,12 +1,15 @@
FROM alpine:latest
FROM golang:1.18-alpine3.16 AS base
WORKDIR /app
COPY . .
RUN go mod tidy && go build -o nsq_exporter .
FROM alpine:3.16
EXPOSE 9117
ENV GOPATH /go
ENV APPPATH $GOPATH/src/github.com/lovoo/nsq_exporter
COPY . $APPPATH
RUN apk add --update -t build-deps go git mercurial libc-dev gcc libgcc \
&& cd $APPPATH && go get -d && go build -o /nsq_exporter \
&& apk del --purge build-deps && rm -rf $GOPATH
COPY --from=base /app/nsq_exporter /nsq_exporter
ENTRYPOINT ["/nsq_exporter"]