muyu-apiserver/deploy/Dockerfile.inventory

22 lines
811 B
Docker
Raw Permalink Normal View History

ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library
FROM ${BASE_REGISTRY}/golang:1.24-alpine AS builder
ENV GOPROXY=https://goproxy.cn,direct
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories
RUN apk add --no-cache git
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server ./rpc/inventory/inventory.go
FROM ${BASE_REGISTRY}/alpine:3.20
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories
RUN apk add --no-cache ca-certificates tzdata gettext
WORKDIR /app
COPY --from=builder /server ./inventory
COPY deploy/etc/inventory.yaml etc/inventory.yaml
COPY deploy/entrypoint.sh /entrypoint.sh
EXPOSE 9002
ENTRYPOINT ["/entrypoint.sh"]
CMD ["./inventory", "-f", "etc/inventory.yaml"]