From 97a8982089531ed2e4a3f957575f923dcf9366a9 Mon Sep 17 00:00:00 2001 From: Wang Yun Tao Date: Sun, 1 Nov 2015 15:32:15 +0800 Subject: [PATCH 1/3] add docker build file --- .dockerignore | 2 ++ Dockerfile | 26 ++++++++++++++++++++++++++ bin/docker-entrypoint.sh | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 bin/docker-entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3ec1231 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Dockerfile +.* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dbee4ef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM java:7-jre +ENV ES_HOME=/usr/share/elasticsearch-rtf +ENV PATH $ES_HOME/bin:$PATH + +# RUN git clone -b 1.7.1 git://github.com/medcl/elasticsearch-rtf.git $ES_HOME +COPY . $ES_HOME + +RUN $ES_HOME/bin/plugin -install mobz/elasticsearch-head + +# ES_MAX_MEM, ES_MIN_MEM or ES_HEAP_SIZE only (max = min) +# RUN git clone https://github.com/elastic/elasticsearch-servicewrapper /usr/share/elasticsearch-servicewrapper +# RUN cp -r /user/share/elasticsearch-servicewrapper/service $ES_HOME/bin/ +# RUN /user/share/elasticsearch-servicewrapper/elasticsearch64 install +# RUN service elasticsearch start + +RUN mkdir -p $ES_HOME/data + +VOLUME /usr/share/elasticsearch-rtf/data + +COPY bin/docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 9200 9300 + +CMD ["elasticsearch"] diff --git a/bin/docker-entrypoint.sh b/bin/docker-entrypoint.sh new file mode 100755 index 0000000..0910fcb --- /dev/null +++ b/bin/docker-entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +# Add elasticsearch as command if it is needed +if [ "${1:0:1}" = '-' ]; then + set -- elasticsearch "$@" +fi + +# Drop root privileges if we are running elasticsearch +#if [ "$1" = 'elasticsearch' ]; then + # Change the ownership of /usr/share/elasticsearch/data to elasticsearch +# chown -R elasticsearch:elasticsearch /usr/share/elasticsearch-rtf/data +# exec gosu elasticsearch "$@" +#fi + +# As argument is not related to elasticsearch, +# then assume that user wants to run his own process, +# for example a `bash` shell to explore this image +exec "$@" From f8044bcf28ebf8fc5151a66ec3be34a6eacda8f6 Mon Sep 17 00:00:00 2001 From: tntest Date: Mon, 9 Nov 2015 12:02:59 +0800 Subject: [PATCH 2/3] add river-csv plugin --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index dbee4ef..8f65ea5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,8 @@ COPY . $ES_HOME RUN $ES_HOME/bin/plugin -install mobz/elasticsearch-head +RUN $ES_HOME/bin/plugin -install river-csv -url https://github.com/AgileWorksOrg/elasticsearch-river-csv/releases/download/2.2.1/elasticsearch-river-csv-2.2.1.zip + # ES_MAX_MEM, ES_MIN_MEM or ES_HEAP_SIZE only (max = min) # RUN git clone https://github.com/elastic/elasticsearch-servicewrapper /usr/share/elasticsearch-servicewrapper # RUN cp -r /user/share/elasticsearch-servicewrapper/service $ES_HOME/bin/ @@ -14,10 +16,12 @@ RUN $ES_HOME/bin/plugin -install mobz/elasticsearch-head # RUN service elasticsearch start RUN mkdir -p $ES_HOME/data +RUN mkdir -p $ES_HOME/data-csv + +# VOLUME /usr/share/elasticsearch-rtf/data -VOLUME /usr/share/elasticsearch-rtf/data +VOLUME ["/usr/share/elasticsearch-rtf/data", "/usr/share/elasticsearch-rtf/data-csv"] -COPY bin/docker-entrypoint.sh / ENTRYPOINT ["/docker-entrypoint.sh"] From f562dd1f4ef13d8d66fb9e3d988e0fe7e5a06dfd Mon Sep 17 00:00:00 2001 From: tntest Date: Tue, 10 Nov 2015 15:00:50 +0800 Subject: [PATCH 3/3] fix bug: docker-entrypoint.sh path problem. and add cors support --- Dockerfile | 1 + config/elasticsearch.yml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8f65ea5..782688e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ ENV PATH $ES_HOME/bin:$PATH # RUN git clone -b 1.7.1 git://github.com/medcl/elasticsearch-rtf.git $ES_HOME COPY . $ES_HOME +COPY bin/docker-entrypoint.sh / RUN $ES_HOME/bin/plugin -install mobz/elasticsearch-head diff --git a/config/elasticsearch.yml b/config/elasticsearch.yml index a3bfd63..47a9da5 100755 --- a/config/elasticsearch.yml +++ b/config/elasticsearch.yml @@ -434,3 +434,7 @@ index: tokenizer: mmseg_complex index.analysis.analyzer.default.type : "org.elasticsearch.index.analysis.MMsegAnalyzerProvider" script.groovy.sandbox.enabled: true +http.cors.enabled : true +http.cors.allow-origin: "/.*/" +http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE +http.cors.allow-headers : "X-Requested-With,X-Auth-Token,Content-Type, Content-Length, Authorization"