FROM python:3.9-slim

RUN apt-get update && apt-get install -y \
    curl wget gnupg2 apt-transport-https \
    && rm -rf /var/lib/apt/lists/*

RUN wget -qO /usr/share/keyrings/elasticsearch-keyring.gpg \
    https://artifacts.elastic.co/GPG-KEY-elasticsearch && \
    echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] \
    https://artifacts.elastic.co/packages/8.x/apt stable main" \
    > /etc/apt/sources.list.d/elastic-8.x.list && \
    apt-get update && \
    apt-get install -y filebeat && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

COPY filebeat.yml /etc/filebeat/filebeat.yml
COPY start.sh /app/start.sh
RUN chmod +x /app/start.sh

CMD ["/app/start.sh"]
