Skip to content

Commit fb58f76

Browse files
committed
Switch a few bits for cross-variant consistency
1 parent 8f1daed commit fb58f76

34 files changed

+822
-266
lines changed

.travis.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@ language: bash
22
services: docker
33

44
env:
5-
- VERSION=5.0
6-
- VERSION=5.0/alpine
7-
- VERSION=2.4
8-
- VERSION=2.3
9-
- VERSION=2.3/alpine
10-
- VERSION=2.2
11-
- VERSION=2.2/alpine
12-
- VERSION=2.1
13-
- VERSION=2.1/alpine
14-
- VERSION=2.0
15-
- VERSION=2.0/alpine
16-
- VERSION=1.5
17-
- VERSION=1.5/alpine
5+
- VERSION=5.0 VARIANT=
6+
- VERSION=5.0 VARIANT=alpine
7+
- VERSION=2.4 VARIANT=
8+
- VERSION=2.4 VARIANT=alpine
9+
- VERSION=2.3 VARIANT=
10+
- VERSION=2.3 VARIANT=alpine
11+
- VERSION=2.2 VARIANT=
12+
- VERSION=2.2 VARIANT=alpine
13+
- VERSION=2.1 VARIANT=
14+
- VERSION=2.1 VARIANT=alpine
15+
- VERSION=2.0 VARIANT=
16+
- VERSION=2.0 VARIANT=alpine
17+
- VERSION=1.5 VARIANT=
18+
- VERSION=1.5 VARIANT=alpine
1819

1920
install:
2021
- git clone https://github.com/docker-library/official-images.git ~/official-images
2122

2223
before_script:
2324
- env | sort
2425
- cd "$VERSION"
25-
- image="logstash:$VERSION"
26+
- image="logstash:${VERSION}${VARIANT:+-$VARIANT}"
2627

2728
script:
28-
- docker build -t "$image" .
29+
- docker build -t "$image" "${VARIANT:-.}"
2930
- ~/official-images/test/run.sh "$image"
3031

3132
after_script:

1.5/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC85485
2828

2929
RUN echo 'deb http://packages.elastic.co/logstash/1.5/debian stable main' > /etc/apt/sources.list.d/logstash.list
3030

31-
ENV LOGSTASH_VERSION 1:1.5.6-1
31+
ENV LOGSTASH_VERSION 1.5.6
32+
ENV LOGSTASH_DEB_VERSION 1:1.5.6-1
3233

3334
RUN set -x \
3435
&& apt-get update \
35-
&& apt-get install -y --no-install-recommends logstash=$LOGSTASH_VERSION \
36+
&& apt-get install -y --no-install-recommends "logstash=$LOGSTASH_DEB_VERSION" \
3637
&& rm -rf /var/lib/apt/lists/*
3738

3839
ENV PATH /opt/logstash/bin:$PATH

1.5/alpine/Dockerfile

Lines changed: 74 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,85 @@
1-
FROM alpine:3.4
1+
FROM openjdk:8-jre-alpine
22

3+
# ensure logstash user exists
34
RUN addgroup -S logstash && adduser -S -G logstash logstash
45

5-
RUN echo '@testing http://nl.alpinelinux.org/alpine/edge/testing' >> '/etc/apk/repositories'
6+
# install plugin dependencies
7+
RUN apk add --no-cache \
8+
# env: can't execute 'bash': No such file or directory
9+
bash \
10+
libzmq
611

7-
RUN apk update
8-
RUN apk add --no-cache ca-certificates curl openjdk8 gosu@testing libzmq
12+
# grab su-exec for easy step-down from root
13+
RUN apk add --no-cache 'su-exec>=0.2'
914

10-
# the "ffi-rzmq-core" gem is very picky about where it looks for libzmq.so
11-
RUN mkdir -p /usr/local/lib \
12-
&& ln -s /usr/lib/*/libzmq.so.3 /usr/local/lib/libzmq.so
15+
# https://www.elastic.co/guide/en/logstash/5.0/installing-logstash.html#_apt
16+
# https://artifacts.elastic.co/GPG-KEY-elasticsearch
17+
ENV GPG_KEY 46095ACC8548582C1A2699A9D27D666CD88E42B4
18+
19+
ENV LOGSTASH_PATH /opt/logstash/bin
20+
ENV PATH $LOGSTASH_PATH:$PATH
1321

