ARG BASE_VERSION=latest
ARG VM_IMAGE_NAME=rockylinux
ARG VM_IMAGE_VERSION=9
ARG ISTIO_BASE_REGISTRY=gcr.io/istio-release

FROM ${ISTIO_BASE_REGISTRY}/app_sidecar_base_${VM_IMAGE_NAME}_${VM_IMAGE_VERSION}:${BASE_VERSION}

# Install the certs.
COPY certs/                           /var/lib/istio/
COPY certs/default/                   /var/run/secrets/istio/

# Install the sidecar components
ARG TARGETARCH
COPY ${TARGETARCH:-amd64}/istio-sidecar.rpm  /tmp/istio-sidecar.rpm
RUN rpm -vi /tmp/istio-sidecar.rpm && rm /tmp/istio-sidecar.rpm

# Sudoers used to allow tcpdump and other debug utilities.
COPY sudoers /etc/sudoers

# Install the Echo application
COPY echo-start.sh /usr/local/bin/echo-start.sh
COPY ${TARGETARCH:-amd64}/client /usr/local/bin/client
COPY ${TARGETARCH:-amd64}/server /usr/local/bin/server

ENTRYPOINT ["/usr/local/bin/echo-start.sh"]
