Public Repository

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description

Test

docker run  -p 15672:15672 -p 9200:9200 --name logstash_test kiryam/logstash_err

# wait for start elastic
docker exec logstash_test curl -XGET http://localhost:9200


docker exec logstash_test /test.sh
docker exec logstash_test curl -XGET http://localhost:9200/logstash/_search?pretty

Build

docker build -t kiryam/logstash_err .

Dockerfile

FROM debian
MAINTAINER Kirill Ivannikov <kiryam@kiryam.ru>
RUN apt-get update && apt-get install -y wget
RUN wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" >> /etc/apt/sources.list
RUN echo "deb http://packages.elastic.co/logstash/2.2/debian stable main" | tee -a /etc/apt/sources.list
RUN echo "deb http://www.rabbitmq.com/debian/ testing main" >> /etc/apt/sources.list
RUN wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc && apt-key add rabbitmq-signing-key-public.asc

RUN apt-get update && apt-get install -y  --force-yes sudo supervisor openjdk-7-jre nano curl elasticsearch rabbitmq-server logstash

RUN echo "network.host: 0.0.0.0" >> /etc/elasticsearch/elasticsearch.yml
RUN echo '[{rabbit, [{default_user, <<"docker_user">>},{default_pass, <<"docker_password">>},{tcp_listeners, [{"0.0.0.0", 5672}]}]}].' > /etc/rabbitmq/rabbitmq.config
RUN rabbitmq-plugins enable rabbitmq_management

RUN echo "[program:elasticsearch]\ncommand=sudo -u elasticsearch /usr/share/elasticsearch/bin/elasticsearch --default.path.logs=/var/log/elasticsearch --default.path.data=/var/lib/elasticsearch  --default.path.conf=/etc/elasticsearch" > /etc/supervisor/conf.d/elasticsearch.conf
RUN echo "[program:rabbitmq]\ncommand=rabbitmq-server\nautorestart=true\npriority=1" > /etc/supervisor/conf.d/rabbitmq.conf
RUN echo "[program:logstash]\ncommand=/opt/logstash/bin/logstash -f /etc/elasticsearch.conf" > /etc/supervisor/conf.d/logstash.conf

RUN echo "input { rabbitmq {host => \"localhost\" user=>\"docker_user\" password=>\"docker_password\" queue=> \"logstash\" codec=> es_bulk } }" >> /etc/elasticsearch.conf
RUN echo "output {elasticsearch {index => \"logstash\" document_id => \"%{[@metadata][_id]}\"} }" >> /etc/elasticsearch.conf

RUN echo "#!/bin/sh" >> /test.sh
RUN echo "curl -i -u docker_user:docker_password -H \"content-type:application/json\" -XPUT http://localhost:15672/api/exchanges/%2f/logstash -d '{\"type\":\"direct\",\"durable\":true}'" >> /test.sh
RUN echo "curl -i -u docker_user:docker_password -H \"content-type:application/json\" -XPUT http://localhost:15672/api/queues/%2f/logstash -d '{\"auto_delete\":false, \"durable\":true }'" >> /test.sh
RUN echo "curl -i -u docker_user:docker_password -H \"content-type:application/json\" -XPOST http://localhost:15672/api/bindings/%2f/e/logstash/q/logstash -d '{\"routing_key\":\"logstash\",\"arguments\":[]}'" >> /test.sh
RUN echo "curl -i -u docker_user:docker_password -H \"content-type:application/json\" -XPOST http://localhost:15672/api/exchanges/%2f/logstash/publish -d '{\"properties\":{},\"routing_key\":\"logstash\",\"payload_encoding\":\"string\", \"payload\": \"{ \\\"index\\\" : { \\\"_index\\\" : \\\"test\\\", \\\"_type\\\" : \\\"type1\\\", \\\"_id\\\" : \\\"1\\\" } }\\r\\n{ \\\"field1\\\" : \\\"value1\\\" }\\r\\n{ \\\"update\\\" : {\\\"_id\\\" : \\\"1\\\", \\\"_type\\\" : \\\"type1\\\", \\\"_index\\\" : \\\"test\\\"} }\\r\\n{ \\\"doc\\\" : {\\\"field1\\\" : \\\"value2\\\"}}\\r\\n\"}'" >> /test.sh
RUN chmod +x /test.sh


CMD ["/usr/bin/supervisord", "--nodaemon"]
EXPOSE 9200
EXPOSE 15672
Docker Pull Command
Owner
kiryam

Comments (0)