14-
ENV LOGSTASH_MAJOR 1.5
1522
ENV LOGSTASH_VERSION 1.5.6
16-
ENV LOGSTASH_TAR_SHA1 f3e4342f496e0d7e709de231daf624eb1fd80873
17-
18-
RUN \
19-
adduser -D -S elasticsearch
20-
RUN \
21-
mkdir -p /opt && \
22-
cd /tmp && \
23-
curl -L https://download.elastic.co/logstash/logstash/logstash-$LOGSTASH_VERSION.tar.gz > logstash-$LOGSTASH_VERSION.tar.gz && \
24-
echo "$LOGSTASH_TAR_SHA1 logstash-$LOGSTASH_VERSION.tar.gz" | sha1sum -c - && \
25-
tar -xzf logstash-$LOGSTASH_VERSION.tar.gz && \
26-
rm -rf logstash-$LOGSTASH_VERSION.tar.gz && \
27-
mv logstash-$LOGSTASH_VERSION /opt/logstash && \
28-
ln -s /opt/logstash/bin/logstash /usr/local/bin/logstash
23+
ENV LOGSTASH_TARBALL="https://download.elastic.co/logstash/logstash/logstash-1.5.6.tar.gz" \
24+
LOGSTASH_TARBALL_ASC="" \
25+
LOGSTASH_TARBALL_SHA1="f3e4342f496e0d7e709de231daf624eb1fd80873"
26+
27+
RUN set -ex; \
28+
\
29+
if [ -z "$LOGSTASH_TARBALL_SHA1" ] && [ -z "$LOGSTASH_TARBALL_ASC" ]; then \
30+
echo >&2 'error: have neither a SHA1 _or_ a signature file -- cannot verify download!'; \
31+
exit 1; \
32+
fi; \
33+
\
34+
apk add --no-cache --virtual .fetch-deps \
35+
ca-certificates \
36+
gnupg \
37+
openssl \
38+
tar \
39+
; \
40+
\
41+
wget -O logstash.tar.gz "$LOGSTASH_TARBALL"; \
42+
\
43+
if [ "$LOGSTASH_TARBALL_SHA1" ]; then \
44+
echo "$LOGSTASH_TARBALL_SHA1 *logstash.tar.gz" | sha1sum -c -; \
45+
fi; \
46+
\
47+
if [ "$LOGSTASH_TARBALL_ASC" ]; then \
48+
wget -O logstash.tar.gz.asc "$LOGSTASH_TARBALL_ASC"; \
49+
export GNUPGHOME="$(mktemp -d)"; \
50+
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY"; \
51+
gpg --batch --verify logstash.tar.gz.asc logstash.tar.gz; \
52+
rm -r "$GNUPGHOME" logstash.tar.gz.asc; \
53+
fi; \
54+
\
55+
dir="$(dirname "$LOGSTASH_PATH")"; \
56+
\
57+
mkdir -p "$dir"; \
58+
tar -xf logstash.tar.gz --strip-components=1 -C "$dir"; \
59+
rm logstash.tar.gz; \
60+
\
61+
apk del .fetch-deps; \
62+
\
63+
export LS_SETTINGS_DIR="$dir/config"; \
64+
# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console"
65+
if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \
66+
cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \
67+
truncate -s 0 "$LS_SETTINGS_DIR/log4j2.properties"; \
68+
fi; \
69+
\
70+
# set up some file permissions
71+
for userDir in \
72+
"$dir/config" \
73+
"$dir/data" \
74+
; do \
75+
if [ -d "$userDir" ]; then \
76+
chown -R logstash:logstash "$userDir"; \
77+
fi; \
78+
done; \
79+
\
80+
logstash --version
2981

3082
COPY docker-entrypoint.sh /
3183

3284
ENTRYPOINT ["/docker-entrypoint.sh"]
33-
CMD ["logstash", "agent"]
85+
CMD ["-e", ""]

1.5/alpine/docker-entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#!/bin/sh
2-
1+
#!/bin/bash
32
set -e
43

5-
# Add logstash as command if needed
6-
if [ "${1:0:1}" = '-' ]; then
4+
# first arg is `-f` or `--some-option`
5+
if [ "${1#-}" != "$1" ]; then
76
set -- logstash "$@"
87
fi
98

