Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Add piinguin server image (closes #47)
Browse files Browse the repository at this point in the history
  • Loading branch information
knservis authored and BenFradet committed Aug 6, 2018
1 parent b632788 commit 1f0e413
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ env:
- IMG=s3-loader/0.6.0
- IMG=elasticsearch-loader/0.10.2
- IMG=iglu-server/0.3.0
- IMG=piinguin-server/0.1.1
global:
# BINTRAY_SNOWPLOW_DOCKER_USER
- secure: IcBMTopBAIzGlWNgS7dw0iNmvFhd2dgSn/Y1mt6hXnzLrr7SDryRuxPqemsCBLIlf4xtpgHvuOoo+7jYywtAOqyHQ+EOnR5eU8/28v+Z8zd/Djnw0Sv10RV5oMS6ejh9gGS4WDNPvf9M1sfP5p+0gA0p68dNeObLDT4TwpG2pdpeEuqQ3RMGCQc+tb3Q26K6aUPXeIgAHUyIEgHtzxxfgrGNwSmxdb6npsWTUttKpQkJudGRk17xXW67Dd0PKLWJkDpien/lbkLIBK8MlwaH03NMawGcTChgM2njcqElqz1b46wxl1ATcVV2T7A6YPYZxb012P8j/KUZ6MLhdDFNhmz/jIk6caEZ3x4AH2Q0qN8C9Hn70yMN8gAliBeUN4pjLpKnD8t5HgCE+90EufppcQRCfCJhSk9xmegTaikan3QZCN09vwSctIBu4AeWYqctql6bLhNWguakbRIyk9feogmxqbn2HSoFpRrAEqXXv9jFKJrKm2UNKuLbXCvyoYqjAhxTPn7OMAY30wqsVSUu5gSt1fO0Pd+5H8yq44Ul3jROgYKM5NlLWUY+u8qp6KKm2zXQ2LFlr8rzZ2ar5pI9zZiABDMnRRUdAXDTnpDw2HtBvngGXhyfr/irrzach0z/f5YwHL7WVf9Wu7MqoVpexdDqThNGip4ansIikrC57LE=
Expand Down Expand Up @@ -70,3 +71,9 @@ deploy:
on:
tags: true
condition: '"$(.travis/is_release_tag.sh iglu-server $TRAVIS_TAG)" == "" && $? == 0 && $IMG = base-alpine'
- provider: script
script: ./.travis/deploy.sh piinguin-server $TRAVIS_TAG
skip_cleanup: true
on:
tags: true
condition: '"$(.travis/is_release_tag.sh piinguin-server $TRAVIS_TAG)" == "" && $? == 0 && $IMG = base-alpine'
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This repository contains the Docker images for the following Snowplow components
- [Elasticsearch Loader][es]
- [S3 Loader][s3]
- [Iglu Server][iglu-server]
- [Piinguin Server][piinguin-server]

They are published in the [`snowplow-docker-registry.bintray.io`][registry] docker registry.

Expand All @@ -34,6 +35,9 @@ docker pull snowplow-docker-registry.bintray.io/snowplow/s3-loader:0.6.0

# Iglu Server image
docker pull snowplow-docker-registry.bintray.io/snowplow/iglu-server:0.3.0

# Piinguin Server image
docker pull snowplow-docker-registry.bintray.io/snowplow/piinguin-server:0.1.1
```

## Building
Expand All @@ -59,6 +63,9 @@ docker build -t snowplow/s3-loader:0.6.0 s3-loader/0.6.0

# Iglu Server image
docker build -t snowplow/iglu-server:0.3.0 iglu-server/0.3.0

# Piinguin Server image
docker build -t snowplow/piinguin-server:0.1.1 piinguin-server/0.1.1
```

## Running
Expand Down Expand Up @@ -114,13 +121,26 @@ docker run \
--config /snowplow/config/application.conf
```

In the case of the piinguin server there is no configuration file so you can run it simply with (if changing the port for the server, you may also need to publish a different port in the docker host):

```bash
$ docker run \
-d \
piinguin-server:${VERSION} \
-h <interface e.g. 0.0.0.0>
-p 8080
-t <piinguin-dynamo-table>
```


You can find more information in the readme for each image:

- [Scala Stream Collector readme][ssc-readme]
- [Stream Enrich readme][se-readme]
- [Elasticsearch Loader readme][es-readme]
- [S3 Loader readme][s3-readme]
- [Iglu Server readme][iglu-server-readme]
- [Piinguin Server readme][piinguin-server-readme]

There is a Docker Compose example in the [example folder][example]. Iglu Server also
has a Docker Compose example in a [separate example folder][iglu-example].
Expand Down Expand Up @@ -180,3 +200,5 @@ limitations under the License.

[license-image]: http://img.shields.io/badge/license-Apache--2-blue.svg?style=flat
[license]: http://www.apache.org/licenses/LICENSE-2.0
[piinguin-server]: https://github.com/snowplow-incubator/piinguin
[piinguin-server-readme]: https://github.com/snowplow-incubator/piinguin
28 changes: 28 additions & 0 deletions piinguin-server/0.1.1/Dockerfile
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" ]
8 changes: 8 additions & 0 deletions piinguin-server/0.1.1/docker-entrypoint.sh
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 "$@"
102 changes: 102 additions & 0 deletions piinguin-server/README.md
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 &copy; 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

0 comments on commit 1f0e413

Please sign in to comment.