diff --git a/.travis.yml b/.travis.yml index 0625eb4..719b804 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: - IMG=scala-stream-collector/0.10.0 - IMG=stream-enrich/0.11.0 - IMG=s3-loader/0.6.0 + - IMG=elasticsearch-loader/0.10.0 global: # BINTRAY_SNOWPLOW_DOCKER_USER - secure: IcBMTopBAIzGlWNgS7dw0iNmvFhd2dgSn/Y1mt6hXnzLrr7SDryRuxPqemsCBLIlf4xtpgHvuOoo+7jYywtAOqyHQ+EOnR5eU8/28v+Z8zd/Djnw0Sv10RV5oMS6ejh9gGS4WDNPvf9M1sfP5p+0gA0p68dNeObLDT4TwpG2pdpeEuqQ3RMGCQc+tb3Q26K6aUPXeIgAHUyIEgHtzxxfgrGNwSmxdb6npsWTUttKpQkJudGRk17xXW67Dd0PKLWJkDpien/lbkLIBK8MlwaH03NMawGcTChgM2njcqElqz1b46wxl1ATcVV2T7A6YPYZxb012P8j/KUZ6MLhdDFNhmz/jIk6caEZ3x4AH2Q0qN8C9Hn70yMN8gAliBeUN4pjLpKnD8t5HgCE+90EufppcQRCfCJhSk9xmegTaikan3QZCN09vwSctIBu4AeWYqctql6bLhNWguakbRIyk9feogmxqbn2HSoFpRrAEqXXv9jFKJrKm2UNKuLbXCvyoYqjAhxTPn7OMAY30wqsVSUu5gSt1fO0Pd+5H8yq44Ul3jROgYKM5NlLWUY+u8qp6KKm2zXQ2LFlr8rzZ2ar5pI9zZiABDMnRRUdAXDTnpDw2HtBvngGXhyfr/irrzach0z/f5YwHL7WVf9Wu7MqoVpexdDqThNGip4ansIikrC57LE= diff --git a/elasticsearch-loader/0.10.0/Dockerfile b/elasticsearch-loader/0.10.0/Dockerfile new file mode 100644 index 0000000..48d2d43 --- /dev/null +++ b/elasticsearch-loader/0.10.0/Dockerfile @@ -0,0 +1,23 @@ +FROM snowplow/base:0.1.0 +LABEL maintainer="Snowplow Analytics Ltd. " + +# The version of the loader to download. +ENV ELASTICSEARCH_LOADER_VERSION="0.10.0" + +# The name of the archive to download. +ENV ARCHIVE="snowplow_elasticsearch_loader_http_${ELASTICSEARCH_LOADER_VERSION}.zip" + +# Install the ElasticSearch Loader. +RUN mkdir -p /tmp/build && \ + cd /tmp/build && \ + wget -q http://dl.bintray.com/snowplow/snowplow-generic/${ARCHIVE} && \ + unzip -d ${SNOWPLOW_BIN_PATH} ${ARCHIVE} && \ + cd /tmp && \ + rm -rf /tmp/build + +# Defines an entrypoint script delegating the lauching of the loader to the snowplow user. +# The script uses dumb-init as the top-level process. +COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh +ENTRYPOINT [ "docker-entrypoint.sh" ] + +CMD [ "--usage" ] \ No newline at end of file diff --git a/elasticsearch-loader/0.10.0/docker-entrypoint.sh b/elasticsearch-loader/0.10.0/docker-entrypoint.sh new file mode 100755 index 0000000..d5f53bf --- /dev/null +++ b/elasticsearch-loader/0.10.0/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/usr/bin/dumb-init /bin/sh +set -e + +# If the config directory has been mounted through -v, we chown it. +if [ "$(stat -c %u ${SNOWPLOW_CONFIG_PATH})" != "$(id -u snowplow)" ]; then + chown snowplow:snowplow ${SNOWPLOW_CONFIG_PATH} +fi + +# Make sure we run the loader as the snowplow user +exec su-exec snowplow:snowplow /usr/bin/java \ + $SP_JAVA_OPTS \ + -jar ${SNOWPLOW_BIN_PATH}/snowplow-elasticsearch-loader-http-${ELASTICSEARCH_LOADER_VERSION}.jar "$@" \ No newline at end of file diff --git a/elasticsearch-loader/README.md b/elasticsearch-loader/README.md new file mode 100644 index 0000000..496bae8 --- /dev/null +++ b/elasticsearch-loader/README.md @@ -0,0 +1,87 @@ +# Elasticsearch Loader + +This folder contains the Docker image for [the Snowplow Elasticsearch Loader][es-loader] + +## Introduction + +This image is based on [the base image][base-image] which leverages +[the Java 8 Alpine image][alpine-image]. + +The Elasticsearch Loader runs under [dumb-init][dumb-init] which handles reaping zombie processes +and forwards signals on to all processes running in the container. This image also uses +[su-exec][su-exec], as a sudo replacement, to run the Elasticsearch Loader as the non-root +`snowplow` user. + +The container exposes the `/snowplow/config` volume to store the loader configuration. If this +folder is bind mounted then ownership will be changed to the `snowplow` user. + +The `-XX:+UnlockExperimentalVMOptions` and `-XX:+UseCGroupMemoryLimitForHeap` JVM options will be +automatically provided when launching the loader in order to make the JVM adhere to the memory +limits imposed by Docker. For more information, see [this article][jvm-docker-article] for more +information. + +Additional JVM options can be set through the `SP_JAVA_OPTS` environment variable. + +## Usage + +Running the container without arguments will print out its usage: + +```bash +$ docker run snowplow/elasticsearch-loader:latest + +snowplow-elasticsearch-loader 0.x.0 + +Usage: snowplow-elasticsearch-loader [options] + + --help + --version + --config +``` + +Alternatively, we can mount a configuration folder and run the loader: + +```bash +$ docker run \ + -d \ + -v config:/snowplow/config \ + snowplow/elasticsearch-loader:latest \ + --config /snowplow/config/config.hocon +``` + +If we want to specify additional JVM options, we can add the `SP_JAVA_OPTS` environment variable: + +```bash +$ docker run \ + -d \ + -v config:/snowplow/config \ + -e 'SP_JAVA_OPTS=-Xms512m -Xmx512m' \ + snowplow/elasticsearch-loader:latest \ + --config /snowplow/config/config.hocon +``` + +For a more complete example, check out [the docker compose example][docker-compose-example]. + +## Copyright and license + +The Elasticsearch Loader image is copyright 2017-2017 Snowplow Analytics Ltd. + +Licensed under the [Apache License, Version 2.0][license] (the "License"); +you may not use this software except in compliance with the License. + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +[base-image]: https://github.com/snowplow/snowplow-docker/tree/master/base +[docker-compose-example]: https://github.com/snowplow/snowplow-docker/tree/master/example +[alpine-image]: https://github.com/docker-library/openjdk/blob/master/8-jre/alpine/Dockerfile + +[es-loader]: https://github.com/snowplow/snowplow-elasticsearch-loader/ +[dumb-init]: https://github.com/Yelp/dumb-init +[su-exec]: https://github.com/ncopa/su-exec + +[jvm-docker-article]: https://blogs.oracle.com/java-platform-group/java-se-support-for-docker-cpu-and-memory-limits + +[license]: http://www.apache.org/licenses/LICENSE-2.0 \ No newline at end of file