109
# Run as user "logstash" if the command is "logstash"
11-
if [ "$1" = 'logstash' ]; then
12-
set -- gosu logstash "$@"
10+
# allow the container to be started with `--user`
11+
if [ "$1" = 'logstash' -a "$(id -u)" = '0' ]; then
12+
set -- su-exec logstash "$@"
1313
fi
1414

1515
exec "$@"

1.5/docker-entrypoint.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/bin/bash
2-
32
set -e
43

5-
# Add logstash as command if needed
6-
if [ "${1:0:1}" = '-' ]; then
4+
# first arg is `-f` or `--some-option`
5+
if [ "${1#-}" != "$1" ]; then
76
set -- logstash "$@"
87
fi
98

2.0/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC85485
2828

2929
RUN echo 'deb http://packages.elastic.co/logstash/2.0/debian stable main' > /etc/apt/sources.list.d/logstash.list
3030

31-
ENV LOGSTASH_VERSION 1:2.0.0-1
31+
ENV LOGSTASH_VERSION 2.0.0
32+
ENV LOGSTASH_DEB_VERSION 1:2.0.0-1
3233

3334
RUN set -x \
3435
&& apt-get update \
35-
&& apt-get install -y --no-install-recommends logstash=$LOGSTASH_VERSION \
36+
&& apt-get install -y --no-install-recommends "logstash=$LOGSTASH_DEB_VERSION" \
3637
&& rm -rf /var/lib/apt/lists/*
3738

3839
ENV PATH /opt/logstash/bin:$PATH

2.0/alpine/Dockerfile

Lines changed: 74 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,85 @@
1-
FROM alpine:3.4
1+
FROM openjdk:8-jre-alpine
22

3+
# ensure logstash user exists
34
RUN addgroup -S logstash && adduser -S -G logstash logstash
45

5-
RUN echo '@testing http://nl.alpinelinux.org/alpine/edge/testing' >> '/etc/apk/repositories'
6+
# install plugin dependencies
7+
RUN apk add --no-cache \
8+
# env: can't execute 'bash': No such file or directory
9+
bash \
10+
libzmq
611

7-
RUN apk update
8-
RUN apk add --no-cache ca-certificates curl openjdk8 gosu@testing libzmq
12+
# grab su-exec for easy step-down from root
13+
RUN apk add --no-cache 'su-exec>=0.2'
914

10-
# the "ffi-rzmq-core" gem is very picky about where it looks for libzmq.so
11-
RUN mkdir -p /usr/local/lib \
12-
&& ln -s /usr/lib/*/libzmq.so.3 /usr/local/lib/libzmq.so
15+
# https://www.elastic.co/guide/en/logstash/5.0/installing-logstash.html#_apt
16+
# https://artifacts.elastic.co/GPG-KEY-elasticsearch
17+
ENV GPG_KEY 46095ACC8548582C1A2699A9D27D666CD88E42B4
1318

14-
ENV LOGSTASH_MAJOR 2.0
15-
ENV LOGSTASH_VERSION 2.0.0-rc1
16-
ENV LOGSTASH_TAR_SHA1 5d3a311d83dfba7e37c1bb48879fbcc59690f7cd
19+
ENV LOGSTASH_PATH /opt/logstash/bin
20+
ENV PATH $LOGSTASH_PATH:$PATH
1721

