FROM debian:bookworm-slim

LABEL maintainer="Oleg Batlaev <oleg@dttb.ru>"
LABEL description="Oleg Agent — портативный DevOps-агент"

# Базовые инструменты
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl wget git ssh nano htop \
    nmap net-tools dnsutils iputils-ping \
    python3 python3-pip python3-venv \
    jq yq ca-certificates gnupg \
    openssh-client rsync \
    && rm -rf /var/lib/apt/lists/*

# Docker CLI (для управления удалёнными Docker)
RUN install -m 0755 -d /etc/apt/keyrings && \
    curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \
    chmod a+r /etc/apt/keyrings/docker.asc && \
    echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" > /etc/apt/sources.list.d/docker.list && \
    apt-get update && apt-get install -y --no-install-recommends docker-ce-cli && \
    rm -rf /var/lib/apt/lists/*

# Ansible
RUN python3 -m venv /opt/ansible && \
    /opt/ansible/bin/pip install ansible paramiko && \
    ln -s /opt/ansible/bin/ansible /usr/local/bin/ansible && \
    ln -s /opt/ansible/bin/ansible-playbook /usr/local/bin/ansible-playbook

# Рабочая директория
WORKDIR /workspace

# Скрипт инициализации
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]
