|
| 1 | +FROM maven:3.3.9-jdk-8 |
| 2 | + |
| 3 | +MAINTAINER B1nj0y <idegorepl@gmail.com> |
| 4 | + |
| 5 | +# grab gosu for easy step-down from root |
| 6 | +ENV GOSU_VERSION 1.7 |
| 7 | +RUN set -x \ |
| 8 | + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \ |
| 9 | + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \ |
| 10 | + && export GNUPGHOME="$(mktemp -d)" \ |
| 11 | + && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ |
| 12 | + && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ |
| 13 | + && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ |
| 14 | + && chmod +x /usr/local/bin/gosu \ |
| 15 | + && gosu nobody true |
| 16 | + |
| 17 | +RUN set -ex; \ |
| 18 | +# https://artifacts.elastic.co/GPG-KEY-elasticsearch |
| 19 | + key='46095ACC8548582C1A2699A9D27D666CD88E42B4'; \ |
| 20 | + export GNUPGHOME="$(mktemp -d)"; \ |
| 21 | + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ |
| 22 | + gpg --export "$key" > /etc/apt/trusted.gpg.d/elastic.gpg; \ |
| 23 | + rm -r "$GNUPGHOME"; \ |
| 24 | + apt-key list |
| 25 | + |
| 26 | +# https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html |
| 27 | +# https://www.elastic.co/guide/en/elasticsearch/reference/5.0/deb.html |
| 28 | +RUN set -x \ |
| 29 | + && apt-get update && apt-get install -y --no-install-recommends apt-transport-https && rm -rf /var/lib/apt/lists/* \ |
| 30 | + && echo 'deb https://artifacts.elastic.co/packages/5.x/apt stable main' > /etc/apt/sources.list.d/elasticsearch.list |
| 31 | + |
| 32 | +ENV ELASTICSEARCH_VERSION 5.3.0 |
| 33 | +ENV ELASTICSEARCH_DEB_VERSION 5.3.0 |
| 34 | + |
| 35 | +RUN set -x \ |
| 36 | + \ |
| 37 | +# don't allow the package to install its sysctl file (causes the install to fail) |
| 38 | +# Failed to write '262144' to '/proc/sys/vm/max_map_count': Read-only file system |
| 39 | + && dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \ |
| 40 | + \ |
| 41 | + && apt-get update \ |
| 42 | + && apt-get install -y git \ |
| 43 | + && apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \ |
| 44 | + && rm -rf /var/lib/apt/lists/* |
| 45 | + |
| 46 | +RUN set -x \ |
| 47 | + && cd /usr/share/elasticsearch \ |
| 48 | + && git clone https://github.com/medcl/elasticsearch-analysis-ik \ |
| 49 | + && cd elasticsearch-analysis-ik \ |
| 50 | + && mvn clean \ |
| 51 | + && mvn compile \ |
| 52 | + && mvn package \ |
| 53 | + && cd /usr/share/elasticsearch \ |
| 54 | + && unzip elasticsearch-analysis-ik/target/releases/elasticsearch-analysis-ik-5.3.0.zip -d plugins/ik \ |
| 55 | + && rm -rf elasticsearch-analysis-ik |
| 56 | + |
| 57 | +ENV PATH /usr/share/elasticsearch/bin:$PATH |
| 58 | + |
| 59 | +WORKDIR /usr/share/elasticsearch |
| 60 | + |
| 61 | +RUN set -ex \ |
| 62 | + && for path in \ |
| 63 | + ./data \ |
| 64 | + ./logs \ |
| 65 | + ./config \ |
| 66 | + ./config/scripts \ |
| 67 | + ; do \ |
| 68 | + mkdir -p "$path"; \ |
| 69 | + chown -R elasticsearch:elasticsearch "$path"; \ |
| 70 | + done |
| 71 | + |
| 72 | +COPY config ./config |
| 73 | + |
| 74 | +VOLUME /usr/share/elasticsearch/data |
| 75 | + |
| 76 | +COPY docker-entrypoint.sh / |
| 77 | + |
| 78 | +EXPOSE 9200 9300 |
| 79 | +ENTRYPOINT ["/docker-entrypoint.sh"] |
| 80 | +CMD ["elasticsearch"] |
0 commit comments