|
| 1 | +FROM openjdk:8-jre-alpine |
| 2 | + |
| 3 | +# ensure elasticsearch user exists |
| 4 | +RUN addgroup -S elasticsearch && adduser -S -G elasticsearch elasticsearch |
| 5 | + |
| 6 | +# grab su-exec for easy step-down from root |
| 7 | +# and bash for "bin/elasticsearch" among others |
| 8 | +RUN apk add --no-cache 'su-exec>=0.2' bash |
| 9 | + |
| 10 | +# https://artifacts.elastic.co/GPG-KEY-elasticsearch |
| 11 | +ENV GPG_KEY 46095ACC8548582C1A2699A9D27D666CD88E42B4 |
| 12 | + |
| 13 | +ENV ELASTICSEARCH_VERSION %%ELASTICSEARCH_VERSION%% |
| 14 | + |
| 15 | +ENV PATH /usr/share/elasticsearch/bin:$PATH |
| 16 | +WORKDIR /usr/share/elasticsearch |
| 17 | + |
| 18 | +RUN set -ex; \ |
| 19 | + \ |
| 20 | + apk add --no-cache --virtual .fetch-deps \ |
| 21 | + ca-certificates \ |
| 22 | + gnupg \ |
| 23 | + openssl \ |
| 24 | + tar \ |
| 25 | + ; \ |
| 26 | + \ |
| 27 | + wget -O elasticsearch.tar.gz "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz"; \ |
| 28 | + \ |
| 29 | + wget -O elasticsearch.tar.gz.asc "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz.asc"; \ |
| 30 | + export GNUPGHOME="$(mktemp -d)"; \ |
| 31 | + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY"; \ |
| 32 | + gpg --batch --verify elasticsearch.tar.gz.asc elasticsearch.tar.gz; \ |
| 33 | + rm -r "$GNUPGHOME" elasticsearch.tar.gz.asc; \ |
| 34 | + \ |
| 35 | + tar -xf elasticsearch.tar.gz --strip-components=1; \ |
| 36 | + rm elasticsearch.tar.gz; \ |
| 37 | + \ |
| 38 | + apk del .fetch-deps; \ |
| 39 | + \ |
| 40 | + for path in \ |
| 41 | + ./data \ |
| 42 | + ./logs \ |
| 43 | + ./config \ |
| 44 | + ./config/scripts \ |
| 45 | + ; do \ |
| 46 | + mkdir -p "$path"; \ |
| 47 | + chown -R elasticsearch:elasticsearch "$path"; \ |
| 48 | + done; \ |
| 49 | + \ |
| 50 | + elasticsearch --version |
| 51 | + |
| 52 | +COPY config ./config |
| 53 | + |
| 54 | +VOLUME /usr/share/elasticsearch/data |
| 55 | + |
| 56 | +COPY docker-entrypoint.sh / |
| 57 | + |
| 58 | +EXPOSE 9200 9300 |
| 59 | +ENTRYPOINT ["/docker-entrypoint.sh"] |
| 60 | +CMD ["elasticsearch"] |
0 commit comments