FROM golang:1.24 as builder


# pass GITHUB_TOKEN from command-line argument --build-arg
ARG GITHUB_TOKEN=

RUN git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"

WORKDIR /build
COPY go.mod go.sum ./
# Copy all the locally-replaced go modules' go.mod and go.sum file here
COPY ./idl/pbgen/go.mod ./idl/pbgen/go.sum ./idl/pbgen/
COPY ./pkg/event/go.mod ./pkg/event/
COPY ./pkg/cloud_storage/go.mod ./pkg/cloud_storage/
RUN go mod download -x

COPY . ./
RUN make build

FROM gcr.io/pingcap-public/pingcap/alpine:alpine-3.14.6

# `version.GitHash` not set
COPY --from=builder /build/bin/server /serverless-service
