FROM alpine:latest AS download

 RUN apk --update add --no-cache \
       curl \
       jq && \
     curl -L https://api.github.com/repos/helm/helm/releases/latest | \
       jq -r '.tag_name' | \
       xargs -I {} curl -L -o /tmp/helm.tar.gz https://get.helm.sh/helm-{}-linux-amd64.tar.gz && \
     tar -xzf /tmp/helm.tar.gz --strip-components=1 -C /tmp

FROM debian:11-slim

#COPY --from=alpine/helm:latest /usr/bin/helm /usr/bin/helm
COPY --from=download /tmp/helm /usr/bin/helm

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
      # (curl) Dependency for Ansible 'kubernetes.core' collection
      curl \
      git \
      jq \
      locales \
      netcat-openbsd \
      openssh-client \
      # (python3-*) Dependency for installation of Ansible
      python3-pip && \
    sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
    locale-gen && \
    pip3 install --upgrade pip && \
    pip3 install \
      ansible-core \
      # (jmespath) Dependency for Ansible 'json_query' filter
      jmespath \
      # (kubernetes) Dependency for Ansible 'kubernetes.core' collection
      kubernetes \
      # (netaddr) Dependency for Ansible 'ipaddr' filter
      netaddr \
      # (pyvmomi) Dependency for Ansible 'community.vmware' collection
      pyvmomi \
      # (pyyaml) Dependency for Ansible 'kubernetes.core' collection
      pyyaml \
      setuptools \
      wheel \
      yamllint && \
    rm -rf /var/lib/apt/lists/* && \
    rm -f /tmp/ovftool-installer

ENTRYPOINT []
CMD []
