FROM gcr.io/pingcap-public/pingcap/alpine:3.15.5 as builder
WORKDIR /workspace
# Download aws-iam-authenticator
RUN wget -O aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.5.21/aws-iam-authenticator_0.5.21_linux_amd64
# Download latest kubectl
RUN wget -O kubectl https://dl.k8s.io/release/v1.33.2/bin/linux/amd64/kubectl
# Download ack-ram-tool
RUN wget -qO- https://github.com/AliyunContainerService/ack-ram-tool/releases/download/v0.20.0-beta.6/ack-ram-tool_0.20.0-beta.6_Linux_x86_64.tar.gz | tar xvz
# Download kubelogin for azure
RUN wget -qO- https://github.com/Azure/kubelogin/releases/download/v0.2.14/kubelogin-linux-amd64.zip | busybox unzip -d . -

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/pingcap-public/pingcap/alpine-glibc:alpine-3.14.3
WORKDIR /
COPY --from=builder /workspace/aws-iam-authenticator /usr/local/bin/
COPY --from=builder /workspace/kubectl /usr/local/bin/
COPY --from=builder /workspace/ack-ram-tool /usr/local/bin/
COPY --from=builder /workspace/bin/linux_amd64/kubelogin /usr/local/bin/
RUN chmod +x /usr/local/bin/kubelogin
RUN chmod +x /usr/local/bin/aws-iam-authenticator
RUN chmod +x /usr/local/bin/kubectl
COPY --chmod=+x scripts/taskcleanup.sh taskcleanup.sh
ENTRYPOINT ["/taskcleanup.sh"]
