PandaWiki/backend/Dockerfile.consumer

30 lines
856 B
Docker
Raw Permalink Normal View History

FROM --platform=$BUILDPLATFORM golang:1.24.3-alpine AS builder
WORKDIR /src
ENV CGO_ENABLED=0
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
2025-06-23 17:58:48 +08:00
go mod download
COPY . .
ARG TARGETOS TARGETARCH
2025-06-23 17:58:48 +08:00
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "-s -w -extldflags '-static'" -o /build/panda-wiki-consumer cmd/consumer/main.go cmd/consumer/wire_gen.go
FROM alpine:3.21 AS consumer
RUN apk update \
&& apk upgrade \
&& apk add --no-cache ca-certificates tzdata \
2025-06-23 17:58:48 +08:00
&& update-ca-certificates 2>/dev/null || true \
&& rm -rf /var/cache/apk/*
WORKDIR /app
COPY --from=builder /build/panda-wiki-consumer /app/panda-wiki-consumer
2025-06-23 17:58:48 +08:00
COPY --from=builder /src/store/pg/migration /app/migration
CMD ["./panda-wiki-consumer"]