FROM gcr.io/pingcap-public/third-party/golang:1.19.4-alpine3.17 as builder

ARG GITHUB_TOKEN=ghp_replace_me
RUN apk update && apk add --no-cache git make
RUN git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"

COPY . /
RUN ROOT_DIR=/ sh /build/build_all.sh

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

COPY --from=builder /build/server/core-svc /core-svc
COPY --from=builder /build/server/core-portal /core-portal
COPY --from=builder /build/server/provider-cost /provider-cost

# Download aws-iam-authenticator
RUN wget -O /usr/local/bin/aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.6.11/aws-iam-authenticator_0.6.11_linux_amd64
RUN chmod +x /usr/local/bin/aws-iam-authenticator

# Download gke-gcloud-auth-plugin
RUN wget -qO- https://storage.googleapis.com/cloud-sdk-release/for_packagers/linux/google-cloud-cli-gke-gcloud-auth-plugin_404.0.0.orig_amd64.tar.gz | tar xvz
ENV PATH=$PATH:/google-cloud-sdk/bin

CMD ["tail", "-f", "/dev/null"]
