diff --git a/.travis.yml b/.travis.yml index 0583557..d84dd06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,12 @@ language: bash services: docker env: - - VERSION=5 - - VERSION=2.4 - - VERSION=1.7 + - VERSION=5 VARIANT= + - VERSION=5 VARIANT=alpine + - VERSION=2.4 VARIANT= + - VERSION=2.4 VARIANT=alpine + - VERSION=1.7 VARIANT= + - VERSION=1.7 VARIANT=alpine install: - git clone https://github.com/docker-library/official-images.git ~/official-images diff --git a/1.7/Dockerfile b/1.7/Dockerfile index f264acf..51e9355 100644 --- a/1.7/Dockerfile +++ b/1.7/Dockerfile @@ -22,6 +22,7 @@ RUN set -x \ && echo 'deb http://packages.elasticsearch.org/elasticsearch/1.7/debian stable main' > /etc/apt/sources.list.d/elasticsearch.list ENV ELASTICSEARCH_VERSION 1.7.6 +ENV ELASTICSEARCH_DEB_VERSION 1.7.6 RUN set -x \ \ @@ -30,7 +31,7 @@ RUN set -x \ && dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \ \ && apt-get update \ - && apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \ + && apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \ && rm -rf /var/lib/apt/lists/* ENV PATH /usr/share/elasticsearch/bin:$PATH diff --git a/1.7/alpine/Dockerfile b/1.7/alpine/Dockerfile new file mode 100644 index 0000000..61c8852 --- /dev/null +++ b/1.7/alpine/Dockerfile @@ -0,0 +1,76 @@ +FROM openjdk:8-jre-alpine + +# ensure elasticsearch user exists +RUN addgroup -S elasticsearch && adduser -S -G elasticsearch elasticsearch + +# grab su-exec for easy step-down from root +# and bash for "bin/elasticsearch" among others +RUN apk add --no-cache 'su-exec>=0.2' bash + +# https://artifacts.elastic.co/GPG-KEY-elasticsearch +ENV GPG_KEY 46095ACC8548582C1A2699A9D27D666CD88E42B4 + +WORKDIR /usr/share/elasticsearch +ENV PATH /usr/share/elasticsearch/bin:$PATH + +ENV ELASTICSEARCH_VERSION 1.7.6 +ENV ELASTICSEARCH_TARBALL="https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.6.tar.gz" \ + ELASTICSEARCH_TARBALL_ASC="" \ + ELASTICSEARCH_TARBALL_SHA1="0b6ec9fe34b29e6adc4d8481630bf1f69cb04aa9" + +RUN set -ex; \ + \ + apk add --no-cache --virtual .fetch-deps \ + ca-certificates \ + gnupg \ + openssl \ + tar \ + ; \ + \ + wget -O elasticsearch.tar.gz "$ELASTICSEARCH_TARBALL"; \ + \ + if [ "$ELASTICSEARCH_TARBALL_SHA1" ]; then \ + echo "$ELASTICSEARCH_TARBALL_SHA1 *elasticsearch.tar.gz" | sha1sum -c -; \ + fi; \ + \ + if [ "$ELASTICSEARCH_TARBALL_ASC" ]; then \ + wget -O elasticsearch.tar.gz.asc "$ELASTICSEARCH_TARBALL_ASC"; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY"; \ + gpg --batch --verify elasticsearch.tar.gz.asc elasticsearch.tar.gz; \ + rm -r "$GNUPGHOME" elasticsearch.tar.gz.asc; \ + fi; \ + \ + tar -xf elasticsearch.tar.gz --strip-components=1; \ + rm elasticsearch.tar.gz; \ + \ + apk del .fetch-deps; \ + \ + mkdir -p ./plugins; \ + for path in \ + ./data \ + ./logs \ + ./config \ + ./config/scripts \ + ; do \ + mkdir -p "$path"; \ + chown -R elasticsearch:elasticsearch "$path"; \ + done; \ + \ + if [ "${ELASTICSEARCH_VERSION%%.*}" -gt 1 ]; then \ + elasticsearch --version; \ + else \ +# elasticsearch 1.x doesn't support --version +# but in 5.x, "-v" is verbose (and "-V" is --version) + elasticsearch -v; \ + fi + +COPY config ./config + +VOLUME /usr/share/elasticsearch/data + +COPY docker-entrypoint.sh / + +EXPOSE 9200 9300 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["elasticsearch"] diff --git a/1.7/alpine/config/logging.yml b/1.7/alpine/config/logging.yml new file mode 100644 index 0000000..c2681ac --- /dev/null +++ b/1.7/alpine/config/logging.yml @@ -0,0 +1,15 @@ +# you can override this using by setting a system property, for example -Des.logger.level=DEBUG +es.logger.level: INFO +rootLogger: ${es.logger.level}, console +logger: + # log action execution errors for easier debugging + action: DEBUG + # reduce the logging for aws, too much is logged under the default INFO + com.amazonaws: WARN + +appender: + console: + type: console + layout: + type: consolePattern + conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n" diff --git a/1.7/alpine/docker-entrypoint.sh b/1.7/alpine/docker-entrypoint.sh new file mode 100755 index 0000000..31d31fa --- /dev/null +++ b/1.7/alpine/docker-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +# Add elasticsearch as command if needed +if [ "${1:0:1}" = '-' ]; then + set -- elasticsearch "$@" +fi + +# Drop root privileges if we are running elasticsearch +# allow the container to be started with `--user` +if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then + # Change the ownership of /usr/share/elasticsearch/data to elasticsearch + chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data + + set -- su-exec elasticsearch "$@" + #exec su-exec elasticsearch "$BASH_SOURCE" "$@" +fi + +# As argument is not related to elasticsearch, +# then assume that user wants to run his own process, +# for example a `bash` shell to explore this image +exec "$@" diff --git a/2.4/Dockerfile b/2.4/Dockerfile index 0e599c0..b943a78 100644 --- a/2.4/Dockerfile +++ b/2.4/Dockerfile @@ -22,6 +22,7 @@ RUN set -x \ && echo 'deb http://packages.elasticsearch.org/elasticsearch/2.x/debian stable main' > /etc/apt/sources.list.d/elasticsearch.list ENV ELASTICSEARCH_VERSION 2.4.2 +ENV ELASTICSEARCH_DEB_VERSION 2.4.2 RUN set -x \ \ @@ -30,7 +31,7 @@ RUN set -x \ && dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \ \ && apt-get update \ - && apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \ + && apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \ && rm -rf /var/lib/apt/lists/* ENV PATH /usr/share/elasticsearch/bin:$PATH diff --git a/2.4/alpine/Dockerfile b/2.4/alpine/Dockerfile new file mode 100644 index 0000000..c0c7417 --- /dev/null +++ b/2.4/alpine/Dockerfile @@ -0,0 +1,76 @@ +FROM openjdk:8-jre-alpine + +# ensure elasticsearch user exists +RUN addgroup -S elasticsearch && adduser -S -G elasticsearch elasticsearch + +# grab su-exec for easy step-down from root +# and bash for "bin/elasticsearch" among others +RUN apk add --no-cache 'su-exec>=0.2' bash + +# https://artifacts.elastic.co/GPG-KEY-elasticsearch +ENV GPG_KEY 46095ACC8548582C1A2699A9D27D666CD88E42B4 + +WORKDIR /usr/share/elasticsearch +ENV PATH /usr/share/elasticsearch/bin:$PATH + +ENV ELASTICSEARCH_VERSION 2.4.2 +ENV ELASTICSEARCH_TARBALL="https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.4.2.tar.gz" \ + ELASTICSEARCH_TARBALL_ASC="https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.4.2.tar.gz.asc" \ + ELASTICSEARCH_TARBALL_SHA1="25effa2daacf5ba65151103dd47339fd88826756" + +RUN set -ex; \ + \ + apk add --no-cache --virtual .fetch-deps \ + ca-certificates \ + gnupg \ + openssl \ + tar \ + ; \ + \ + wget -O elasticsearch.tar.gz "$ELASTICSEARCH_TARBALL"; \ + \ + if [ "$ELASTICSEARCH_TARBALL_SHA1" ]; then \ + echo "$ELASTICSEARCH_TARBALL_SHA1 *elasticsearch.tar.gz" | sha1sum -c -; \ + fi; \ + \ + if [ "$ELASTICSEARCH_TARBALL_ASC" ]; then \ + wget -O elasticsearch.tar.gz.asc "$ELASTICSEARCH_TARBALL_ASC"; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY"; \ + gpg --batch --verify elasticsearch.tar.gz.asc elasticsearch.tar.gz; \ + rm -r "$GNUPGHOME" elasticsearch.tar.gz.asc; \ + fi; \ + \ + tar -xf elasticsearch.tar.gz --strip-components=1; \ + rm elasticsearch.tar.gz; \ + \ + apk del .fetch-deps; \ + \ + mkdir -p ./plugins; \ + for path in \ + ./data \ + ./logs \ + ./config \ + ./config/scripts \ + ; do \ + mkdir -p "$path"; \ + chown -R elasticsearch:elasticsearch "$path"; \ + done; \ + \ + if [ "${ELASTICSEARCH_VERSION%%.*}" -gt 1 ]; then \ + elasticsearch --version; \ + else \ +# elasticsearch 1.x doesn't support --version +# but in 5.x, "-v" is verbose (and "-V" is --version) + elasticsearch -v; \ + fi + +COPY config ./config + +VOLUME /usr/share/elasticsearch/data + +COPY docker-entrypoint.sh / + +EXPOSE 9200 9300 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["elasticsearch"] diff --git a/2.4/alpine/config/elasticsearch.yml b/2.4/alpine/config/elasticsearch.yml new file mode 100644 index 0000000..5108c77 --- /dev/null +++ b/2.4/alpine/config/elasticsearch.yml @@ -0,0 +1 @@ +network.host: 0.0.0.0 diff --git a/2.4/alpine/config/logging.yml b/2.4/alpine/config/logging.yml new file mode 100644 index 0000000..c2681ac --- /dev/null +++ b/2.4/alpine/config/logging.yml @@ -0,0 +1,15 @@ +# you can override this using by setting a system property, for example -Des.logger.level=DEBUG +es.logger.level: INFO +rootLogger: ${es.logger.level}, console +logger: + # log action execution errors for easier debugging + action: DEBUG + # reduce the logging for aws, too much is logged under the default INFO + com.amazonaws: WARN + +appender: + console: + type: console + layout: + type: consolePattern + conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n" diff --git a/2.4/alpine/docker-entrypoint.sh b/2.4/alpine/docker-entrypoint.sh new file mode 100755 index 0000000..31d31fa --- /dev/null +++ b/2.4/alpine/docker-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +# Add elasticsearch as command if needed +if [ "${1:0:1}" = '-' ]; then + set -- elasticsearch "$@" +fi + +# Drop root privileges if we are running elasticsearch +# allow the container to be started with `--user` +if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then + # Change the ownership of /usr/share/elasticsearch/data to elasticsearch + chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data + + set -- su-exec elasticsearch "$@" + #exec su-exec elasticsearch "$BASH_SOURCE" "$@" +fi + +# As argument is not related to elasticsearch, +# then assume that user wants to run his own process, +# for example a `bash` shell to explore this image +exec "$@" diff --git a/5/Dockerfile b/5/Dockerfile index c03e228..ae6e823 100644 --- a/5/Dockerfile +++ b/5/Dockerfile @@ -22,6 +22,7 @@ RUN set -x \ && echo 'deb https://artifacts.elastic.co/packages/5.x/apt stable main' > /etc/apt/sources.list.d/elasticsearch.list ENV ELASTICSEARCH_VERSION 5.1.1 +ENV ELASTICSEARCH_DEB_VERSION 5.1.1 RUN set -x \ \ @@ -30,7 +31,7 @@ RUN set -x \ && dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \ \ && apt-get update \ - && apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \ + && apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \ && rm -rf /var/lib/apt/lists/* ENV PATH /usr/share/elasticsearch/bin:$PATH diff --git a/5/alpine/Dockerfile b/5/alpine/Dockerfile new file mode 100644 index 0000000..5bbe1b2 --- /dev/null +++ b/5/alpine/Dockerfile @@ -0,0 +1,76 @@ +FROM openjdk:8-jre-alpine + +# ensure elasticsearch user exists +RUN addgroup -S elasticsearch && adduser -S -G elasticsearch elasticsearch + +# grab su-exec for easy step-down from root +# and bash for "bin/elasticsearch" among others +RUN apk add --no-cache 'su-exec>=0.2' bash + +# https://artifacts.elastic.co/GPG-KEY-elasticsearch +ENV GPG_KEY 46095ACC8548582C1A2699A9D27D666CD88E42B4 + +WORKDIR /usr/share/elasticsearch +ENV PATH /usr/share/elasticsearch/bin:$PATH + +ENV ELASTICSEARCH_VERSION 5.1.1 +ENV ELASTICSEARCH_TARBALL="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz" \ + ELASTICSEARCH_TARBALL_ASC="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz.asc" \ + ELASTICSEARCH_TARBALL_SHA1="7351cd29ac9c20592d94bde950f513b5c5bb44d3" + +RUN set -ex; \ + \ + apk add --no-cache --virtual .fetch-deps \ + ca-certificates \ + gnupg \ + openssl \ + tar \ + ; \ + \ + wget -O elasticsearch.tar.gz "$ELASTICSEARCH_TARBALL"; \ + \ + if [ "$ELASTICSEARCH_TARBALL_SHA1" ]; then \ + echo "$ELASTICSEARCH_TARBALL_SHA1 *elasticsearch.tar.gz" | sha1sum -c -; \ + fi; \ + \ + if [ "$ELASTICSEARCH_TARBALL_ASC" ]; then \ + wget -O elasticsearch.tar.gz.asc "$ELASTICSEARCH_TARBALL_ASC"; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY"; \ + gpg --batch --verify elasticsearch.tar.gz.asc elasticsearch.tar.gz; \ + rm -r "$GNUPGHOME" elasticsearch.tar.gz.asc; \ + fi; \ + \ + tar -xf elasticsearch.tar.gz --strip-components=1; \ + rm elasticsearch.tar.gz; \ + \ + apk del .fetch-deps; \ + \ + mkdir -p ./plugins; \ + for path in \ + ./data \ + ./logs \ + ./config \ + ./config/scripts \ + ; do \ + mkdir -p "$path"; \ + chown -R elasticsearch:elasticsearch "$path"; \ + done; \ + \ + if [ "${ELASTICSEARCH_VERSION%%.*}" -gt 1 ]; then \ + elasticsearch --version; \ + else \ +# elasticsearch 1.x doesn't support --version +# but in 5.x, "-v" is verbose (and "-V" is --version) + elasticsearch -v; \ + fi + +COPY config ./config + +VOLUME /usr/share/elasticsearch/data + +COPY docker-entrypoint.sh / + +EXPOSE 9200 9300 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["elasticsearch"] diff --git a/5/alpine/config/elasticsearch.yml b/5/alpine/config/elasticsearch.yml new file mode 100644 index 0000000..bee2cfe --- /dev/null +++ b/5/alpine/config/elasticsearch.yml @@ -0,0 +1,5 @@ +network.host: 0.0.0.0 + +# this value is required because we set "network.host" +# be sure to modify it appropriately for a production cluster deployment +discovery.zen.minimum_master_nodes: 1 diff --git a/5/alpine/config/log4j2.properties b/5/alpine/config/log4j2.properties new file mode 100644 index 0000000..46877d0 --- /dev/null +++ b/5/alpine/config/log4j2.properties @@ -0,0 +1,9 @@ +status = error + +appender.console.type = Console +appender.console.name = console +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n + +rootLogger.level = info +rootLogger.appenderRef.console.ref = console diff --git a/5/alpine/docker-entrypoint.sh b/5/alpine/docker-entrypoint.sh new file mode 100755 index 0000000..31d31fa --- /dev/null +++ b/5/alpine/docker-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +# Add elasticsearch as command if needed +if [ "${1:0:1}" = '-' ]; then + set -- elasticsearch "$@" +fi + +# Drop root privileges if we are running elasticsearch +# allow the container to be started with `--user` +if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then + # Change the ownership of /usr/share/elasticsearch/data to elasticsearch + chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data + + set -- su-exec elasticsearch "$@" + #exec su-exec elasticsearch "$BASH_SOURCE" "$@" +fi + +# As argument is not related to elasticsearch, +# then assume that user wants to run his own process, +# for example a `bash` shell to explore this image +exec "$@" diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template new file mode 100644 index 0000000..e632289 --- /dev/null +++ b/Dockerfile-alpine.template @@ -0,0 +1,76 @@ +FROM openjdk:8-jre-alpine + +# ensure elasticsearch user exists +RUN addgroup -S elasticsearch && adduser -S -G elasticsearch elasticsearch + +# grab su-exec for easy step-down from root +# and bash for "bin/elasticsearch" among others +RUN apk add --no-cache 'su-exec>=0.2' bash + +# https://artifacts.elastic.co/GPG-KEY-elasticsearch +ENV GPG_KEY 46095ACC8548582C1A2699A9D27D666CD88E42B4 + +WORKDIR /usr/share/elasticsearch +ENV PATH /usr/share/elasticsearch/bin:$PATH + +ENV ELASTICSEARCH_VERSION %%ELASTICSEARCH_VERSION%% +ENV ELASTICSEARCH_TARBALL="%%ELASTICSEARCH_TARBALL%%" \ + ELASTICSEARCH_TARBALL_ASC="%%ELASTICSEARCH_TARBALL_ASC%%" \ + ELASTICSEARCH_TARBALL_SHA1="%%ELASTICSEARCH_TARBALL_SHA1%%" + +RUN set -ex; \ + \ + apk add --no-cache --virtual .fetch-deps \ + ca-certificates \ + gnupg \ + openssl \ + tar \ + ; \ + \ + wget -O elasticsearch.tar.gz "$ELASTICSEARCH_TARBALL"; \ + \ + if [ "$ELASTICSEARCH_TARBALL_SHA1" ]; then \ + echo "$ELASTICSEARCH_TARBALL_SHA1 *elasticsearch.tar.gz" | sha1sum -c -; \ + fi; \ + \ + if [ "$ELASTICSEARCH_TARBALL_ASC" ]; then \ + wget -O elasticsearch.tar.gz.asc "$ELASTICSEARCH_TARBALL_ASC"; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY"; \ + gpg --batch --verify elasticsearch.tar.gz.asc elasticsearch.tar.gz; \ + rm -r "$GNUPGHOME" elasticsearch.tar.gz.asc; \ + fi; \ + \ + tar -xf elasticsearch.tar.gz --strip-components=1; \ + rm elasticsearch.tar.gz; \ + \ + apk del .fetch-deps; \ + \ + mkdir -p ./plugins; \ + for path in \ + ./data \ + ./logs \ + ./config \ + ./config/scripts \ + ; do \ + mkdir -p "$path"; \ + chown -R elasticsearch:elasticsearch "$path"; \ + done; \ + \ + if [ "${ELASTICSEARCH_VERSION%%.*}" -gt 1 ]; then \ + elasticsearch --version; \ + else \ +# elasticsearch 1.x doesn't support --version +# but in 5.x, "-v" is verbose (and "-V" is --version) + elasticsearch -v; \ + fi + +COPY config ./config + +VOLUME /usr/share/elasticsearch/data + +COPY docker-entrypoint.sh / + +EXPOSE 9200 9300 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["elasticsearch"] diff --git a/Dockerfile.template b/Dockerfile-debian.template similarity index 88% rename from Dockerfile.template rename to Dockerfile-debian.template index a737399..4204239 100644 --- a/Dockerfile.template +++ b/Dockerfile-debian.template @@ -19,9 +19,10 @@ RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC85485 # https://www.elastic.co/guide/en/elasticsearch/reference/5.0/deb.html RUN set -x \ && apt-get update && apt-get install -y --no-install-recommends apt-transport-https && rm -rf /var/lib/apt/lists/* \ - && echo 'deb %%ELASTICSEARCH_REPO_BASE%% stable main' > /etc/apt/sources.list.d/elasticsearch.list + && echo 'deb %%ELASTICSEARCH_DEB_REPO%% stable main' > /etc/apt/sources.list.d/elasticsearch.list ENV ELASTICSEARCH_VERSION %%ELASTICSEARCH_VERSION%% +ENV ELASTICSEARCH_DEB_VERSION %%ELASTICSEARCH_DEB_VERSION%% RUN set -x \ \ @@ -30,7 +31,7 @@ RUN set -x \ && dpkg-divert --rename /usr/lib/sysctl.d/elasticsearch.conf \ \ && apt-get update \ - && apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \ + && apt-get install -y --no-install-recommends "elasticsearch=$ELASTICSEARCH_DEB_VERSION" \ && rm -rf /var/lib/apt/lists/* ENV PATH /usr/share/elasticsearch/bin:$PATH diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 51e0a8f..d08c313 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -76,4 +76,20 @@ for version in "${versions[@]}"; do GitCommit: $commit Directory: $version EOE + + for variant in alpine; do + [ -f "$version/$variant/Dockerfile" ] || continue + + commit="$(dirCommit "$version/$variant")" + + variantAliases=( "${versionAliases[@]/%/-$variant}" ) + variantAliases=( "${variantAliases[@]//latest-/}" ) + + echo + cat <<-EOE + Tags: $(join ', ' "${variantAliases[@]}") + GitCommit: $commit + Directory: $version/$variant + EOE + done done diff --git a/update.sh b/update.sh index b5a6b15..09c4ad8 100755 --- a/update.sh +++ b/update.sh @@ -11,8 +11,6 @@ versions=( "${versions[@]%/}" ) travisEnv= for version in "${versions[@]}"; do - travisEnv='\n - VERSION='"$version$travisEnv" - rcVersion="${version%-rc}" majorVersion="${rcVersion%%.*}" @@ -20,29 +18,63 @@ for version in "${versions[@]}"; do if [ "$rcVersion" != "$version" ]; then aptBucket+='-prerelease' fi - repoBase= - if [ "$majorVersion" -ge 5 ]; then - repoBase="https://artifacts.elastic.co/packages/$aptBucket/apt" - elif [ "$majorVersion" -ge 2 ]; then - repoBase="http://packages.elasticsearch.org/elasticsearch/$aptBucket/debian" - else - repoBase="http://packages.elasticsearch.org/elasticsearch/$rcVersion/debian" + debRepo="https://artifacts.elastic.co/packages/$aptBucket/apt" + tarballUrlBase='https://artifacts.elastic.co/downloads' + if [ "$majorVersion" -eq 2 ]; then + debRepo="http://packages.elasticsearch.org/elasticsearch/$aptBucket/debian" + tarballUrlBase='https://download.elastic.co/elasticsearch' + elif [ "$majorVersion" -eq 1 ]; then + debRepo="http://packages.elasticsearch.org/elasticsearch/$rcVersion/debian" + tarballUrlBase='https://download.elastic.co/elasticsearch' fi - fullVersion="$(curl -fsSL "$repoBase/dists/stable/main/binary-amd64/Packages" | awk -F ': ' '$1 == "Package" { pkg = $2 } pkg == "elasticsearch" && $1 == "Version" && $2 ~ /^([0-9]+:)?'"$rcVersion"'/ { print $2 }' | sort -rV | head -n1)" + fullVersion="$(curl -fsSL "$debRepo/dists/stable/main/binary-amd64/Packages" | awk -F ': ' '$1 == "Package" { pkg = $2 } pkg == "elasticsearch" && $1 == "Version" && $2 ~ /^([0-9]+:)?'"$rcVersion"'/ { print $2 }' | sort -rV | head -n1)" if [ -z "$fullVersion" ]; then echo >&2 "warning: cannot find full version for $version" continue fi + # convert "1:5.0.2-1" over to "5.0.2" + plainVersion="${fullVersion%%-*}" # strip non-upstream-version + plainVersion="${plainVersion##*:}" # strip epoch + tilde='~'; plainVersion="${plainVersion//$tilde/-}" # replace '~' with '-' ( set -x cp docker-entrypoint.sh "$version/" sed ' - s/%%ELASTICSEARCH_VERSION%%/'"$fullVersion"'/g; - s!%%ELASTICSEARCH_REPO_BASE%%!'"$repoBase"'!g; - ' Dockerfile.template > "$version/Dockerfile" + s!%%ELASTICSEARCH_VERSION%%!'"$plainVersion"'!g; + s!%%ELASTICSEARCH_DEB_REPO%%!'"$debRepo"'!g; + s!%%ELASTICSEARCH_DEB_VERSION%%!'"$fullVersion"'!g; + ' Dockerfile-debian.template > "$version/Dockerfile" ) + + if [ -d "$version/alpine" ]; then + tarball="$tarballUrlBase/elasticsearch/elasticsearch-${plainVersion}.tar.gz" + tarballAsc="${tarball}.asc" + if ! wget --quiet --spider "$tarballAsc"; then + tarballAsc= + fi + tarballSha1= + for sha1Url in "${tarball}.sha1" "${tarball}.sha1.txt"; do + if sha1="$(wget -qO- "$sha1Url")"; then + tarballSha1="${sha1%% *}" + break + fi + done + ( + set -x + cp docker-entrypoint.sh "$version/alpine/" + sed -i 's/gosu/su-exec/g' "$version/alpine/docker-entrypoint.sh" + sed \ + -e 's!%%ELASTICSEARCH_VERSION%%!'"$plainVersion"'!g' \ + -e 's!%%ELASTICSEARCH_TARBALL%%!'"$tarball"'!g' \ + -e 's!%%ELASTICSEARCH_TARBALL_ASC%%!'"$tarballAsc"'!g' \ + -e 's!%%ELASTICSEARCH_TARBALL_SHA1%%!'"$tarballSha1"'!g' \ + Dockerfile-alpine.template > "$version/alpine/Dockerfile" + ) + travisEnv='\n - VERSION='"$version VARIANT=alpine$travisEnv" + fi + travisEnv='\n - VERSION='"$version VARIANT=$travisEnv" done travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"