FROM golang:1.17.2-alpine3.14 as builder RUN apk update && apk add --no-cache git tzdata WORKDIR /src COPY go.mod go.sum /src/ RUN go mod download COPY . . RUN VERSION=$(git describe --tags) BUILD=$(git rev-parse --short HEAD) && \ GOOS=linux GOARCH=amd64 \ go build -ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD} -w" \ -o /go/bin/myip cmd/myip/main.go FROM alpine:3.14 EXPOSE 5080 ENV PATH="/go/bin:${PATH}" COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=builder /go/bin/myip /go/bin/myip CMD ["/go/bin/myip","serve","-f","/var/log/myip.log"] # use cmd instead for flexibility # ENTRYPOINT ["/go/bin/myip","serve"]