From c2e7b6f2d282bd8b8eadd7b754ab09e936ffcdae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20B=C3=B6hm?= Date: Tue, 28 Nov 2017 22:26:59 +0100 Subject: [PATCH] prepare docker setup for http remote backend --- docker/ddns/Dockerfile | 6 ++++-- docker/docker-compose.yml | 25 +++++-------------------- docker/powerdns/Dockerfile | 4 ++-- docker/powerdns/entrypoint.sh | 4 +--- docker/powerdns/pdns.conf | 5 ++--- docker/web/Dockerfile | 6 ------ web/template.go | 4 ++-- 7 files changed, 16 insertions(+), 38 deletions(-) delete mode 100644 docker/web/Dockerfile diff --git a/docker/ddns/Dockerfile b/docker/ddns/Dockerfile index 2b2bfaa..e51e786 100644 --- a/docker/ddns/Dockerfile +++ b/docker/ddns/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.7 +FROM golang:1.9 WORKDIR /go/src/github.com/pboehm/ddns COPY . . @@ -6,4 +6,6 @@ COPY . . RUN go-wrapper download # "go get -d -v ./..." RUN go-wrapper install # "go install -v ." -CMD ["/bin/true"] +ENV GIN_MODE release + +CMD /go/bin/ddns --domain=${DDNS_DOMAIN} --soa_fqdn=${DDNS_SOA_DOMAIN} --redis=redis:6379 web diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 75e6606..0685d5d 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,42 +1,27 @@ version: '2' -volumes: - ddns: - services: ddns: + restart: unless-stopped build: context: .. dockerfile: docker/ddns/Dockerfile - volumes: - - ddns:/go/bin/ - - ddns-web: - restart: unless-stopped - build: - context: web/ - dockerfile: Dockerfile depends_on: - redis - volumes_from: - - ddns environment: DDNS_DOMAIN: d.example.net + DDNS_SOA_DOMAIN: soa.example.net - ddns-powerdns: + powerdns: restart: unless-stopped build: context: powerdns/ dockerfile: Dockerfile depends_on: - - redis - volumes_from: - ddns environment: - DDNS_DOMAIN: d.example.net - DDNS_SOA_DOMAIN: soa.example.net - DDNS_VERBOSE: --verbose + PDNS_REMOTE_HTTP_HOST: "ddns:8080" redis: restart: unless-stopped - image: redis:latest \ No newline at end of file + image: redis:4-alpine \ No newline at end of file diff --git a/docker/powerdns/Dockerfile b/docker/powerdns/Dockerfile index af138e5..e560109 100644 --- a/docker/powerdns/Dockerfile +++ b/docker/powerdns/Dockerfile @@ -2,11 +2,11 @@ FROM buildpack-deps:jessie-scm MAINTAINER Philipp Böhm # the setup procedure according to https://repo.powerdns.com/ (Debian 8 Jessie) -RUN echo "deb http://repo.powerdns.com/debian jessie-auth-40 main" > /etc/apt/sources.list.d/pdns.list \ +RUN echo "deb http://repo.powerdns.com/debian jessie-auth-41 main" > /etc/apt/sources.list.d/pdns.list \ && echo "Package: pdns-*\nPin: origin repo.powerdns.com\nPin-Priority: 600\n" >> /etc/apt/preferences.d/pdns \ && curl https://repo.powerdns.com/FD380FBB-pub.asc | apt-key add - \ && apt-get -y update \ - && apt-get install -y pdns-server pdns-backend-pipe \ + && apt-get install -y pdns-server pdns-backend-remote \ && rm -rf /var/lib/apt/lists/* COPY pdns.conf /etc/powerdns/pdns.conf diff --git a/docker/powerdns/entrypoint.sh b/docker/powerdns/entrypoint.sh index 3070000..da767ff 100644 --- a/docker/powerdns/entrypoint.sh +++ b/docker/powerdns/entrypoint.sh @@ -2,8 +2,6 @@ CONFIG_FILE=/etc/powerdns/pdns.conf -sed -i 's/{{DDNS_DOMAIN}}/'"${DDNS_DOMAIN}"'/g' ${CONFIG_FILE} -sed -i 's/{{DDNS_SOA_DOMAIN}}/'"${DDNS_SOA_DOMAIN}"'/g' ${CONFIG_FILE} -sed -i 's/{{DDNS_VERBOSE}}/'"${DDNS_VERBOSE}"'/g' ${CONFIG_FILE} +sed -i 's/{{PDNS_REMOTE_HTTP_HOST}}/'"${PDNS_REMOTE_HTTP_HOST}"'/g' ${CONFIG_FILE} exec "$@" \ No newline at end of file diff --git a/docker/powerdns/pdns.conf b/docker/powerdns/pdns.conf index 367baa3..0ddb6ec 100644 --- a/docker/powerdns/pdns.conf +++ b/docker/powerdns/pdns.conf @@ -3,7 +3,6 @@ cache-ttl=0 loglevel=7 log-dns-details=yes disable-axfr=yes -pipe-abi-version=1 -launch=pipe -pipe-command=/go/bin/ddns --domain={{DDNS_DOMAIN}} --soa_fqdn={{DDNS_SOA_DOMAIN}} --redis=redis:6379 {{DDNS_VERBOSE}} backend \ No newline at end of file +launch=remote +remote-connection-string=http:url=http://{{PDNS_REMOTE_HTTP_HOST}}/dnsapi \ No newline at end of file diff --git a/docker/web/Dockerfile b/docker/web/Dockerfile deleted file mode 100644 index 9ec1003..0000000 --- a/docker/web/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM buildpack-deps:jessie-scm -MAINTAINER Philipp Böhm - -ENV GIN_MODE release - -CMD /go/bin/ddns --domain=${DDNS_DOMAIN} --redis=redis:6379 web diff --git a/web/template.go b/web/template.go index bb2b1cd..94424a9 100644 --- a/web/template.go +++ b/web/template.go @@ -168,7 +168,7 @@ const indexTemplate string = ` function validate() { var hostname = $('#hostname').val(); - $.getJSON("/available/" + hostname + "/", function( data ) { + $.getJSON("/available/" + hostname, function( data ) { if (data.available) { isValid(); } else { @@ -188,7 +188,7 @@ const indexTemplate string = ` $('#register').click(function() { var hostname = $("#hostname").val(); - $.getJSON("/new/" + hostname + "/", function( data ) { + $.getJSON("/new/" + hostname, function( data ) { console.log(data); var host = location.protocol + '//' + location.host;