Dockerfile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # adapted from https://github.com/docker-library/elasticsearch/blob/master/2.4/Dockerfile
  2. FROM openjdk:8-jre
  3. # grab gosu for easy step-down from root
  4. ENV GOSU_VERSION 1.10
  5. RUN set -x \
  6. && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
  7. && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
  8. && export GNUPGHOME="$(mktemp -d)" \
  9. && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
  10. && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
  11. && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \
  12. && chmod +x /usr/local/bin/gosu \
  13. && gosu nobody true
  14. RUN set -ex; \
  15. # https://artifacts.elastic.co/GPG-KEY-elasticsearch
  16. key='46095ACC8548582C1A2699A9D27D666CD88E42B4'; \
  17. export GNUPGHOME="$(mktemp -d)"; \
  18. gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
  19. gpg --export "$key" > /etc/apt/trusted.gpg.d/elastic.gpg; \
  20. rm -rf "$GNUPGHOME"; \
  21. apt-key list
  22. # https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html
  23. # https://www.elastic.co/guide/en/elasticsearch/reference/5.0/deb.html
  24. RUN set -x \
  25. && apt-get update && apt-get install -y --no-install-recommends apt-transport-https && rm -rf /var/lib/apt/lists/* \
  26. && echo 'deb http://packages.elasticsearch.org/elasticsearch/2.x/debian stable main' > /etc/apt/sources.list.d/elasticsearch.list
  27. ENV ELASTICSEARCH_VERSION 2.4.6
  28. ENV ELASTICSEARCH_DEB_VERSION 2.4.6
  29. RUN set -x \
  30. \
  31. # don't allow the package to install its sysctl file (causes the install to fail)
  32. # Failed to write '262144' to '/proc/sys/vm/max_map_count': Read-only file system
  33. && dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \
  34. \
  35. && apt-get update \
  36. && apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \
  37. && rm -rf /var/lib/apt/lists/*
  38. ENV PATH /usr/share/elasticsearch/bin:$PATH
  39. WORKDIR /usr/share/elasticsearch
  40. # uid 11002 because 1000 (elasticsearch) conflicts in our infra
  41. RUN addgroup --gid 11002 elasticsearch-user
  42. RUN useradd --uid 11002 --gid 11002 --home /usr/share/elasticsearch elasticsearch-user
  43. RUN set -ex \
  44. && for path in \
  45. ./data \
  46. ./logs \
  47. ./config \
  48. ./config/scripts \
  49. ; do \
  50. mkdir -p "$path"; \
  51. chown -R elasticsearch-user:elasticsearch-user "$path"; \
  52. done
  53. RUN yes | bin/plugin install cloud-aws
  54. VOLUME /usr/share/elasticsearch/data
  55. COPY ./docker/elasticsearch/docker-entrypoint.sh /
  56. EXPOSE 9200 9300
  57. ENTRYPOINT ["/docker-entrypoint.sh"]
  58. CMD ["elasticsearch"]