-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (27 loc) · 1.21 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
FROM golang:alpine AS builder
LABEL stage=gobuilder
ENV CGO_ENABLED=0
ENV GOPROXY=https://goproxy.cn,direct
RUN apk update --no-cache && apk add --no-cache tzdata
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
RUN addgroup -g 1000 -S app && adduser -u 1000 -S app -G app
WORKDIR /build
COPY . .
RUN go mod download
RUN go build -ldflags="-s -w" -o /app/goctl ./goctl.go
FROM golang:alpine
RUN apk update --no-cache && apk add --no-cache protoc
COPY --from=builder /etc/passwd /etc/group /etc/
COPY --from=builder /usr/share/zoneinfo/ /usr/share/zoneinfo/
COPY --from=builder --chown=1000:1000 /go/bin/protoc-gen-go* /app/goctl /usr/local/bin/
ENV TZ=Asia/Shanghai
WORKDIR /app
USER app
LABEL org.opencontainers.image.authors="Kevin Wan"
LABEL org.opencontainers.image.base.name="docker.io/library/golang:alpine"
LABEL org.opencontainers.image.description="A cloud-native Go microservices framework with cli tool for productivity."
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.source="https://github.com/zeromicro/go-zero"
LABEL org.opencontainers.image.title="goctl (cli)"
ENTRYPOINT ["/usr/local/bin/goctl"]