# docker build -f ansible/Dockerfile -t arcodange-ansible:0.0.0 ansible/
FROM python:slim

RUN apt update && apt install openssh-client socat gosu git curl -y

RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" ; \
    chmod +x kubectl; \
    mv kubectl /usr/local/bin/; \
    curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

COPY nonroot_ssh_proxy_setup.sh /usr/local/bin/nonroot_ssh_proxy_setup.sh
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
COPY requirements.yml /tmp/requirements.yml
RUN chmod +x /usr/local/bin/*.sh
ENV SSH_AUTH_SOCK=/home/arcodange/.ssh/socket

RUN useradd -rm -d /home/arcodange -s /bin/bash -g root -G sudo,root -u 1000 arcodange
USER 1000
WORKDIR /home/arcodange/code
ENV PATH=/home/arcodange/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN pip install ansible-core jmespath kubernetes dnspython
ENV GALAXY_SERVER=https://beta-galaxy.ansible.com/api/
RUN ansible-galaxy collection install --token 11bebd8fd1ad4009f700bdedbeb80b19743ce3d3 \
    -r /tmp/requirements.yml
# community.general community.docker ansible.posix kubernetes.core

ENV ANSIBLE_HOST_KEY_CHECKING=False
ENV ANSIBLE_FORCE_COLOR=True=True
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]