FROM java:8-jre

ENV LS_VERSION 5

ENV VERSION 5.1.2
ENV URL https://staging.elastic.co/5.1.2-429c1ec3/downloads/logstash/logstash-5.1.2.tar.gz
ENV PATH $PATH:/opt/logstash-$VERSION/bin

# Cache variable can be set during building to invalidate the build cache with `--build-arg CACHE=$(date +%s) .`
ARG CACHE=1

# As all snapshot builds have the same url, the image is cached. The date at then can be used to invalidate the image
RUN set -x && \
    cd /opt && \
    wget -qO logstash.tar.gz $URL?${CACHE} && \
    tar xzf logstash.tar.gz


COPY logstash.conf.2.tmpl /logstash.conf.2.tmpl
COPY docker-entrypoint.sh /entrypoint.sh

COPY pki /etc/pki

ENTRYPOINT ["/entrypoint.sh"]

EXPOSE 5044 5055

CMD logstash -f /logstash.conf --log.level=debug --config.debug
