From c2e4bf9d7fc7c395d8c5d3ccb44242365a307585 Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Wed, 27 May 2020 12:08:38 +0200 Subject: [PATCH 1/8] ci(travis): Add Travis-CI config #44 Signed-off-by: mathieu.brunot --- .env | 12 +++++++ .travis.yml | 67 +++++++++++++++++++++++++++++++++++++ README.md | 1 + docker-compose_mysql.yml | 66 ++++++++++++++++++++++++++++++++++++ docker-compose_postgres.yml | 55 ++++++++++++++++++++++++++++++ docker-compose_sqlite.yml | 35 +++++++++++++++++++ 6 files changed, 236 insertions(+) create mode 100644 .env create mode 100644 .travis.yml create mode 100644 docker-compose_mysql.yml create mode 100644 docker-compose_postgres.yml create mode 100644 docker-compose_sqlite.yml diff --git a/.env b/.env new file mode 100644 index 0000000..916ad31 --- /dev/null +++ b/.env @@ -0,0 +1,12 @@ +# PowerDNS configuration + +PDNS_DB_HOST=pdns-db +PDNS_DB_NAME=pdns +PDNS_DB_USER=pdns +PDNS_DB_PASSWORD=changeme + +PDNS_PROTO=http +PDNS_HOST=pdns-server +PDNS_PORT=8081 +PDNS_API_KEY=changeme +PDNS_WEBSERVER_ALLOW_FROM=0.0.0.0 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..56d2c19 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,67 @@ +os: linux +dist: bionic + +services: docker + +language: shell + +branches: + only: + - master + - develop + +before_install: + - env | sort + - export TAG=travis + - export VCS_REF=`git rev-parse --short HEAD` + - export BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` + - export name="pdns-server" + - export image="docker-powerdns" + - export home=$(pwd) + - export travis_dir="${home}/" + +install: + - cd "$travis_dir" + # Test container build + - travis_retry docker build -t "$image" "$travis_dir" + +before_script: + - docker images + +script: + - cd "$travis_dir" + # Test container run + - docker run --rm --name "cmd_help" -e AUTOCONF=$AUTOCONF "$image" --help + #- docker run --rm --name "cmd_version" -e AUTOCONF=$AUTOCONF "$image" --version + - docker run --name "$name" -e AUTOCONF=$AUTOCONF -d "$image" + - docker ps | grep "$name" + - docker logs "$name" + - docker stop "$name" && docker rm -f "$name" + # Docker-compose tests + - mv docker-compose_$AUTOCONF.yml docker-compose.yml + - rm -f docker-compose_*.yml + - travis_retry travis_wait 60 docker-compose build + - docker images + - travis_retry docker-compose up -d && sleep 30 + - docker-compose ps + - docker-compose logs + - docker-compose ps "$name" | grep "Up" + - echo 'Wait until everything ready (1-2 minutes)' && sleep 120 + - docker-compose ps + - docker-compose logs + - docker-compose ps "$name" | grep "Up" + - docker-compose down + - travis_retry docker-compose up -d && sleep 30 + - echo 'Wait until everything ready (1-2 minutes)' && sleep 120 + - docker-compose ps + - docker-compose logs + - docker-compose ps "$name" | grep "Up" + +notifications: + email: false + +env: # Environments + #- AUTOCONF=false + - AUTOCONF=sqlite + - AUTOCONF=postgres + - AUTOCONF=mysql diff --git a/README.md b/README.md index 8f5e592..2ed5036 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # PowerDNS Docker Container +[![Build Status](https://travis-ci.org/psi-4ward/docker-powerdns.svg)](https://travis-ci.org/psi-4ward/docker-powerdns) [![Image Size](https://images.microbadger.com/badges/image/psitrax/powerdns.svg)](https://microbadger.com/images/psitrax/powerdns) [![Docker Stars](https://img.shields.io/docker/stars/psitrax/powerdns.svg)](https://hub.docker.com/r/psitrax/powerdns/) [![Docker Pulls](https://img.shields.io/docker/pulls/psitrax/powerdns.svg)](https://hub.docker.com/r/psitrax/powerdns/) diff --git a/docker-compose_mysql.yml b/docker-compose_mysql.yml new file mode 100644 index 0000000..8ca53a3 --- /dev/null +++ b/docker-compose_mysql.yml @@ -0,0 +1,66 @@ +version: "2.1" + +services: + pdns-server: + build: . + image: docker-powerdns + hostname: ${PDNS_HOST} + container_name: ${PDNS_HOST} + ports: + - "5053:53" + - "5053:53/udp" + networks: + - default + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + environment: + - MYSQL_AUTOCONF=true + #- AUTOCONF=mysql + # MySQL / MariaDB + - MYSQL_HOST=${PDNS_DB_HOST} + - MYSQL_PORT=3306 + - MYSQL_DB=${PDNS_DB_NAME} + - MYSQL_USER=${PDNS_DB_USER} + - MYSQL_PASS=${PDNS_DB_PASSWORD} + - MYSQL_DNSSEC=no + - PDNS_API=yes + - PDNS_API_KEY=${PDNS_API_KEY} + - PDNS_WEBSERVER_ADDRESS=0.0.0.0 + - PDNS_WEBSERVER_PORT=8081 + - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 + - PDNS_SOA_REFRESH_DEFAULT=14400 + depends_on: + pdns-mysql: + condition: service_healthy + + pdns-mysql: + image: mariadb:10.3 + hostname: ${PDNS_DB_HOST} + container_name: ${PDNS_DB_HOST} + mem_limit: 256M + memswap_limit: 256M + expose: + - 3306 + volumes: + - powerdns-mysql-data:/var/lib/mysql + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + networks: + - default + command: --character_set_client=utf8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --character-set-client-handshake=FALSE + environment: + - MYSQL_DATABASE=${PDNS_DB_NAME} + - MYSQL_USER=${PDNS_DB_USER} + - MYSQL_PASSWORD=${PDNS_DB_PASSWORD} + - MYSQL_RANDOM_ROOT_PASSWORD=1 + healthcheck: + test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] + timeout: 10s + retries: 5 + +networks: + default: + +volumes: + powerdns-mysql-data: diff --git a/docker-compose_postgres.yml b/docker-compose_postgres.yml new file mode 100644 index 0000000..0e1d31c --- /dev/null +++ b/docker-compose_postgres.yml @@ -0,0 +1,55 @@ +version: "2.1" + +services: + pdns-server: + build: . + image: docker-powerdns + hostname: ${PDNS_HOST} + container_name: ${PDNS_HOST} + ports: + - "5053:53" + - "5053:53/udp" + networks: + - default + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + environment: + - AUTOCONF=postgres + # PostgreSQL + - PGSQL_HOST=${PDNS_DB_HOST} + - PGSQL_PORT=5432 + - PGSQL_DB=${PDNS_DB_NAME} + - PGSQL_USER=${PDNS_DB_USER} + - PGSQL_PASS=${PDNS_DB_PASSWORD} + - PGSQL_DNSSEC=no + - PDNS_API=yes + - PDNS_API_KEY=${PDNS_API_KEY} + - PDNS_WEBSERVER_ADDRESS=0.0.0.0 + - PDNS_WEBSERVER_PORT=8081 + - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 + - PDNS_SOA_REFRESH_DEFAULT=14400 + depends_on: + - pdns-postgresql + + pdns-postgresql: + image: postgres:10-alpine + hostname: ${PDNS_DB_HOST} + container_name: ${PDNS_DB_HOST} + restart: always + environment: + - POSTGRES_DB=${PDNS_DB_NAME} + - POSTGRES_USER=${PDNS_DB_USER} + - POSTGRES_PASSWORD=${PDNS_DB_PASSWORD} + healthcheck: + test: ["CMD", "pg_isready", "-U", "${PDNS_DB_USER}"] + volumes: + - powerdns-postgresql-data:/var/lib/postgresql/data + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + +networks: + default: + +volumes: + powerdns-postgresql-data: diff --git a/docker-compose_sqlite.yml b/docker-compose_sqlite.yml new file mode 100644 index 0000000..6dada0a --- /dev/null +++ b/docker-compose_sqlite.yml @@ -0,0 +1,35 @@ +version: "2.1" + +services: + pdns-server: + build: . + image: docker-powerdns + hostname: ${PDNS_HOST} + container_name: ${PDNS_HOST} + ports: + - "5053:53" + - "5053:53/udp" + networks: + - default + volumes: + - powerdns-sqlite-data:/srv/pdns/db + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + environment: + - AUTOCONF=sqlite + # SQLite + - SQLITE_DB=/srv/pdns/db/${PDNS_DB_NAME} + - SQLITE_DNSSEC=no + # PDNS Config + - PDNS_API=yes + - PDNS_API_KEY=${PDNS_API_KEY} + - PDNS_WEBSERVER_ADDRESS=0.0.0.0 + - PDNS_WEBSERVER_PORT=8081 + - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 + - PDNS_SOA_REFRESH_DEFAULT=14400 + +networks: + default: + +volumes: + powerdns-sqlite-data: From 123aad9480227b288af9432034178bcefad39015 Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Wed, 27 May 2020 19:03:45 +0200 Subject: [PATCH 2/8] =?UTF-8?q?=E2=9C=85=20Use=20Dockerhub=20tests=20forma?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mathieu.brunot --- .test/Dockerfile | 8 +++++ .test/docker_test.sh | 27 ++++++++++++++++ .travis.yml | 32 +++++++++---------- ...mysql.yml => docker-compose.mysql.test.yml | 21 +++++++++++- ...es.yml => docker-compose.postgres.test.yml | 21 +++++++++++- ...lite.yml => docker-compose.sqlite.test.yml | 19 ++++++++++- 6 files changed, 109 insertions(+), 19 deletions(-) create mode 100644 .test/Dockerfile create mode 100644 .test/docker_test.sh rename docker-compose_mysql.yml => docker-compose.mysql.test.yml (78%) rename docker-compose_postgres.yml => docker-compose.postgres.test.yml (74%) rename docker-compose_sqlite.yml => docker-compose.sqlite.test.yml (64%) diff --git a/.test/Dockerfile b/.test/Dockerfile new file mode 100644 index 0000000..461eb64 --- /dev/null +++ b/.test/Dockerfile @@ -0,0 +1,8 @@ +FROM alpine:3.9 + +COPY docker_test.sh /docker_test.sh + +RUN set -ex; \ + chmod 755 /docker_test.sh; + +CMD ["/docker_test.sh"] diff --git a/.test/docker_test.sh b/.test/docker_test.sh new file mode 100644 index 0000000..05ff0e4 --- /dev/null +++ b/.test/docker_test.sh @@ -0,0 +1,27 @@ +#!/usr/bin/sh + +set -e + +################################################################################ +# Testing docker containers + +echo "Waiting to ensure everything is fully ready for the tests..." +sleep 60 + +echo "Checking main containers are reachable..." +if ! ping -c 10 -q "${PING_CONTAINER}" ; then + echo 'Main container is not responding!' + exit 1 +fi + + +################################################################################ +# Testing PowerDNS + +# TODO Check PowerDNS is up from this container, maybe using its Web API + +################################################################################ +# Success +echo 'Docker tests successful' +echo 'Check the CI reports and logs for details.' +exit 0 diff --git a/.travis.yml b/.travis.yml index 56d2c19..ab0c9ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,18 +12,18 @@ branches: before_install: - env | sort - - export TAG=travis - export VCS_REF=`git rev-parse --short HEAD` - export BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` - - export name="pdns-server" - - export image="docker-powerdns" + - export CONTAINER_NAME="pdns-server" + - export TAG=travis + - export IMAGE_NAME="docker-powerdns:${TAG}" - export home=$(pwd) - export travis_dir="${home}/" install: - cd "$travis_dir" # Test container build - - travis_retry docker build -t "$image" "$travis_dir" + - travis_retry docker build -t "${IMAGE_NAME}" "$travis_dir" before_script: - docker images @@ -31,37 +31,37 @@ before_script: script: - cd "$travis_dir" # Test container run - - docker run --rm --name "cmd_help" -e AUTOCONF=$AUTOCONF "$image" --help - #- docker run --rm --name "cmd_version" -e AUTOCONF=$AUTOCONF "$image" --version - - docker run --name "$name" -e AUTOCONF=$AUTOCONF -d "$image" - - docker ps | grep "$name" - - docker logs "$name" - - docker stop "$name" && docker rm -f "$name" + - docker run --rm --name "cmd_help" -e AUTOCONF=$AUTOCONF "${IMAGE_NAME}" --help + #- docker run --rm --name "cmd_version" -e AUTOCONF=$AUTOCONF "${IMAGE_NAME}" --version + - docker run --name "${CONTAINER_NAME}" -e AUTOCONF=$AUTOCONF -d "${IMAGE_NAME}" + - docker ps | grep "${CONTAINER_NAME}" + - docker logs "${CONTAINER_NAME}" + - docker stop "${CONTAINER_NAME}" && docker rm -f "${CONTAINER_NAME}" # Docker-compose tests - - mv docker-compose_$AUTOCONF.yml docker-compose.yml + - mv docker-compose.$AUTOCONF.test.yml docker-compose.yml - rm -f docker-compose_*.yml - travis_retry travis_wait 60 docker-compose build - docker images - travis_retry docker-compose up -d && sleep 30 - docker-compose ps - docker-compose logs - - docker-compose ps "$name" | grep "Up" + - docker-compose ps "${CONTAINER_NAME}" | grep "Up" - echo 'Wait until everything ready (1-2 minutes)' && sleep 120 - docker-compose ps - docker-compose logs - - docker-compose ps "$name" | grep "Up" + - docker-compose ps "${CONTAINER_NAME}" | grep "Up" - docker-compose down - travis_retry docker-compose up -d && sleep 30 - echo 'Wait until everything ready (1-2 minutes)' && sleep 120 - docker-compose ps - docker-compose logs - - docker-compose ps "$name" | grep "Up" + - docker-compose ps "${CONTAINER_NAME}" | grep "Up" notifications: email: false env: # Environments #- AUTOCONF=false - - AUTOCONF=sqlite - - AUTOCONF=postgres + #- AUTOCONF=sqlite + #- AUTOCONF=postgres - AUTOCONF=mysql diff --git a/docker-compose_mysql.yml b/docker-compose.mysql.test.yml similarity index 78% rename from docker-compose_mysql.yml rename to docker-compose.mysql.test.yml index 8ca53a3..0f5f808 100644 --- a/docker-compose_mysql.yml +++ b/docker-compose.mysql.test.yml @@ -1,9 +1,27 @@ version: "2.1" services: + # https://docs.docker.com/docker-hub/builds/automated-testing/ + sut: + build: + context: ./.test + dockerfile: Dockerfile + command: sh /docker_test.sh + depends_on: + - pdns-server + - pdns-mysql + environment: + # Tests setup + - PING_CONTAINER=pdns-server + volumes_from: + - pdns-server + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + pdns-server: build: . - image: docker-powerdns + image: ${IMAGE_NAME} hostname: ${PDNS_HOST} container_name: ${PDNS_HOST} ports: @@ -24,6 +42,7 @@ services: - MYSQL_USER=${PDNS_DB_USER} - MYSQL_PASS=${PDNS_DB_PASSWORD} - MYSQL_DNSSEC=no + # PDNS Config - PDNS_API=yes - PDNS_API_KEY=${PDNS_API_KEY} - PDNS_WEBSERVER_ADDRESS=0.0.0.0 diff --git a/docker-compose_postgres.yml b/docker-compose.postgres.test.yml similarity index 74% rename from docker-compose_postgres.yml rename to docker-compose.postgres.test.yml index 0e1d31c..0c2bdea 100644 --- a/docker-compose_postgres.yml +++ b/docker-compose.postgres.test.yml @@ -1,9 +1,27 @@ version: "2.1" services: + # https://docs.docker.com/docker-hub/builds/automated-testing/ + sut: + build: + context: ./.test + dockerfile: Dockerfile + command: sh /docker_test.sh + depends_on: + - pdns-server + - pdns-postgresql + environment: + # Tests setup + - PING_CONTAINER=pdns-server + volumes_from: + - pdns-server + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + pdns-server: build: . - image: docker-powerdns + image: ${IMAGE_NAME} hostname: ${PDNS_HOST} container_name: ${PDNS_HOST} ports: @@ -23,6 +41,7 @@ services: - PGSQL_USER=${PDNS_DB_USER} - PGSQL_PASS=${PDNS_DB_PASSWORD} - PGSQL_DNSSEC=no + # PDNS Config - PDNS_API=yes - PDNS_API_KEY=${PDNS_API_KEY} - PDNS_WEBSERVER_ADDRESS=0.0.0.0 diff --git a/docker-compose_sqlite.yml b/docker-compose.sqlite.test.yml similarity index 64% rename from docker-compose_sqlite.yml rename to docker-compose.sqlite.test.yml index 6dada0a..d44413e 100644 --- a/docker-compose_sqlite.yml +++ b/docker-compose.sqlite.test.yml @@ -1,9 +1,26 @@ version: "2.1" services: + # https://docs.docker.com/docker-hub/builds/automated-testing/ + sut: + build: + context: ./.test + dockerfile: Dockerfile + command: sh /docker_test.sh + depends_on: + - pdns-server + environment: + # Tests setup + - PING_CONTAINER=pdns-server + volumes_from: + - pdns-server + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + pdns-server: build: . - image: docker-powerdns + image: ${IMAGE_NAME} hostname: ${PDNS_HOST} container_name: ${PDNS_HOST} ports: From e9a5269dad036c85f4b3a5a591a5594db71d1bfd Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Wed, 27 May 2020 19:06:36 +0200 Subject: [PATCH 3/8] :wrench: Follow name of docker image Signed-off-by: mathieu.brunot --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ab0c9ae..98cefb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ before_install: - export BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` - export CONTAINER_NAME="pdns-server" - export TAG=travis - - export IMAGE_NAME="docker-powerdns:${TAG}" + - export IMAGE_NAME="psitrax/powerdns:${TAG}" - export home=$(pwd) - export travis_dir="${home}/" From fcb9228533a477b593890d0a84c43d1dd4e39136 Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Thu, 28 May 2020 13:04:04 +0200 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=92=9A=20Do=20not=20share=20DB=20host?= =?UTF-8?q?=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mathieu.brunot --- .env | 1 - docker-compose.mysql.test.yml | 6 +++--- docker-compose.postgres.test.yml | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 916ad31..2a5607b 100644 --- a/.env +++ b/.env @@ -1,6 +1,5 @@ # PowerDNS configuration -PDNS_DB_HOST=pdns-db PDNS_DB_NAME=pdns PDNS_DB_USER=pdns PDNS_DB_PASSWORD=changeme diff --git a/docker-compose.mysql.test.yml b/docker-compose.mysql.test.yml index 0f5f808..fa84529 100644 --- a/docker-compose.mysql.test.yml +++ b/docker-compose.mysql.test.yml @@ -36,7 +36,7 @@ services: - MYSQL_AUTOCONF=true #- AUTOCONF=mysql # MySQL / MariaDB - - MYSQL_HOST=${PDNS_DB_HOST} + - MYSQL_HOST=pdns-mysql - MYSQL_PORT=3306 - MYSQL_DB=${PDNS_DB_NAME} - MYSQL_USER=${PDNS_DB_USER} @@ -55,8 +55,8 @@ services: pdns-mysql: image: mariadb:10.3 - hostname: ${PDNS_DB_HOST} - container_name: ${PDNS_DB_HOST} + hostname: pdns-mysql + container_name: pdns-mysql mem_limit: 256M memswap_limit: 256M expose: diff --git a/docker-compose.postgres.test.yml b/docker-compose.postgres.test.yml index 0c2bdea..57dc44b 100644 --- a/docker-compose.postgres.test.yml +++ b/docker-compose.postgres.test.yml @@ -35,7 +35,7 @@ services: environment: - AUTOCONF=postgres # PostgreSQL - - PGSQL_HOST=${PDNS_DB_HOST} + - PGSQL_HOST=pdns-postgresql - PGSQL_PORT=5432 - PGSQL_DB=${PDNS_DB_NAME} - PGSQL_USER=${PDNS_DB_USER} @@ -53,8 +53,8 @@ services: pdns-postgresql: image: postgres:10-alpine - hostname: ${PDNS_DB_HOST} - container_name: ${PDNS_DB_HOST} + hostname: pdns-postgresql + container_name: pdns-postgresql restart: always environment: - POSTGRES_DB=${PDNS_DB_NAME} From cc34e26b8629571082374a02e945684791ee6640 Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Fri, 29 May 2020 03:45:53 +0200 Subject: [PATCH 5/8] :wrench: Add Log and Webserver config Signed-off-by: mathieu.brunot --- docker-compose.mysql.test.yml | 2 ++ docker-compose.postgres.test.yml | 2 ++ docker-compose.sqlite.test.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/docker-compose.mysql.test.yml b/docker-compose.mysql.test.yml index fa84529..a7f6333 100644 --- a/docker-compose.mysql.test.yml +++ b/docker-compose.mysql.test.yml @@ -43,8 +43,10 @@ services: - MYSQL_PASS=${PDNS_DB_PASSWORD} - MYSQL_DNSSEC=no # PDNS Config + - PDNS_LOG_DNS_QUERIES=yes - PDNS_API=yes - PDNS_API_KEY=${PDNS_API_KEY} + - PDNS_WEBSERVER=no - PDNS_WEBSERVER_ADDRESS=0.0.0.0 - PDNS_WEBSERVER_PORT=8081 - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 diff --git a/docker-compose.postgres.test.yml b/docker-compose.postgres.test.yml index 57dc44b..b1af87e 100644 --- a/docker-compose.postgres.test.yml +++ b/docker-compose.postgres.test.yml @@ -42,8 +42,10 @@ services: - PGSQL_PASS=${PDNS_DB_PASSWORD} - PGSQL_DNSSEC=no # PDNS Config + - PDNS_LOG_DNS_QUERIES=yes - PDNS_API=yes - PDNS_API_KEY=${PDNS_API_KEY} + - PDNS_WEBSERVER=no - PDNS_WEBSERVER_ADDRESS=0.0.0.0 - PDNS_WEBSERVER_PORT=8081 - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 diff --git a/docker-compose.sqlite.test.yml b/docker-compose.sqlite.test.yml index d44413e..7031754 100644 --- a/docker-compose.sqlite.test.yml +++ b/docker-compose.sqlite.test.yml @@ -38,8 +38,10 @@ services: - SQLITE_DB=/srv/pdns/db/${PDNS_DB_NAME} - SQLITE_DNSSEC=no # PDNS Config + - PDNS_LOG_DNS_QUERIES=yes - PDNS_API=yes - PDNS_API_KEY=${PDNS_API_KEY} + - PDNS_WEBSERVER=no - PDNS_WEBSERVER_ADDRESS=0.0.0.0 - PDNS_WEBSERVER_PORT=8081 - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 From 0211fa78fbf3cb46066353a5ed01d7bceeefca4b Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Fri, 29 May 2020 04:02:51 +0200 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=92=9A=20Rename=20containers=20and=20?= =?UTF-8?q?networks=20to=20be=20unique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mathieu.brunot --- .travis.yml | 11 ++++++++--- docker-compose.mysql.test.yml | 18 +++++++++--------- docker-compose.postgres.test.yml | 18 ++++++++++-------- docker-compose.sqlite.test.yml | 16 ++++++++-------- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 98cefb4..23a5720 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_install: - env | sort - export VCS_REF=`git rev-parse --short HEAD` - export BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` - - export CONTAINER_NAME="pdns-server" + - export CONTAINER_NAME="pdns-server-${AUTOCONF}" - export TAG=travis - export IMAGE_NAME="psitrax/powerdns:${TAG}" - export home=$(pwd) @@ -30,14 +30,14 @@ before_script: script: - cd "$travis_dir" - # Test container run + # Test docker run - docker run --rm --name "cmd_help" -e AUTOCONF=$AUTOCONF "${IMAGE_NAME}" --help #- docker run --rm --name "cmd_version" -e AUTOCONF=$AUTOCONF "${IMAGE_NAME}" --version - docker run --name "${CONTAINER_NAME}" -e AUTOCONF=$AUTOCONF -d "${IMAGE_NAME}" - docker ps | grep "${CONTAINER_NAME}" - docker logs "${CONTAINER_NAME}" - docker stop "${CONTAINER_NAME}" && docker rm -f "${CONTAINER_NAME}" - # Docker-compose tests + # Test docker-compose run - mv docker-compose.$AUTOCONF.test.yml docker-compose.yml - rm -f docker-compose_*.yml - travis_retry travis_wait 60 docker-compose build @@ -50,12 +50,17 @@ script: - docker-compose ps - docker-compose logs - docker-compose ps "${CONTAINER_NAME}" | grep "Up" + - docker-compose logs "sut" + - docker-compose ps "sut" | grep "Exit 0" + # Test docker-compose restart - docker-compose down - travis_retry docker-compose up -d && sleep 30 - echo 'Wait until everything ready (1-2 minutes)' && sleep 120 - docker-compose ps - docker-compose logs - docker-compose ps "${CONTAINER_NAME}" | grep "Up" + - docker-compose logs "sut" + - docker-compose ps "sut" | grep "Exit 0" notifications: email: false diff --git a/docker-compose.mysql.test.yml b/docker-compose.mysql.test.yml index a7f6333..a645020 100644 --- a/docker-compose.mysql.test.yml +++ b/docker-compose.mysql.test.yml @@ -8,27 +8,27 @@ services: dockerfile: Dockerfile command: sh /docker_test.sh depends_on: - - pdns-server + - pdns-server-mysql - pdns-mysql environment: # Tests setup - - PING_CONTAINER=pdns-server + - PING_CONTAINER=pdns-server-mysql volumes_from: - - pdns-server + - pdns-server-mysql volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro - pdns-server: + pdns-server-mysql: build: . image: ${IMAGE_NAME} hostname: ${PDNS_HOST} - container_name: ${PDNS_HOST} + container_name: pdns-server-mysql ports: - "5053:53" - "5053:53/udp" networks: - - default + - pdns-compose-mysql volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro @@ -50,7 +50,7 @@ services: - PDNS_WEBSERVER_ADDRESS=0.0.0.0 - PDNS_WEBSERVER_PORT=8081 - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 - - PDNS_SOA_REFRESH_DEFAULT=14400 + - PDNS_SOA_REFRESH_pdns-compose-mysql=14400 depends_on: pdns-mysql: condition: service_healthy @@ -68,7 +68,7 @@ services: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro networks: - - default + - pdns-compose-mysql command: --character_set_client=utf8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --character-set-client-handshake=FALSE environment: - MYSQL_DATABASE=${PDNS_DB_NAME} @@ -81,7 +81,7 @@ services: retries: 5 networks: - default: + pdns-compose-mysql: volumes: powerdns-mysql-data: diff --git a/docker-compose.postgres.test.yml b/docker-compose.postgres.test.yml index b1af87e..26961ee 100644 --- a/docker-compose.postgres.test.yml +++ b/docker-compose.postgres.test.yml @@ -8,27 +8,27 @@ services: dockerfile: Dockerfile command: sh /docker_test.sh depends_on: - - pdns-server + - pdns-server-postgres - pdns-postgresql environment: # Tests setup - - PING_CONTAINER=pdns-server + - PING_CONTAINER=pdns-server-postgres volumes_from: - - pdns-server + - pdns-server-postgres volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro - pdns-server: + pdns-server-postgres: build: . image: ${IMAGE_NAME} hostname: ${PDNS_HOST} - container_name: ${PDNS_HOST} + container_name: pdns-server-postgres ports: - "5053:53" - "5053:53/udp" networks: - - default + - pdns-compose-pgsql volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro @@ -49,7 +49,7 @@ services: - PDNS_WEBSERVER_ADDRESS=0.0.0.0 - PDNS_WEBSERVER_PORT=8081 - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 - - PDNS_SOA_REFRESH_DEFAULT=14400 + - PDNS_SOA_REFRESH_pdns-compose-pgsql=14400 depends_on: - pdns-postgresql @@ -58,6 +58,8 @@ services: hostname: pdns-postgresql container_name: pdns-postgresql restart: always + expose: + - 5432 environment: - POSTGRES_DB=${PDNS_DB_NAME} - POSTGRES_USER=${PDNS_DB_USER} @@ -70,7 +72,7 @@ services: - /etc/timezone:/etc/timezone:ro networks: - default: + pdns-compose-pgsql: volumes: powerdns-postgresql-data: diff --git a/docker-compose.sqlite.test.yml b/docker-compose.sqlite.test.yml index 7031754..0591cce 100644 --- a/docker-compose.sqlite.test.yml +++ b/docker-compose.sqlite.test.yml @@ -8,26 +8,26 @@ services: dockerfile: Dockerfile command: sh /docker_test.sh depends_on: - - pdns-server + - pdns-server-sqlite environment: # Tests setup - - PING_CONTAINER=pdns-server + - PING_CONTAINER=pdns-server-sqlite volumes_from: - - pdns-server + - pdns-server-sqlite volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro - pdns-server: + pdns-server-sqlite: build: . image: ${IMAGE_NAME} hostname: ${PDNS_HOST} - container_name: ${PDNS_HOST} + container_name: pdns-server-sqlite ports: - "5053:53" - "5053:53/udp" networks: - - default + - pdns-compose-sqlite volumes: - powerdns-sqlite-data:/srv/pdns/db - /etc/localtime:/etc/localtime:ro @@ -45,10 +45,10 @@ services: - PDNS_WEBSERVER_ADDRESS=0.0.0.0 - PDNS_WEBSERVER_PORT=8081 - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 - - PDNS_SOA_REFRESH_DEFAULT=14400 + - PDNS_SOA_REFRESH_pdns-compose-sqlite=14400 networks: - default: + pdns-compose-sqlite: volumes: powerdns-sqlite-data: From d5a36b7182a5007e09b628d22c42fa0f0622965d Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Fri, 29 May 2020 04:47:29 +0200 Subject: [PATCH 7/8] =?UTF-8?q?=F0=9F=92=9A=20Fix=20compose=20networks=20a?= =?UTF-8?q?nd=20env=20vars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mathieu.brunot --- docker-compose.mysql.test.yml | 6 +++++- docker-compose.postgres.test.yml | 6 +++++- docker-compose.sqlite.test.yml | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docker-compose.mysql.test.yml b/docker-compose.mysql.test.yml index a645020..92a125a 100644 --- a/docker-compose.mysql.test.yml +++ b/docker-compose.mysql.test.yml @@ -15,6 +15,8 @@ services: - PING_CONTAINER=pdns-server-mysql volumes_from: - pdns-server-mysql + networks: + - pdns-compose-mysql volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro @@ -50,7 +52,7 @@ services: - PDNS_WEBSERVER_ADDRESS=0.0.0.0 - PDNS_WEBSERVER_PORT=8081 - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 - - PDNS_SOA_REFRESH_pdns-compose-mysql=14400 + - PDNS_SOA_REFRESH_DEFAULT=14400 depends_on: pdns-mysql: condition: service_healthy @@ -63,6 +65,8 @@ services: memswap_limit: 256M expose: - 3306 + networks: + - pdns-compose-mysql volumes: - powerdns-mysql-data:/var/lib/mysql - /etc/localtime:/etc/localtime:ro diff --git a/docker-compose.postgres.test.yml b/docker-compose.postgres.test.yml index 26961ee..d4ac505 100644 --- a/docker-compose.postgres.test.yml +++ b/docker-compose.postgres.test.yml @@ -15,6 +15,8 @@ services: - PING_CONTAINER=pdns-server-postgres volumes_from: - pdns-server-postgres + networks: + - pdns-compose-pgsql volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro @@ -49,7 +51,7 @@ services: - PDNS_WEBSERVER_ADDRESS=0.0.0.0 - PDNS_WEBSERVER_PORT=8081 - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 - - PDNS_SOA_REFRESH_pdns-compose-pgsql=14400 + - PDNS_SOA_REFRESH_DEFAULT=14400 depends_on: - pdns-postgresql @@ -60,6 +62,8 @@ services: restart: always expose: - 5432 + networks: + - pdns-compose-pgsql environment: - POSTGRES_DB=${PDNS_DB_NAME} - POSTGRES_USER=${PDNS_DB_USER} diff --git a/docker-compose.sqlite.test.yml b/docker-compose.sqlite.test.yml index 0591cce..51bf9f3 100644 --- a/docker-compose.sqlite.test.yml +++ b/docker-compose.sqlite.test.yml @@ -14,6 +14,8 @@ services: - PING_CONTAINER=pdns-server-sqlite volumes_from: - pdns-server-sqlite + networks: + - pdns-compose-sqlite volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro @@ -45,7 +47,7 @@ services: - PDNS_WEBSERVER_ADDRESS=0.0.0.0 - PDNS_WEBSERVER_PORT=8081 - PDNS_WEBSERVER_ALLOW_FROM=${PDNS_WEBSERVER_ALLOW_FROM}/0 - - PDNS_SOA_REFRESH_pdns-compose-sqlite=14400 + - PDNS_SOA_REFRESH_DEFAULT=14400 networks: pdns-compose-sqlite: From 55fb9536a14d475dbc081d498fd834a2f64604aa Mon Sep 17 00:00:00 2001 From: "mathieu.brunot" Date: Sat, 30 May 2020 02:31:45 +0200 Subject: [PATCH 8/8] =?UTF-8?q?=F0=9F=92=9A=20Do=20not=20open=20map=20port?= =?UTF-8?q?s=20on=20host?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mathieu.brunot --- docker-compose.mysql.test.yml | 7 ++++--- docker-compose.postgres.test.yml | 7 ++++--- docker-compose.sqlite.test.yml | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docker-compose.mysql.test.yml b/docker-compose.mysql.test.yml index 92a125a..f82648e 100644 --- a/docker-compose.mysql.test.yml +++ b/docker-compose.mysql.test.yml @@ -26,9 +26,10 @@ services: image: ${IMAGE_NAME} hostname: ${PDNS_HOST} container_name: pdns-server-mysql - ports: - - "5053:53" - - "5053:53/udp" + # If ports need to be redirected or exposed to host + #ports: + # - "5053:53" + # - "5053:53/udp" networks: - pdns-compose-mysql volumes: diff --git a/docker-compose.postgres.test.yml b/docker-compose.postgres.test.yml index d4ac505..308642f 100644 --- a/docker-compose.postgres.test.yml +++ b/docker-compose.postgres.test.yml @@ -26,9 +26,10 @@ services: image: ${IMAGE_NAME} hostname: ${PDNS_HOST} container_name: pdns-server-postgres - ports: - - "5053:53" - - "5053:53/udp" + # If ports need to be redirected or exposed to host + #ports: + # - "5053:53" + # - "5053:53/udp" networks: - pdns-compose-pgsql volumes: diff --git a/docker-compose.sqlite.test.yml b/docker-compose.sqlite.test.yml index 51bf9f3..ea77b20 100644 --- a/docker-compose.sqlite.test.yml +++ b/docker-compose.sqlite.test.yml @@ -25,9 +25,10 @@ services: image: ${IMAGE_NAME} hostname: ${PDNS_HOST} container_name: pdns-server-sqlite - ports: - - "5053:53" - - "5053:53/udp" + # If ports need to be redirected or exposed to host + #ports: + # - "5053:53" + # - "5053:53/udp" networks: - pdns-compose-sqlite volumes: