FROM gcr.io/pingcap-public/third-party/baseimage/golang:1.24 as builder

ARG GITHUB_TOKEN=ghp_LxxxxxF

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

WORKDIR /build

# Begin to cache the dependency go modules
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/
RUN go mod download
# End of caching the dependency go modules

COPY . ./
RUN make build-dataflow-personal

FROM golang:1.21

COPY --from=builder /build/dist/dataflow /dataflow
RUN go mod download github.com/go-delve/delve@v1.21.0
WORKDIR /go/pkg/mod/github.com/go-delve/delve@v1.21.0/
RUN go mod tidy
RUN go mod vendor
RUN go install ./cmd/dlv/

CMD ["/dataflow"]
