24 lines
650 B
Docker
24 lines
650 B
Docker
|
FROM golang:1.17 as builder
|
||
|
ENV GO111MODULE on
|
||
|
ENV GOPROXY https://goproxy.io,direct
|
||
|
WORKDIR /go/cache
|
||
|
ADD go.mod .
|
||
|
ADD go.sum .
|
||
|
RUN go mod download
|
||
|
WORKDIR /go/src
|
||
|
ADD . .
|
||
|
RUN go mod tidy
|
||
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o api_example_api
|
||
|
|
||
|
FROM alpine as brahma-api
|
||
|
WORKDIR /go/src
|
||
|
#LABEL maintainer "The Prometheus Authors <prometheus-developers@googlegroups.com>"
|
||
|
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||
|
# copy main and config from builder
|
||
|
COPY --from=builder /go/src/api_example_api ./
|
||
|
ENV TZ=Asia/Shanghai
|
||
|
ENV env=pro
|
||
|
ENV endpoints=http://etcd-server:2379
|
||
|
RUN chmod +x ./main
|
||
|
EXPOSE 8080
|
||
|
CMD ["./main"]
|