2021-10-15 08:17:56 +00:00
|
|
|
FROM golang:1.17.2-alpine3.14 as builder
|
|
|
|
|
2021-10-15 16:58:49 +00:00
|
|
|
RUN apk update && apk add --no-cache git tzdata
|
|
|
|
|
2021-10-15 08:17:56 +00:00
|
|
|
WORKDIR /src
|
2021-10-15 16:58:49 +00:00
|
|
|
COPY go.mod go.sum /src/
|
|
|
|
RUN go mod download
|
2021-10-15 08:17:56 +00:00
|
|
|
COPY . .
|
2021-10-15 16:58:49 +00:00
|
|
|
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" \
|
2021-10-18 01:14:30 +00:00
|
|
|
-o /go/bin/myip cmd/myip/main.go
|
2021-10-15 08:17:56 +00:00
|
|
|
|
|
|
|
FROM alpine:3.14
|
2021-10-15 17:20:39 +00:00
|
|
|
|
2021-10-15 08:17:56 +00:00
|
|
|
EXPOSE 5080
|
2021-10-15 17:20:39 +00:00
|
|
|
ENV PATH="/go/bin:${PATH}"
|
2021-10-15 08:17:56 +00:00
|
|
|
|
2021-10-15 16:58:49 +00:00
|
|
|
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
2021-10-15 08:17:56 +00:00
|
|
|
COPY --from=builder /go/bin/myip /go/bin/myip
|
2021-10-16 18:22:55 +00:00
|
|
|
CMD ["/go/bin/myip","serve","-f","/var/log/myip.log"]
|
2021-10-15 17:20:39 +00:00
|
|
|
|
|
|
|
# use cmd instead for flexibility
|
|
|
|
# ENTRYPOINT ["/go/bin/myip","serve"]
|
|
|
|
|