go-template/app/api/example_api/Dockerfile

22 lines
621 B
Docker
Raw Normal View History

2021-12-27 21:02:11 +08:00
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
2021-12-28 11:55:55 +08:00
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o api_example_api ./app/api/example_api
2021-12-29 20:32:45 +08:00
FROM alpine as example_api
2021-12-27 21:02:11 +08:00
WORKDIR /go/src
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /go/src/api_example_api ./
ENV TZ=Asia/Shanghai
ENV env=pro
ENV endpoints=http://etcd-server:2379
2021-12-28 11:55:55 +08:00
RUN chmod +x ./api_example_api
2021-12-29 20:32:45 +08:00
LABEL io.portainer.accesscontrol.teams="admin"
2021-12-27 21:02:11 +08:00
EXPOSE 8080
2021-12-28 11:55:55 +08:00
CMD ["./api_example_api"]