From d4de6e0b2de37b7147928b4bafcc9ee919ef91d4 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 7 Sep 2020 11:21:37 +0200 Subject: [PATCH] Add docker setup for local testing --- Dockerfile | 14 ++++++++++++++ README.rst | 15 +++++++++++++++ docker-compose.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0e52256 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.8-slim + +USER root + +RUN mkdir /tmp/build +WORKDIR /tmp/build +COPY . . +RUN SETUPTOOLS_SCM_PRETEND_VERSION=0 pip install . + +WORKDIR /tmp +RUN rm -rf /tmp/build + +RUN useradd --system checker +USER checker diff --git a/README.rst b/README.rst index 7ff289b..80b0673 100644 --- a/README.rst +++ b/README.rst @@ -30,6 +30,21 @@ console scripts via the command line:: chweb_collect -c config.yaml & chweb_consume -c config.yaml & +Using docker-compose +-------------------- + +The services can be run with docker-compose. You'd need to change the values of +``KAFKA_SERVERS``, ``POSTGRES_HOST`` and ``POSTGRES_PASS`` in order for +the configuration to be properly applied. Also, you'd need to download the +kafka certificates and put them in the folder you're running docker-composer +from and create the PostgreSQL cert by copying it from aivens console and +saving it to ``pgcert.pem``. After all this is done, simply run:: + + docker-compose up + +Config file +=========== + Sites ----- diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..a33d83c --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,42 @@ +version: "3" +services: + collector: + build: + context: . + dockerfile: Dockerfile + environment: + KAFKA_SERVERS: "AIVEN_KAFKA_SERVER" + KAFKA_TOPIC: "sitestats" + KAFKA_CA_FILE: "/etc/kafka_ca.pem" + KAFKA_CERT: "/etc/kafka_service.cert" + KAFKA_KEY: "/etc/kafka_service.key" + volumes: + - ./config.yaml:/etc/checker.yaml + - ./ca.pem:/etc/kafka_ca.pem + - ./service.cert:/etc/kafka_service.cert + - ./service.key:/etc/kafka_service.key + command: chweb_collect + + consumer: + build: + context: . + dockerfile: Dockerfile + environment: + KAFKA_SERVERS: "AIVEN_KAFKA_SERVER" + KAFKA_TOPIC: "sitestats" + KAFKA_CA_FILE: "/etc/kafka_ca.pem" + KAFKA_CERT: "/etc/kafka_service.cert" + KAFKA_KEY: "/etc/kafka_service.key" + POSTGRES_DB: "defaultdb" + POSTGRES_HOST: "AIVEN_PG_SERVER" + POSTGRES_PORT: 23700 + POSTGRES_USER: "avnadmin" + POSTGRES_PASS: "" + POSTGRES_CERT: "/etc/pgcert.pem" + volumes: + - ./config.yaml:/etc/checker.yaml + - ./ca.pem:/etc/kafka_ca.pem + - ./service.cert:/etc/kafka_service.cert + - ./service.key:/etc/kafka_service.key + - ./pgcert.pem:/etc/pgcert.pem + command: chweb_consume