This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile for S3 Loader (closes #1)
- Loading branch information
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM snowplow/base:0.1.0 | ||
LABEL maintainer="Snowplow Analytics Ltd. <[email protected]>" | ||
|
||
# The version of the loader to download. | ||
ENV S3_LOADER_VERSION="0.6.0" | ||
|
||
# The name of the archive to download. | ||
ENV ARCHIVE="snowplow_s3_loader_${S3_LOADER_VERSION}.zip" | ||
|
||
# Install the S3 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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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-s3-loader-${S3_LOADER_VERSION}.jar "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# S3 Loader | ||
|
||
This folder contains the Docker image for [the Snowplow S3 Loader][s3-loader] | ||
|
||
## Introduction | ||
|
||
This image is based on [the base image][base-image] which leverages | ||
[the Java 8 Alpine image][alpine-image]. | ||
|
||
The S3 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 S3 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/s3-loader:latest | ||
|
||
snowplow-s3-loader 0.x.0 | ||
|
||
Usage: snowplow-s3-loader [options] | ||
|
||
--help | ||
--version | ||
--config <filename> | ||
``` | ||
|
||
Alternatively, we can mount a configuration folder and run the loader: | ||
|
||
```bash | ||
$ docker run \ | ||
-d \ | ||
-v config:/snowplow/config \ | ||
snowplow/s3-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/s3-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 S3 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 | ||
|
||
[s3-loader]: https://github.com/snowplow/snowplow-s3-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 |