38 lines
912 B
Docker
38 lines
912 B
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
# 编译阶段
|
|
FROM quay.io/0voice/golang:1.20 AS builder
|
|
|
|
ENV CGO_ENABLED=0 \
|
|
GOOS=linux \
|
|
GOARCH=amd64 \
|
|
GOPROXY=https://goproxy.cn|https://proxy.golang.google.cn|direct \
|
|
GOSUMDB=sum.golang.google.cn
|
|
|
|
WORKDIR /src/keywords-filter
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
go mod download -x
|
|
|
|
COPY . .
|
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
go build -trimpath -ldflags="-s -w" -o /out/keywords-filter ./filter-server
|
|
|
|
# 运行阶段
|
|
FROM quay.io/0voice/alpine:3.18 AS runtime
|
|
|
|
COPY ./grpc_health_probe-linux-amd64 /usr/bin/grpc_health_probe
|
|
RUN chmod +x /usr/bin/grpc_health_probe
|
|
|
|
LABEL maintainer="nick"
|
|
|
|
WORKDIR /app/
|
|
|
|
COPY --from=builder /out/keywords-filter ./keywords-filter
|
|
|
|
ENTRYPOINT ["./keywords-filter"] |