Skip to content

Commit 737fb64

Browse files
committed
Add alpine variant
Also, shrink the diff between "logstash" and "elasticsearch".
1 parent 2da4090 commit 737fb64

12 files changed

+224
-18
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ language: bash
22
services: docker
33

44
env:
5-
- VERSION=5
6-
- VERSION=2.4
7-
- VERSION=1.7
5+
- VERSION=5 VARIANT=
6+
- VERSION=5 VARIANT=alpine
7+
- VERSION=2.4 VARIANT=
8+
- VERSION=1.7 VARIANT=
89

910
install:
1011
- git clone https://github.com/docker-library/official-images.git ~/official-images

1.7/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RUN set -x \
2222
&& echo 'deb http://packages.elasticsearch.org/elasticsearch/1.7/debian stable main' > /etc/apt/sources.list.d/elasticsearch.list
2323

2424
ENV ELASTICSEARCH_VERSION 1.7.6
25+
ENV ELASTICSEARCH_DEB_VERSION 1.7.6
2526

2627
RUN set -x \
2728
\
@@ -30,7 +31,7 @@ RUN set -x \
3031
&& dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \
3132
\
3233
&& apt-get update \
33-
&& apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \
34+
&& apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \
3435
&& rm -rf /var/lib/apt/lists/*
3536

3637
ENV PATH /usr/share/elasticsearch/bin:$PATH

2.4/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RUN set -x \
2222
&& echo 'deb http://packages.elasticsearch.org/elasticsearch/2.x/debian stable main' > /etc/apt/sources.list.d/elasticsearch.list
2323

2424
ENV ELASTICSEARCH_VERSION 2.4.2
25+
ENV ELASTICSEARCH_DEB_VERSION 2.4.2
2526

2627
RUN set -x \
2728
\
@@ -30,7 +31,7 @@ RUN set -x \
3031
&& dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \
3132
\
3233
&& apt-get update \
33-
&& apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \
34+
&& apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \
3435
&& rm -rf /var/lib/apt/lists/*
3536

3637
ENV PATH /usr/share/elasticsearch/bin:$PATH

5/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RUN set -x \
2222
&& echo 'deb https://artifacts.elastic.co/packages/5.x/apt stable main' > /etc/apt/sources.list.d/elasticsearch.list
2323

2424
ENV ELASTICSEARCH_VERSION 5.1.1
25+
ENV ELASTICSEARCH_DEB_VERSION 5.1.1
2526

2627
RUN set -x \
2728
\
@@ -30,7 +31,7 @@ RUN set -x \
3031
&& dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \
3132
\
3233
&& apt-get update \
33-
&& apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \
34+
&& apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \
3435
&& rm -rf /var/lib/apt/lists/*
3536

3637
ENV PATH /usr/share/elasticsearch/bin:$PATH

5/alpine/Dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 5.1.1
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"]

5/alpine/config/elasticsearch.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
network.host: 0.0.0.0
2+
3+
# this value is required because we set "network.host"
4+
# be sure to modify it appropriately for a production cluster deployment
5+
discovery.zen.minimum_master_nodes: 1

5/alpine/config/log4j2.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
status = error
2+
3+
appender.console.type = Console
4+
appender.console.name = console
5+
appender.console.layout.type = PatternLayout
6+
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
7+
8+
rootLogger.level = info
9+
rootLogger.appenderRef.console.ref = console

5/alpine/docker-entrypoint.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Add elasticsearch as command if needed
6+
if [ "${1:0:1}" = '-' ]; then
7+
set -- elasticsearch "$@"
8+
fi
9+
10+
# Drop root privileges if we are running elasticsearch
11+
# allow the container to be started with `--user`
12+
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
13+
# Change the ownership of /usr/share/elasticsearch/data to elasticsearch
14+
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
15+
16+
set -- su-exec elasticsearch "$@"
17+
#exec su-exec elasticsearch "$BASH_SOURCE" "$@"
18+
fi
19+
20+
# As argument is not related to elasticsearch,
21+
# then assume that user wants to run his own process,
22+
# for example a `bash` shell to explore this image
23+
exec "$@"

Dockerfile-alpine.template

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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"]

Dockerfile.template renamed to Dockerfile-debian.template

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC85485
1919
# https://www.elastic.co/guide/en/elasticsearch/reference/5.0/deb.html
2020
RUN set -x \
2121
&& apt-get update && apt-get install -y --no-install-recommends apt-transport-https && rm -rf /var/lib/apt/lists/* \
22-
&& echo 'deb %%ELASTICSEARCH_REPO_BASE%% stable main' > /etc/apt/sources.list.d/elasticsearch.list
22+
&& echo 'deb %%ELASTICSEARCH_DEB_REPO%% stable main' > /etc/apt/sources.list.d/elasticsearch.list
2323

2424
ENV ELASTICSEARCH_VERSION %%ELASTICSEARCH_VERSION%%
25+
ENV ELASTICSEARCH_DEB_VERSION %%ELASTICSEARCH_DEB_VERSION%%
2526

2627
RUN set -x \
2728
\
@@ -30,7 +31,7 @@ RUN set -x \
3031
&& dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \
3132
\
3233
&& apt-get update \
33-
&& apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \
34+
&& apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \
3435
&& rm -rf /var/lib/apt/lists/*
3536

3637
ENV PATH /usr/share/elasticsearch/bin:$PATH

0 commit comments

Comments
 (0)