go-zero/tools/goctl/Dockerfile

40 lines
1.2 KiB
Docker
Raw Permalink Normal View History

2022-03-19 23:07:17 +08:00
FROM golang:alpine AS builder
LABEL stage=gobuilder
ENV CGO_ENABLED=0
ENV GOPROXY=https://goproxy.cn,direct
2022-03-19 23:07:17 +08:00
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
2024-03-02 23:40:31 +08:00
RUN addgroup -g 1000 -S app && adduser -u 1000 -S app -G app
2022-03-19 23:07:17 +08:00
WORKDIR /build
COPY . .
2024-03-02 23:40:31 +08:00
RUN go mod download
2022-03-19 23:07:17 +08:00
RUN go build -ldflags="-s -w" -o /app/goctl ./goctl.go
FROM golang:alpine
2022-03-19 23:07:17 +08:00
RUN apk update --no-cache && apk add --no-cache protoc
2024-03-02 23:40:31 +08:00
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
2022-03-19 23:07:17 +08:00
WORKDIR /app
2024-03-02 23:40:31 +08:00
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)"
2022-03-19 23:07:17 +08:00
2024-03-02 23:40:31 +08:00
ENTRYPOINT ["/usr/local/bin/goctl"]