From 12cdd2436cfc67c50ce4f8d97755f11918da8b27 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 4 Jul 2018 20:10:51 +0900 Subject: [PATCH] ing --- Dockerfile | 21 ++++++++++++++++++++ _docker/bin/docker-entrypoint.sh | 4 ++++ _docker/config/config.json | 34 ++++++++++++++++++++++++++++++++ build.sh | 8 ++++++++ docker-compose.yml | 10 ++++++++++ 5 files changed, 77 insertions(+) create mode 100644 Dockerfile create mode 100644 _docker/bin/docker-entrypoint.sh create mode 100644 _docker/config/config.json create mode 100755 build.sh create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..88aa6a3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM alpine:3.7 + +# grab su-exec for easy step-down from root +RUN apk add --no-cache curl + +COPY _docker/config/* /etc/overflow/config/ +COPY _docker/bin/* /usr/local/overflow/bin/ +COPY dist/consumer_metric /usr/local/overflow/bin/ + +RUN mkdir -p /var/overflow/logs; \ + chmod +x /usr/local/overflow/bin/docker-entrypoint.sh /usr/local/overflow/bin/consumer_metric; + +ENV TINI_VERSION='0.17.0' + +# Use tini as subreaper in Docker container to adopt zombie processes +RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-amd64 -o /bin/tini && chmod +x /bin/tini + +EXPOSE 80 + +ENTRYPOINT ["/bin/tini", "--"] +CMD ["/usr/local/overflow/bin/docker-entrypoint.sh"] \ No newline at end of file diff --git a/_docker/bin/docker-entrypoint.sh b/_docker/bin/docker-entrypoint.sh new file mode 100644 index 0000000..bea09bc --- /dev/null +++ b/_docker/bin/docker-entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -e + +exec /usr/local/overflow/bin/consumer_metric -config-dir=/etc/overflow/config \ No newline at end of file diff --git a/_docker/config/config.json b/_docker/config/config.json new file mode 100644 index 0000000..eb345d5 --- /dev/null +++ b/_docker/config/config.json @@ -0,0 +1,34 @@ +{ + "external": { + "grpc": { + "network": "tcp4", + "address": "central:9111" + }, + "kafka": { + "consumers": { + "metric": { + "brokers": [ + "kafka1:9092" + ], + "groupID": "overflow-metric-group-id", + "topic": "overflow-metric-topic", + "minBytes": 10000, + "maxBytes": 1000000 + } + } + }, + "influxDB": { + "clientConfigs": { + "metric": { + "clientType": "http", + "address": "influxdb:18086" + } + }, + "batchPointsConfigs": { + "metric": { + "database": "metric" + } + } + } + } +} diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..2836253 --- /dev/null +++ b/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +rm ./dist +CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-s" -o ./dist/consumer_metric + +docker build -t docker.loafle.net/overflow/consumer_metric:1.0.0-SNAPSHOT . + +docker push docker.loafle.net/overflow/consumer_metric:1.0.0-SNAPSHOT \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bc84d45 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: "3" + +services: + consumer_metric: + image: docker.loafle.net/overflow/consumer_metric:1.0.0-SNAPSHOT + container_name: consumer_metric + hostname: consumer_metric + restart: always + volumes: + - /service/overflow/data/consumer_metric/opt/conf:/opt/conf