FROM gcr.io/pingcap-public/pingcap/alpine:3.15.5 as builder
WORKDIR /workspace
# Download aws-iam-authenticator, this is used to construct kubeconfig and access eks.
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 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/
RUN chmod +x /usr/local/bin/aws-iam-authenticator
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
COPY bin/executor executor
RUN mkdir -p /templates
COPY  deployments/templates/* /templates/
USER 65532:65532
ENTRYPOINT ["/executor"]