18-
RUN \
19-
adduser -D -S elasticsearch
20-
RUN \
21-
mkdir -p /opt && \
22-
cd /tmp && \
23-
curl -L https://download.elastic.co/logstash/logstash/logstash-$LOGSTASH_VERSION.tar.gz > logstash-$LOGSTASH_VERSION.tar.gz && \
24-
echo "$LOGSTASH_TAR_SHA1 logstash-$LOGSTASH_VERSION.tar.gz" | sha1sum -c - && \
25-
tar -xzf logstash-$LOGSTASH_VERSION.tar.gz && \
26-
rm -rf logstash-$LOGSTASH_VERSION.tar.gz && \
27-
mv logstash-$LOGSTASH_VERSION /opt/logstash && \
28-
ln -s /opt/logstash/bin/logstash /usr/local/bin/logstash
22+
ENV LOGSTASH_VERSION 2.0.0
23+
ENV LOGSTASH_TARBALL="https://download.elastic.co/logstash/logstash/logstash-2.0.0.tar.gz" \
24+
LOGSTASH_TARBALL_ASC="" \
25+
LOGSTASH_TARBALL_SHA1="f0961520dd9590d3b600c877be66f79f94a05f80"
26+
27+
RUN set -ex; \
28+
\
29+
if [ -z "$LOGSTASH_TARBALL_SHA1" ] && [ -z "$LOGSTASH_TARBALL_ASC" ]; then \
30+
echo >&2 'error: have neither a SHA1 _or_ a signature file -- cannot verify download!'; \
31+
exit 1; \
32+
fi; \
33+
\
34+
apk add --no-cache --virtual .fetch-deps \
35+
ca-certificates \
36+
gnupg \
37+
openssl \
38+
tar \
39+
; \
40+
\
41+
wget -O logstash.tar.gz "$LOGSTASH_TARBALL"; \
42+
\
43+
if [ "$LOGSTASH_TARBALL_SHA1" ]; then \
44+
echo "$LOGSTASH_TARBALL_SHA1 *logstash.tar.gz" | sha1sum -c -; \
45+
fi; \
46+
\
47+
if [ "$LOGSTASH_TARBALL_ASC" ]; then \
48+
wget -O logstash.tar.gz.asc "$LOGSTASH_TARBALL_ASC"; \
49+
export GNUPGHOME="$(mktemp -d)"; \
50+
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY"; \
51+
gpg --batch --verify logstash.tar.gz.asc logstash.tar.gz; \
52+
rm -r "$GNUPGHOME" logstash.tar.gz.asc; \
53+
fi; \
54+
\
55+
dir="$(dirname "$LOGSTASH_PATH")"; \
56+
\
57+
mkdir -p "$dir"; \
58+
tar -xf logstash.tar.gz --strip-components=1 -C "$dir"; \
59+
rm logstash.tar.gz; \
60+
\
61+
apk del .fetch-deps; \
62+
\
63+
export LS_SETTINGS_DIR="$dir/config"; \
64+
# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console"
65+
if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \
66+
cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \
67+
truncate -s 0 "$LS_SETTINGS_DIR/log4j2.properties"; \
68+
fi; \
69+
\
70+
# set up some file permissions
71+
for userDir in \
72+
"$dir/config" \
73+
"$dir/data" \
74+
; do \
75+
if [ -d "$userDir" ]; then \
76+
chown -R logstash:logstash "$userDir"; \
77+
fi; \
78+
done; \
79+
\
80+
logstash --version
2981

3082
COPY docker-entrypoint.sh /
3183

3284
ENTRYPOINT ["/docker-entrypoint.sh"]
33-
CMD ["logstash", "agent"]
85+
CMD ["-e", ""]

2.0/alpine/docker-entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#!/bin/sh
2-
1+
#!/bin/bash
32
set -e
43

5-
# Add logstash as command if needed
6-
if [ "${1:0:1}" = '-' ]; then
4+
# first arg is `-f` or `--some-option`
5+
if [ "${1#-}" != "$1" ]; then
76
set -- logstash "$@"
87
fi
98

109
# Run as user "logstash" if the command is "logstash"
11-
if [ "$1" = 'logstash' ]; then
12-
set -- gosu logstash "$@"
10+
# allow the container to be started with `--user`
11+
if [ "$1" = 'logstash' -a "$(id -u)" = '0' ]; then
12+
set -- su-exec logstash "$@"
1313
fi
1414

1515
exec "$@"

2.0/docker-entrypoint.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/bin/bash
2-
32
set -e
43

5-
# Add logstash as command if needed
6-
if [ "${1:0:1}" = '-' ]; then
4+
# first arg is `-f` or `--some-option`
5+
if [ "${1#-}" != "$1" ]; then
76
set -- logstash "$@"
87
fi
98

2.1/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC85485
2828

2929
RUN echo 'deb http://packages.elastic.co/logstash/2.1/debian stable main' > /etc/apt/sources.list.d/logstash.list
3030

31-
ENV LOGSTASH_VERSION 1:2.1.3-1
31+
ENV LOGSTASH_VERSION 2.1.3
32+
ENV LOGSTASH_DEB_VERSION 1:2.1.3-1
3233

3334
RUN set -x \
3435
&& apt-get update \
35-
&& apt-get install -y --no-install-recommends logstash=$LOGSTASH_VERSION \
36+
&& apt-get install -y --no-install-recommends "logstash=$LOGSTASH_DEB_VERSION" \
3637
&& rm -rf /var/lib/apt/lists/*
3738

3839
ENV PATH /opt/logstash/bin:$PATH

0 commit comments

Comments
 (0)