Skip to content

Modify to support multiple major versions of logstash #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: bash

# for secret experimental features ;)
sudo: 9000

env:
- VERSION=1.5
- VERSION=1.4

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

before_script:
- env | sort
- cd "$VERSION"
- image="logstash:$VERSION"

script:
- docker build -t "$image" .
- ~/official-images/test/run.sh "$image"

after_script:
- docker images

# vim:set et ts=2 sw=2:
32 changes: 32 additions & 0 deletions 1.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM java:8-jre

# grab gosu for easy step-down from root
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
RUN arch="$(dpkg --print-architecture)" \
&& set -x \
&& curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.3/gosu-$arch" \
&& curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.3/gosu-$arch.asc" \
&& gpg --verify /usr/local/bin/gosu.asc \
&& rm /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu

# http://www.logstash.net/docs/1.4.2/repositories
# http://packages.elasticsearch.org/GPG-KEY-elasticsearch
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC8548582C1A2699A9D27D666CD88E42B4

ENV LOGSTASH_MAJOR 1.4
ENV LOGSTASH_VERSION 1.4.4-1-5608c19

RUN echo "deb http://packages.elasticsearch.org/logstash/${LOGSTASH_MAJOR}/debian stable main" > /etc/apt/sources.list.d/logstash.list

RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends logstash=$LOGSTASH_VERSION \
&& rm -rf /var/lib/apt/lists/*

ENV PATH /opt/logstash/bin:$PATH

COPY docker-entrypoint.sh /

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["logstash", "agent"]
15 changes: 15 additions & 0 deletions 1.4/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

# Add logstash as command if needed
if [ "${1:0:1}" = '-' ]; then
set -- logstash "$@"
fi

# Run as user "logstash" if the command is "logstash"
if [ "$1" = 'logstash' ]; then
set -- gosu logstash "$@"
fi

exec "$@"
4 changes: 2 additions & 2 deletions Dockerfile → 1.5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN set -x \

ENV PATH /opt/logstash/bin:$PATH

COPY ./docker-entrypoint.sh /
COPY docker-entrypoint.sh /

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["logstash"]
CMD ["logstash", "agent"]
15 changes: 15 additions & 0 deletions 1.5/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

# Add logstash as command if needed
if [ "${1:0:1}" = '-' ]; then
set -- logstash "$@"
fi

# Run as user "logstash" if the command is "logstash"
if [ "$1" = 'logstash' ]; then
set -- gosu logstash "$@"
fi

exec "$@"
32 changes: 32 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM java:8-jre

# grab gosu for easy step-down from root
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
RUN arch="$(dpkg --print-architecture)" \
&& set -x \
&& curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.3/gosu-$arch" \
&& curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.3/gosu-$arch.asc" \
&& gpg --verify /usr/local/bin/gosu.asc \
&& rm /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu

# http://www.logstash.net/docs/1.4.2/repositories
# http://packages.elasticsearch.org/GPG-KEY-elasticsearch
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC8548582C1A2699A9D27D666CD88E42B4

ENV LOGSTASH_MAJOR %%LOGSTASH_MAJOR%%
ENV LOGSTASH_VERSION %%LOGSTASH_VERSION%%

RUN echo "deb http://packages.elasticsearch.org/logstash/${LOGSTASH_MAJOR}/debian stable main" > /etc/apt/sources.list.d/logstash.list

RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends logstash=$LOGSTASH_VERSION \
&& rm -rf /var/lib/apt/lists/*

ENV PATH /opt/logstash/bin:$PATH

COPY docker-entrypoint.sh /

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["logstash", "agent"]
4 changes: 2 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
set -e

# Add logstash as command if needed
if [[ "$1" == -* ]]; then
if [ "${1:0:1}" = '-' ]; then
set -- logstash "$@"
fi

# Run as user "logstash" if the command is "logstash"
if [ "$1" == logstash ]; then
if [ "$1" = 'logstash' ]; then
set -- gosu logstash "$@"
fi

Expand Down
35 changes: 25 additions & 10 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
#!/bin/bash
set -e

declare -A aliases
aliases=(
[1.5]='1 latest'
)

cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

versions=( */ )
versions=( "${versions[@]%/}" )
url='git://github.com/docker-library/logstash'
commit="$(git log -1 --format='format:%H' -- Dockerfile $(awk 'toupper($1) == "COPY" { for (i = 2; i < NF; i++) { print $i } }' Dockerfile))"
debVersion="$(grep -m1 'ENV LOGSTASH_VERSION' Dockerfile | cut -d' ' -f3)"
fullVersion="${debVersion%%[-]*}" # strip "debian version"
fullVersion="${fullVersion##*:}" # strip epoch
version="${fullVersion%[.]*}"

echo '# maintainer: InfoSiftr <[email protected]> (@infosiftr)'
echo
#echo "$debVersion: ${url}@${commit}"
echo "$fullVersion: ${url}@${commit}"
echo "$version: ${url}@${commit}"
echo "latest: ${url}@${commit}"

for version in "${versions[@]}"; do
commit="$(cd "$version" && git log -1 --format='format:%H' -- Dockerfile $(awk 'toupper($1) == "COPY" { for (i = 2; i < NF; i++) { print $i } }' Dockerfile))"
fullVersion="$(grep -m1 'ENV LOGSTASH_VERSION' "$version/Dockerfile" | cut -d' ' -f3)"
fullVersion="${fullVersion#*:}" # cut off the Debian epoch

versionAliases=()
while [ "$fullVersion" != "$version" -a "${fullVersion%[.-]*}" != "$fullVersion" ]; do
versionAliases+=( $fullVersion )
fullVersion="${fullVersion%[.-]*}"
done
versionAliases+=( $version ${aliases[$version]} )

echo
for va in "${versionAliases[@]}"; do
echo "$va: ${url}@${commit} $version"
done
done
31 changes: 26 additions & 5 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,31 @@ set -e

cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

version='1.5'
fullVersion="$(curl -sSL "http://packages.elasticsearch.org/logstash/$version/debian/dists/stable/main/binary-amd64/Packages.gz" | gunzip | awk -F ': +' '$1 == "Package" { pkg = $2 } pkg == "logstash" && $1 == "Version" { print $2 }' | sort -V | tail -1)"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )

sed -ri \
-e 's/^(ENV LOGSTASH_MAJOR) .*/\1 '"$version"'/' \
-e 's/^(ENV LOGSTASH_VERSION) .*/\1 '"$fullVersion"'/' Dockerfile
travisEnv=
for version in "${versions[@]}"; do
travisEnv='\n - VERSION='"$version$travisEnv"

fullVersion="$(curl -fsSL "http://packages.elasticsearch.org/logstash/$version/debian/dists/stable/main/binary-amd64/Packages" | awk -F ': ' '$1 == "Package" { pkg = $2 } pkg == "logstash" && $1 == "Version" { print $2 }' | sort -rV | head -n1)"
if [ -z "$fullVersion" ]; then
echo >&2 "warning: cannot find full version for $version"
continue
fi
(
set -x
cp docker-entrypoint.sh Dockerfile.template "$version/"
mv "$version/Dockerfile.template" "$version/Dockerfile"
sed -i '
s/%%LOGSTASH_MAJOR%%/'"$version"'/g;
s/%%LOGSTASH_VERSION%%/'"$fullVersion"'/g;
' "$version/Dockerfile"
)
done

travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml