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 piinguin server image (closes #47)
- Loading branch information
Showing
5 changed files
with
167 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
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,28 @@ | ||
FROM snowplow-docker-registry.bintray.io/snowplow/base-debian:0.1.0 | ||
LABEL maintainer="Snowplow Analytics Ltd. <[email protected]>" | ||
|
||
# The version of the server to download | ||
ENV PIINGUIN_SERVER_VERSION="0.1.1" | ||
|
||
# The name of the archive to download | ||
ENV ARCHIVE="snowplow_piinguin_server_${PIINGUIN_SERVER_VERSION}.zip" | ||
|
||
# Install Iglu Server, postgresql client | ||
RUN mkdir -p /tmp/build && \ | ||
cd /tmp/build && \ | ||
wget http://dl.bintray.com/snowplow/snowplow-generic/${ARCHIVE} && \ | ||
unzip -d ${SNOWPLOW_BIN_PATH} ${ARCHIVE} && \ | ||
cd /tmp && \ | ||
rm -rf /tmp/build && \ | ||
chown -R snowplow:snowplow ${SNOWPLOW_BIN_PATH} | ||
|
||
ENV PIINGUIN_PORT 8080 | ||
ENV PIINGUIN_HOST 0.0.0.0 | ||
ENV PIINGUIN_DYNAMO_TABLE piinguin | ||
|
||
EXPOSE $PIINGUIN_PORT | ||
|
||
# Defines an entrypoint script delegating the launching of the server 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 [ "/usr/local/bin/docker-entrypoint.sh" ] |
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,8 @@ | ||
#!/usr/bin/dumb-init /bin/sh | ||
set -e | ||
|
||
# Make sure we run the server as the snowplow user | ||
exec su-exec snowplow:snowplow /usr/bin/java \ | ||
$SP_JAVA_OPTS -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap \ | ||
-jar ${SNOWPLOW_BIN_PATH}/piinguin-server-assembly-${PIINGUIN_SERVER_VERSION}.jar \ | ||
-h $PIINGUIN_HOST -p $PIINGUIN_PORT -t $PIINGUIN_DYNAMO_TABLE "$@" |
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,102 @@ | ||
# Piinguin Server | ||
|
||
This folder contains | ||
|
||
* Dockerfile to build [Piinguin server][piinguin-server] | ||
* `0.1.1` | ||
|
||
## Introduction | ||
|
||
[Piinguin server][piinguin-server] images are based on [Snowplow base image][base-image] which leverages [the Java 8 Alpine image][alpine-image]. | ||
|
||
The Piinguin Server 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 Piinguin Server as the non-root `snowplow` user. | ||
|
||
The `-XX:+UnlockExperimentalVMOptions` and `-XX:+UseCGroupMemoryLimitForHeap` JVM options will be | ||
automatically provided when launching the server in order to make the JVM adhere to the memory | ||
limits imposed by Docker. For more information, see [this article][jvm-docker-article]. | ||
|
||
Additional JVM options can be set through the `SP_JAVA_OPTS` environment variable. | ||
|
||
### Build | ||
|
||
1) Clone repository | ||
|
||
`$ git clone [email protected]:snowplow/snowplow-docker.git` | ||
|
||
2) Navigate to `snowplow-docker/piinguin-server/` | ||
|
||
`$ cd snowplow-docker/piinguin-server/` | ||
|
||
3) Build image | ||
|
||
From the `piinguin-server` directory of this repo: | ||
```bash | ||
$ VERSION=0.1.1 | ||
$ docker build -t piinguin-server:${VERSION} $VERSION | ||
``` | ||
where `VERSION` is version of Piinguin Server one wants to run. Each version of Piinguin Server has a dedicated folder under `snowplow-docker/piinguin-server/` which contains a dedicated `Dockerfile`. | ||
|
||
### Run | ||
|
||
Running the container with `--help` will print out its usage: | ||
|
||
```bash | ||
$ docker run piinguin-server:${VERSION} --help | ||
|
||
Usage: piinguin-server [options] | ||
|
||
--help prints this help message | ||
--version prints the server version | ||
-h, --host <value> host to bind server to | ||
-p, --port <value> port number to bind server to | ||
-t, --table-name <value> the dynamodb table to use | ||
``` | ||
|
||
Alternatively, we run the server with: | ||
|
||
```bash | ||
$ docker run \ | ||
-d \ | ||
piinguin-server:${VERSION} | ||
``` | ||
|
||
If we want to specify additional JVM options, we can add the `SP_JAVA_OPTS` environment variable: | ||
|
||
```bash | ||
$ docker run \ | ||
-d \ | ||
-e 'SP_JAVA_OPTS=-Xms512m -Xmx512m' \ | ||
piinguin-server:${VERSION} | ||
``` | ||
|
||
If we want to specify alternative server arguments, we can override the environment variables e.g. `PIINGUIN_PORT`: | ||
|
||
```bash | ||
$ docker run \ | ||
-d \ | ||
-e 'PIINGUIN_PORT=12345' \ | ||
piinguin-server:${VERSION} | ||
``` | ||
|
||
## Copyright & License | ||
|
||
The Piinguin Server image © 2018 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 | ||
[piinguin-server]: https://github.com/snowplow-incubator/piinguin | ||
[alpine-image]: https://github.com/docker-library/openjdk/blob/master/8-jre/alpine/Dockerfile | ||
[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 |