FROM gcr.io/pingcap-public/pingcap/alpine:3.22.1 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.7.7/aws-iam-authenticator_0.7.7_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

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
# Required by the security team to replace base image
FROM frolvlad/alpine-glibc:alpine-3.22_glibc-2.42
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 bin/autoscale_engine autoscale_engine
COPY config/autoscale_engine.yaml autoscale_engine.yaml
RUN chmod +x /autoscale_engine
USER 65532:65532
ENTRYPOINT ["/autoscale_engine"]
