From 93fd59ade3e01eab895f267e427b125d829cec97 Mon Sep 17 00:00:00 2001 From: p1c2u Date: Mon, 7 Aug 2023 16:05:55 +0100 Subject: [PATCH 1/6] Make dnsdock great again --- .travis.yml | 49 -------------------- Dockerfile | 42 +++++++++++++++++ Godeps/Godeps.json | 2 +- Makefile | 5 +++ Rockerfile | 85 ----------------------------------- docker-compose.yml | 19 ++++---- readme.md | 20 ++++----- src/core/cmdline.go | 2 +- src/core/docker.go | 4 +- src/core/docker_test.go | 2 +- src/main.go | 6 +-- src/servers/dnsserver.go | 2 +- src/servers/dnsserver_test.go | 2 +- src/servers/http.go | 2 +- src/servers/http_test.go | 2 +- 15 files changed, 78 insertions(+), 166 deletions(-) delete mode 100644 .travis.yml create mode 100644 Dockerfile create mode 100644 Makefile delete mode 100644 Rockerfile diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d45db6d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -sudo: required -language: c - -services: - - docker - -before_install: - - sudo apt-get update - - sudo apt-get install -qy docker-engine - - wget https://github.com/grammarly/rocker/releases/download/1.3.0/rocker_linux_amd64.tar.gz -O /tmp/rocker.tar.gz - - sudo tar -xvzf /tmp/rocker.tar.gz -C /usr/local/bin && sudo chmod +x /usr/local/bin/rocker - - sudo mkdir -m 777 -p /build/amd64 /build/arm - -script: - - if git describe --contains ${TRAVIS_COMMIT} &>/dev/null; then export VERSIONARGS="-var DOCKERIMAGE_VERSION=`git describe --contains ${TRAVIS_COMMIT}`"; else unset VERSIONARGS; fi - - if git describe --contains ${TRAVIS_COMMIT} &>/dev/null; then export VERSION="`git describe --contains ${TRAVIS_COMMIT}`"; else unset VERSION; fi - - rocker build --no-cache ${VERSIONARGS} -var GIT_COMMIT=${TRAVIS_COMMIT} -var OUTPUT_DIR=/build/amd64 -var ARCH=amd64 . - - rocker build --no-cache ${VERSIONARGS} -var GIT_COMMIT=${TRAVIS_COMMIT} -var OUTPUT_DIR=/build/arm -var ARCH=arm . - -after_success: - - sudo mv /build/amd64/dnsdock /build/dnsdock.amd64 - - sudo mv /build/arm/dnsdock /build/dnsdock.arm - - sudo chmod -R a+rw /build - - echo "docker login -u $DOCKER_USER -p $DOCKER_PASSWORD" >> /tmp/deploy_containers.sh - - echo "docker push aacebedo/dnsdock:latest-amd64" >> /tmp/deploy_containers.sh - - echo "docker push aacebedo/dnsdock:latest-arm" >> /tmp/deploy_containers.sh - - echo "docker push aacebedo/dnsdock:$VERSION-amd64" >> /tmp/deploy_containers.sh - - echo "docker push aacebedo/dnsdock:$VERSION-arm" >> /tmp/deploy_containers.sh - - sudo chmod a+rx /tmp/deploy_containers.sh - -deploy: - - provider: releases - skip_cleanup: true - api-key: - secure: $GITHUB_TOKEN - file: /build/dnsdock.amd64 - on: - tags: true - - provider: releases - skip_cleanup: true - api-key: - secure: $GITHUB_TOKEN - file: /build/dnsdock.arm - on: - tags: true - - provider: script - script: /tmp/deploy_containers.sh - on: - tags: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cec7176 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM alpine:3.6 AS builder + +ARG GOLANG_VERSION=1.8.4-r0 + +RUN apk update +RUN apk add go=${GOLANG_VERSION} go-tools=${GOLANG_VERSION} git musl-dev +RUN go version + +ENV GOPATH=/go +ENV PATH=${PATH}:/go/bin +ENV CGO_ENABLED=0 + +RUN go get -v github.com/tools/godep +# RUN go get -u github.com/golang/lint/golint +RUN go get github.com/ahmetb/govvv + +RUN mkdir -p /go/src/github.com/p1c2u/dnsdock + +WORKDIR /go/src/github.com/p1c2u/dnsdock + +RUN git clone https://github.com/p1c2u/dnsdock /go/src/github.com/p1c2u/dnsdock +# RUN git checkout {{$GIT_COMMIT}} + +RUN mkdir /tmp/output + +WORKDIR /go/src/github.com/p1c2u/dnsdock + +ENV GIT_SSL_NO_VERIFY=true + +RUN godep restore + +ENV GOARCH=arm64 + +WORKDIR /go/src/github.com/p1c2u/dnsdock/src + +RUN govvv build -o /tmp/output/dnsdock + +FROM alpine:3.18.2 + +COPY --from=builder /tmp/output/dnsdock /bin/dnsdock + +ENTRYPOINT ["dnsdock"] diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index fcab44a..5078d21 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,5 +1,5 @@ { - "ImportPath": "github.com/aacebedo/dnsdock", + "ImportPath": "github.com/p1c2u/dnsdock", "GoVersion": "go1.6", "GodepVersion": "v74", "Packages": [ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bb70c22 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +build: + docker build -t dnsdock:latest . + +build-test: + docker build -t dnsdock:test . --progress=plain --no-cache diff --git a/Rockerfile b/Rockerfile deleted file mode 100644 index d434782..0000000 --- a/Rockerfile +++ /dev/null @@ -1,85 +0,0 @@ -# This file is part of DNSDock -# MIT -# -# Copyright (C) 2014 Tõnis Tiigi -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -{{$GOLANG_VERSION := "1.6.3"}} -{{$ARCH:= (or .ARCH "amd64")}} -{{$GIT_COMMIT:= (or .GIT_COMMIT "develop")}} -{{$DOCKERIMAGE_VERSION:= (or .DOCKERIMAGE_VERSION "dev")}} -{{$SRC_DIR:= (or .SRC_DIR ".")}} - -# build image -FROM alpine:3.4 -RUN apk update -RUN apk upgrade -RUN apk add go>{{$GOLANG_VERSION}} go-tools>{{$GOLANG_VERSION}} git musl-dev - -ENV GOPATH=/go -ENV PATH=${PATH}:/go/bin -ENV CGO_ENABLED=0 - -RUN go get -v github.com/tools/godep -RUN go get -u github.com/golang/lint/golint -RUN go get github.com/ahmetb/govvv - -RUN mkdir -p /go/src/github.com/aacebedo/dnsdock -WORKDIR /go/src/github.com/aacebedo/dnsdock -{{if .SRC_DIR}} - MOUNT {{$SRC_DIR}}:/go/src/github.com/aacebedo/dnsdock -{{else}} - RUN git clone https://github.com/aacebedo/dnsdock /go/src/github.com/aacebedo/dnsdock - RUN git checkout {{$GIT_COMMIT}} -{{end}} - -{{if .OUTPUT_DIR}} - MOUNT {{.OUTPUT_DIR}}:/tmp/output -{{else}} - RUN mkdir /tmp/output -{{end}} - -WORKDIR /go/src/github.com/aacebedo/dnsdock -RUN godep restore -ENV GOARCH={{$ARCH}} -WORKDIR /go/src/github.com/aacebedo/dnsdock/src -ATTACH sh -RUN govvv build -o /tmp/output/dnsdock -RUN golint -set_exit_status -{{if eq $ARCH "amd64"}} -RUN go vet -RUN go test ./... -{{end}} -TAG aacebedo/dnsdock-devenv:latest-{{$ARCH}} -EXPORT /tmp/output/dnsdock ./dnsdock - -# run image -{{if eq $ARCH "amd64"}} -FROM alpine -{{else}} -FROM easypi/alpine-arm -{{end}} -IMPORT ./dnsdock /bin/dnsdock -ENTRYPOINT ["dnsdock"] -TAG aacebedo/dnsdock:{{$DOCKERIMAGE_VERSION}}-{{$ARCH}} - -{{if ne $DOCKERIMAGE_VERSION "dev"}} -TAG aacebedo/dnsdock:latest-{{$ARCH}} -{{end}} diff --git a/docker-compose.yml b/docker-compose.yml index dede735..cb111f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,9 @@ -# /var/run/docker.sock does not seem to be available for fig -# for this reason we violate LFHS and add the socket directly on /run -dnsdock: - image: conz27/dnsdock - container_name: dnsdock - command: -nameserver 192.168.0.1:53 -nameserver 8.8.8.8:53 - volumes: - - /var/run/docker.sock:/run/docker.sock - ports: - - 172.17.0.0:53:53/udp +services: + dnsdock: + image: p1c2u/dnsdock + container_name: dnsdock + command: -nameserver 192.168.0.1:53 -nameserver 8.8.8.8:53 + volumes: + - /var/run/docker.sock:/run/docker.sock + ports: + - 172.17.0.0:53:53/udp diff --git a/readme.md b/readme.md index a547c79..195aa21 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -[![Build Status](https://secure.travis-ci.org/aacebedo/dnsdock.png)](http://travis-ci.org/aacebedo/dnsdock) +[![Build Status](https://secure.travis-ci.org/p1c2u/dnsdock.png)](http://travis-ci.org/p1c2u/dnsdock) ## dnsdock @@ -48,10 +48,10 @@ Install a golang development environment on your host and type the following com export GOPATH=/tmp/go export PATH=${PATH}:${GOPATH}/bin go get -v github.com/tools/godep -go get -d -v https://github.com/aacebedo/dnsdock -cd ${GOPATH}/src/github.com/aacebedo/dnsdock +go get -d -v https://github.com/p1c2u/dnsdock +cd ${GOPATH}/src/github.com/p1c2u/dnsdock godep restore -cd ${GOPATH}/src/github.com/aacebedo/dnsdock/src +cd ${GOPATH}/src/github.com/p1c2u/dnsdock/src go build -o ${GOPATH}/bin/dnsdock ``` @@ -60,7 +60,7 @@ go build -o ${GOPATH}/bin/dnsdock To build with docker you need [rocker](https://github.com/grammarly/rocker). Check the website to install it and type the following commands: ``` -git clone https://github.com/aacebedo/dnsdock +git clone https://github.com/p1c2u/dnsdock rocker build -var ARCH=[amd64|arm] -var OUTPUT_DIR= ``` @@ -123,7 +123,7 @@ Restart docker daemon after you have done that (`sudo service docker restart`). Now you only need to run the dnsdock container: ``` -docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p 172.17.0.1:53:53/udp aacebedo/dnsdock [--opts] +docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p 172.17.0.1:53:53/udp p1c2u/dnsdock [--opts] ``` - `-d` starts container as daemon @@ -159,7 +159,7 @@ If you also want to let the host machine discover the containers add `nameserver Mounting docker daemon's unix socket may not work with default configuration on these platforms. Please use [selinux-dockersock](https://github.com/dpw/selinux-dockersock) to fix this. -More information in [#11](https://github.com/aacebedo/dnsdock/issues/11). +More information in [#11](https://github.com/p1c2u/dnsdock/issues/11). #### TLS Authentication @@ -174,7 +174,7 @@ and the `DOCKER_CERTS` to a directory containing files named `ca.pem`, You may build this into your own container with this example Dockerfile: ``` -FROM aacebedo/dnsdock +FROM p1c2u/dnsdock ENV DOCKER_TLS_VERIFY 1 ENV DOCKER_CERTS /certs @@ -314,8 +314,8 @@ Add the following snippet under the `units` part: [Service] EnvironmentFile=/etc/environment ExecStartPre=/bin/sh -c '/usr/bin/docker rm -f dnsdock || ls > /dev/null' - ExecStartPre=/bin/sh -c '/usr/bin/docker pull aacebedo/dnsdock' - ExecStart=/usr/bin/docker run -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p ${COREOS_PRIVATE_IPV4}:53:53/udp aacebedo/dnsdock + ExecStartPre=/bin/sh -c '/usr/bin/docker pull p1c2u/dnsdock' + ExecStart=/usr/bin/docker run -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p ${COREOS_PRIVATE_IPV4}:53:53/udp p1c2u/dnsdock ExecStop=/bin/sh -c '/usr/bin/docker stop dnsdock || ls > /dev/null' ``` diff --git a/src/core/cmdline.go b/src/core/cmdline.go index 0e2f634..10155a4 100644 --- a/src/core/cmdline.go +++ b/src/core/cmdline.go @@ -10,7 +10,7 @@ package core import ( "fmt" - "github.com/aacebedo/dnsdock/src/utils" + "github.com/p1c2u/dnsdock/src/utils" "gopkg.in/alecthomas/kingpin.v2" "strconv" ) diff --git a/src/core/docker.go b/src/core/docker.go index 10885b7..d45494e 100644 --- a/src/core/docker.go +++ b/src/core/docker.go @@ -11,8 +11,8 @@ package core import ( "crypto/tls" "errors" - "github.com/aacebedo/dnsdock/src/servers" - "github.com/aacebedo/dnsdock/src/utils" + "github.com/p1c2u/dnsdock/src/servers" + "github.com/p1c2u/dnsdock/src/utils" "github.com/docker/engine-api/client" "github.com/docker/engine-api/types" eventtypes "github.com/docker/engine-api/types/events" diff --git a/src/core/docker_test.go b/src/core/docker_test.go index f624b65..1a5e5b6 100644 --- a/src/core/docker_test.go +++ b/src/core/docker_test.go @@ -9,7 +9,7 @@ package core import ( - "github.com/aacebedo/dnsdock/src/servers" + "github.com/p1c2u/dnsdock/src/servers" "reflect" "testing" ) diff --git a/src/main.go b/src/main.go index 538d887..0f17448 100644 --- a/src/main.go +++ b/src/main.go @@ -11,9 +11,9 @@ package main import ( "crypto/tls" "crypto/x509" - "github.com/aacebedo/dnsdock/src/core" - "github.com/aacebedo/dnsdock/src/servers" - "github.com/aacebedo/dnsdock/src/utils" + "github.com/p1c2u/dnsdock/src/core" + "github.com/p1c2u/dnsdock/src/servers" + "github.com/p1c2u/dnsdock/src/utils" "github.com/op/go-logging" "io/ioutil" "os" diff --git a/src/servers/dnsserver.go b/src/servers/dnsserver.go index 03a0437..25c57a2 100644 --- a/src/servers/dnsserver.go +++ b/src/servers/dnsserver.go @@ -11,7 +11,7 @@ package servers import ( "errors" "fmt" - "github.com/aacebedo/dnsdock/src/utils" + "github.com/p1c2u/dnsdock/src/utils" "github.com/miekg/dns" "net" "regexp" diff --git a/src/servers/dnsserver_test.go b/src/servers/dnsserver_test.go index 2ec748a..42e39c4 100644 --- a/src/servers/dnsserver_test.go +++ b/src/servers/dnsserver_test.go @@ -9,7 +9,7 @@ package servers import ( - "github.com/aacebedo/dnsdock/src/utils" + "github.com/p1c2u/dnsdock/src/utils" "github.com/miekg/dns" "net" "strings" diff --git a/src/servers/http.go b/src/servers/http.go index 14ff203..bd2bc06 100644 --- a/src/servers/http.go +++ b/src/servers/http.go @@ -10,7 +10,7 @@ package servers import ( "encoding/json" - "github.com/aacebedo/dnsdock/src/utils" + "github.com/p1c2u/dnsdock/src/utils" "github.com/gorilla/mux" "net/http" ) diff --git a/src/servers/http_test.go b/src/servers/http_test.go index 97a44b3..470603e 100644 --- a/src/servers/http_test.go +++ b/src/servers/http_test.go @@ -9,7 +9,7 @@ package servers import ( - "github.com/aacebedo/dnsdock/src/utils" + "github.com/p1c2u/dnsdock/src/utils" "io/ioutil" "net/http" "strings" From 022eba5c4bae3a3c2e323b33c0c251185c7825c7 Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Sun, 21 Jan 2024 22:30:50 +0200 Subject: [PATCH 2/6] change docker api version --- Dockerfile | 10 +++++----- Godeps/Godeps.json | 2 +- docker-compose.yml | 2 +- readme.md | 20 ++++++++++---------- src/core/cmdline.go | 2 +- src/core/docker.go | 6 +++--- src/core/docker_test.go | 2 +- src/main.go | 6 +++--- src/servers/dnsserver.go | 2 +- src/servers/dnsserver_test.go | 2 +- src/servers/http.go | 2 +- src/servers/http_test.go | 2 +- 12 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index cec7176..3665d37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,16 +14,16 @@ RUN go get -v github.com/tools/godep # RUN go get -u github.com/golang/lint/golint RUN go get github.com/ahmetb/govvv -RUN mkdir -p /go/src/github.com/p1c2u/dnsdock +RUN mkdir -p /go/src/github.com/dz3n/dnsdock -WORKDIR /go/src/github.com/p1c2u/dnsdock +WORKDIR /go/src/github.com/dz3n/dnsdock -RUN git clone https://github.com/p1c2u/dnsdock /go/src/github.com/p1c2u/dnsdock +RUN git clone https://github.com/dz3n/dnsdock /go/src/github.com/dz3n/dnsdock # RUN git checkout {{$GIT_COMMIT}} RUN mkdir /tmp/output -WORKDIR /go/src/github.com/p1c2u/dnsdock +WORKDIR /go/src/github.com/dz3n/dnsdock ENV GIT_SSL_NO_VERIFY=true @@ -31,7 +31,7 @@ RUN godep restore ENV GOARCH=arm64 -WORKDIR /go/src/github.com/p1c2u/dnsdock/src +WORKDIR /go/src/github.com/dz3n/dnsdock/src RUN govvv build -o /tmp/output/dnsdock diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 5078d21..491020a 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,5 +1,5 @@ { - "ImportPath": "github.com/p1c2u/dnsdock", + "ImportPath": "github.com/dz3n/dnsdock", "GoVersion": "go1.6", "GodepVersion": "v74", "Packages": [ diff --git a/docker-compose.yml b/docker-compose.yml index cb111f3..fbf2080 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: dnsdock: - image: p1c2u/dnsdock + image: dz3n/dnsdock container_name: dnsdock command: -nameserver 192.168.0.1:53 -nameserver 8.8.8.8:53 volumes: diff --git a/readme.md b/readme.md index 195aa21..bdde429 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -[![Build Status](https://secure.travis-ci.org/p1c2u/dnsdock.png)](http://travis-ci.org/p1c2u/dnsdock) +[![Build Status](https://secure.travis-ci.org/dz3n/dnsdock.png)](http://travis-ci.org/dz3n/dnsdock) ## dnsdock @@ -48,10 +48,10 @@ Install a golang development environment on your host and type the following com export GOPATH=/tmp/go export PATH=${PATH}:${GOPATH}/bin go get -v github.com/tools/godep -go get -d -v https://github.com/p1c2u/dnsdock -cd ${GOPATH}/src/github.com/p1c2u/dnsdock +go get -d -v https://github.com/dz3n/dnsdock +cd ${GOPATH}/src/github.com/dz3n/dnsdock godep restore -cd ${GOPATH}/src/github.com/p1c2u/dnsdock/src +cd ${GOPATH}/src/github.com/dz3n/dnsdock/src go build -o ${GOPATH}/bin/dnsdock ``` @@ -60,7 +60,7 @@ go build -o ${GOPATH}/bin/dnsdock To build with docker you need [rocker](https://github.com/grammarly/rocker). Check the website to install it and type the following commands: ``` -git clone https://github.com/p1c2u/dnsdock +git clone https://github.com/dz3n/dnsdock rocker build -var ARCH=[amd64|arm] -var OUTPUT_DIR= ``` @@ -123,7 +123,7 @@ Restart docker daemon after you have done that (`sudo service docker restart`). Now you only need to run the dnsdock container: ``` -docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p 172.17.0.1:53:53/udp p1c2u/dnsdock [--opts] +docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p 172.17.0.1:53:53/udp dz3n/dnsdock [--opts] ``` - `-d` starts container as daemon @@ -159,7 +159,7 @@ If you also want to let the host machine discover the containers add `nameserver Mounting docker daemon's unix socket may not work with default configuration on these platforms. Please use [selinux-dockersock](https://github.com/dpw/selinux-dockersock) to fix this. -More information in [#11](https://github.com/p1c2u/dnsdock/issues/11). +More information in [#11](https://github.com/dz3n/dnsdock/issues/11). #### TLS Authentication @@ -174,7 +174,7 @@ and the `DOCKER_CERTS` to a directory containing files named `ca.pem`, You may build this into your own container with this example Dockerfile: ``` -FROM p1c2u/dnsdock +FROM dz3n/dnsdock ENV DOCKER_TLS_VERIFY 1 ENV DOCKER_CERTS /certs @@ -314,8 +314,8 @@ Add the following snippet under the `units` part: [Service] EnvironmentFile=/etc/environment ExecStartPre=/bin/sh -c '/usr/bin/docker rm -f dnsdock || ls > /dev/null' - ExecStartPre=/bin/sh -c '/usr/bin/docker pull p1c2u/dnsdock' - ExecStart=/usr/bin/docker run -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p ${COREOS_PRIVATE_IPV4}:53:53/udp p1c2u/dnsdock + ExecStartPre=/bin/sh -c '/usr/bin/docker pull dz3n/dnsdock' + ExecStart=/usr/bin/docker run -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p ${COREOS_PRIVATE_IPV4}:53:53/udp dz3n/dnsdock ExecStop=/bin/sh -c '/usr/bin/docker stop dnsdock || ls > /dev/null' ``` diff --git a/src/core/cmdline.go b/src/core/cmdline.go index 10155a4..d38f410 100644 --- a/src/core/cmdline.go +++ b/src/core/cmdline.go @@ -10,7 +10,7 @@ package core import ( "fmt" - "github.com/p1c2u/dnsdock/src/utils" + "github.com/dz3n/dnsdock/src/utils" "gopkg.in/alecthomas/kingpin.v2" "strconv" ) diff --git a/src/core/docker.go b/src/core/docker.go index d45494e..d5cffc5 100644 --- a/src/core/docker.go +++ b/src/core/docker.go @@ -11,8 +11,8 @@ package core import ( "crypto/tls" "errors" - "github.com/p1c2u/dnsdock/src/servers" - "github.com/p1c2u/dnsdock/src/utils" + "github.com/dz3n/dnsdock/src/servers" + "github.com/dz3n/dnsdock/src/utils" "github.com/docker/engine-api/client" "github.com/docker/engine-api/types" eventtypes "github.com/docker/engine-api/types/events" @@ -35,7 +35,7 @@ type DockerManager struct { // NewDockerManager creates a new DockerManager func NewDockerManager(c *utils.Config, list servers.ServiceListProvider, tlsConfig *tls.Config) (*DockerManager, error) { defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"} - dclient, err := client.NewClient(c.DockerHost, "v1.22", nil, defaultHeaders) + dclient, err := client.NewClient(c.DockerHost, "v1.30", nil, defaultHeaders) if err != nil { return nil, err diff --git a/src/core/docker_test.go b/src/core/docker_test.go index 1a5e5b6..0f59a0b 100644 --- a/src/core/docker_test.go +++ b/src/core/docker_test.go @@ -9,7 +9,7 @@ package core import ( - "github.com/p1c2u/dnsdock/src/servers" + "github.com/dz3n/dnsdock/src/servers" "reflect" "testing" ) diff --git a/src/main.go b/src/main.go index 0f17448..f9eaff6 100644 --- a/src/main.go +++ b/src/main.go @@ -11,9 +11,9 @@ package main import ( "crypto/tls" "crypto/x509" - "github.com/p1c2u/dnsdock/src/core" - "github.com/p1c2u/dnsdock/src/servers" - "github.com/p1c2u/dnsdock/src/utils" + "github.com/dz3n/dnsdock/src/core" + "github.com/dz3n/dnsdock/src/servers" + "github.com/dz3n/dnsdock/src/utils" "github.com/op/go-logging" "io/ioutil" "os" diff --git a/src/servers/dnsserver.go b/src/servers/dnsserver.go index 25c57a2..b76da0f 100644 --- a/src/servers/dnsserver.go +++ b/src/servers/dnsserver.go @@ -11,7 +11,7 @@ package servers import ( "errors" "fmt" - "github.com/p1c2u/dnsdock/src/utils" + "github.com/dz3n/dnsdock/src/utils" "github.com/miekg/dns" "net" "regexp" diff --git a/src/servers/dnsserver_test.go b/src/servers/dnsserver_test.go index 42e39c4..f423189 100644 --- a/src/servers/dnsserver_test.go +++ b/src/servers/dnsserver_test.go @@ -9,7 +9,7 @@ package servers import ( - "github.com/p1c2u/dnsdock/src/utils" + "github.com/dz3n/dnsdock/src/utils" "github.com/miekg/dns" "net" "strings" diff --git a/src/servers/http.go b/src/servers/http.go index bd2bc06..1c05ad6 100644 --- a/src/servers/http.go +++ b/src/servers/http.go @@ -10,7 +10,7 @@ package servers import ( "encoding/json" - "github.com/p1c2u/dnsdock/src/utils" + "github.com/dz3n/dnsdock/src/utils" "github.com/gorilla/mux" "net/http" ) diff --git a/src/servers/http_test.go b/src/servers/http_test.go index 470603e..f6dc43a 100644 --- a/src/servers/http_test.go +++ b/src/servers/http_test.go @@ -9,7 +9,7 @@ package servers import ( - "github.com/p1c2u/dnsdock/src/utils" + "github.com/dz3n/dnsdock/src/utils" "io/ioutil" "net/http" "strings" From fadc8dfca902bed297438ba8592b7cb74d11d968 Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Sun, 21 Jan 2024 22:32:41 +0200 Subject: [PATCH 3/6] change docker api version --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3665d37..3c6c00f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ ENV GIT_SSL_NO_VERIFY=true RUN godep restore -ENV GOARCH=arm64 +ENV GOARCH=amd64 WORKDIR /go/src/github.com/dz3n/dnsdock/src @@ -37,6 +37,8 @@ RUN govvv build -o /tmp/output/dnsdock FROM alpine:3.18.2 +ENV GOARCH=amd64 + COPY --from=builder /tmp/output/dnsdock /bin/dnsdock ENTRYPOINT ["dnsdock"] From e0bdc52e602bc82b98ddf6a40b354c5ad3372df8 Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Sun, 21 Jan 2024 22:37:27 +0200 Subject: [PATCH 4/6] change docker api version --- src/core/docker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/docker.go b/src/core/docker.go index d5cffc5..f7f4971 100644 --- a/src/core/docker.go +++ b/src/core/docker.go @@ -35,7 +35,7 @@ type DockerManager struct { // NewDockerManager creates a new DockerManager func NewDockerManager(c *utils.Config, list servers.ServiceListProvider, tlsConfig *tls.Config) (*DockerManager, error) { defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"} - dclient, err := client.NewClient(c.DockerHost, "v1.30", nil, defaultHeaders) + dclient, err := client.NewClient(c.DockerHost, "v1.44", nil, defaultHeaders) if err != nil { return nil, err From 05d48971f3df612e58db34ca259fe6dd3042dcc1 Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Mon, 22 Jan 2024 15:08:20 +0200 Subject: [PATCH 5/6] change docker api --- Dockerfile | 12 ++++++------ Godeps/Godeps.json | 2 +- docker-compose.yml | 19 ++++++++++--------- readme.md | 20 ++++++++++---------- src/core/cmdline.go | 2 +- src/core/docker.go | 4 ++-- src/core/docker_test.go | 2 +- src/main.go | 6 +++--- src/servers/dnsserver.go | 2 +- src/servers/dnsserver_test.go | 2 +- src/servers/http.go | 2 +- src/servers/http_test.go | 2 +- 12 files changed, 38 insertions(+), 37 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3c6c00f..498b825 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,16 +14,16 @@ RUN go get -v github.com/tools/godep # RUN go get -u github.com/golang/lint/golint RUN go get github.com/ahmetb/govvv -RUN mkdir -p /go/src/github.com/dz3n/dnsdock +RUN mkdir -p /go/src/github.com/aacebedo/dnsdock -WORKDIR /go/src/github.com/dz3n/dnsdock +WORKDIR /go/src/github.com/aacebedo/dnsdock -RUN git clone https://github.com/dz3n/dnsdock /go/src/github.com/dz3n/dnsdock +RUN git clone https://github.com/aacebedo/dnsdock /go/src/github.com/aacebedo/dnsdock # RUN git checkout {{$GIT_COMMIT}} RUN mkdir /tmp/output -WORKDIR /go/src/github.com/dz3n/dnsdock +WORKDIR /go/src/github.com/aacebedo/dnsdock ENV GIT_SSL_NO_VERIFY=true @@ -31,7 +31,7 @@ RUN godep restore ENV GOARCH=amd64 -WORKDIR /go/src/github.com/dz3n/dnsdock/src +WORKDIR /go/src/github.com/aacebedo/dnsdock/src RUN govvv build -o /tmp/output/dnsdock @@ -41,4 +41,4 @@ ENV GOARCH=amd64 COPY --from=builder /tmp/output/dnsdock /bin/dnsdock -ENTRYPOINT ["dnsdock"] +ENTRYPOINT ["dnsdock"] \ No newline at end of file diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 491020a..fcab44a 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,5 +1,5 @@ { - "ImportPath": "github.com/dz3n/dnsdock", + "ImportPath": "github.com/aacebedo/dnsdock", "GoVersion": "go1.6", "GodepVersion": "v74", "Packages": [ diff --git a/docker-compose.yml b/docker-compose.yml index fbf2080..dede735 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,10 @@ -services: - dnsdock: - image: dz3n/dnsdock - container_name: dnsdock - command: -nameserver 192.168.0.1:53 -nameserver 8.8.8.8:53 - volumes: - - /var/run/docker.sock:/run/docker.sock - ports: - - 172.17.0.0:53:53/udp +# /var/run/docker.sock does not seem to be available for fig +# for this reason we violate LFHS and add the socket directly on /run +dnsdock: + image: conz27/dnsdock + container_name: dnsdock + command: -nameserver 192.168.0.1:53 -nameserver 8.8.8.8:53 + volumes: + - /var/run/docker.sock:/run/docker.sock + ports: + - 172.17.0.0:53:53/udp diff --git a/readme.md b/readme.md index bdde429..a547c79 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -[![Build Status](https://secure.travis-ci.org/dz3n/dnsdock.png)](http://travis-ci.org/dz3n/dnsdock) +[![Build Status](https://secure.travis-ci.org/aacebedo/dnsdock.png)](http://travis-ci.org/aacebedo/dnsdock) ## dnsdock @@ -48,10 +48,10 @@ Install a golang development environment on your host and type the following com export GOPATH=/tmp/go export PATH=${PATH}:${GOPATH}/bin go get -v github.com/tools/godep -go get -d -v https://github.com/dz3n/dnsdock -cd ${GOPATH}/src/github.com/dz3n/dnsdock +go get -d -v https://github.com/aacebedo/dnsdock +cd ${GOPATH}/src/github.com/aacebedo/dnsdock godep restore -cd ${GOPATH}/src/github.com/dz3n/dnsdock/src +cd ${GOPATH}/src/github.com/aacebedo/dnsdock/src go build -o ${GOPATH}/bin/dnsdock ``` @@ -60,7 +60,7 @@ go build -o ${GOPATH}/bin/dnsdock To build with docker you need [rocker](https://github.com/grammarly/rocker). Check the website to install it and type the following commands: ``` -git clone https://github.com/dz3n/dnsdock +git clone https://github.com/aacebedo/dnsdock rocker build -var ARCH=[amd64|arm] -var OUTPUT_DIR= ``` @@ -123,7 +123,7 @@ Restart docker daemon after you have done that (`sudo service docker restart`). Now you only need to run the dnsdock container: ``` -docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p 172.17.0.1:53:53/udp dz3n/dnsdock [--opts] +docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p 172.17.0.1:53:53/udp aacebedo/dnsdock [--opts] ``` - `-d` starts container as daemon @@ -159,7 +159,7 @@ If you also want to let the host machine discover the containers add `nameserver Mounting docker daemon's unix socket may not work with default configuration on these platforms. Please use [selinux-dockersock](https://github.com/dpw/selinux-dockersock) to fix this. -More information in [#11](https://github.com/dz3n/dnsdock/issues/11). +More information in [#11](https://github.com/aacebedo/dnsdock/issues/11). #### TLS Authentication @@ -174,7 +174,7 @@ and the `DOCKER_CERTS` to a directory containing files named `ca.pem`, You may build this into your own container with this example Dockerfile: ``` -FROM dz3n/dnsdock +FROM aacebedo/dnsdock ENV DOCKER_TLS_VERIFY 1 ENV DOCKER_CERTS /certs @@ -314,8 +314,8 @@ Add the following snippet under the `units` part: [Service] EnvironmentFile=/etc/environment ExecStartPre=/bin/sh -c '/usr/bin/docker rm -f dnsdock || ls > /dev/null' - ExecStartPre=/bin/sh -c '/usr/bin/docker pull dz3n/dnsdock' - ExecStart=/usr/bin/docker run -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p ${COREOS_PRIVATE_IPV4}:53:53/udp dz3n/dnsdock + ExecStartPre=/bin/sh -c '/usr/bin/docker pull aacebedo/dnsdock' + ExecStart=/usr/bin/docker run -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p ${COREOS_PRIVATE_IPV4}:53:53/udp aacebedo/dnsdock ExecStop=/bin/sh -c '/usr/bin/docker stop dnsdock || ls > /dev/null' ``` diff --git a/src/core/cmdline.go b/src/core/cmdline.go index d38f410..0e2f634 100644 --- a/src/core/cmdline.go +++ b/src/core/cmdline.go @@ -10,7 +10,7 @@ package core import ( "fmt" - "github.com/dz3n/dnsdock/src/utils" + "github.com/aacebedo/dnsdock/src/utils" "gopkg.in/alecthomas/kingpin.v2" "strconv" ) diff --git a/src/core/docker.go b/src/core/docker.go index f7f4971..606e590 100644 --- a/src/core/docker.go +++ b/src/core/docker.go @@ -11,8 +11,8 @@ package core import ( "crypto/tls" "errors" - "github.com/dz3n/dnsdock/src/servers" - "github.com/dz3n/dnsdock/src/utils" + "github.com/aacebedo/dnsdock/src/servers" + "github.com/aacebedo/dnsdock/src/utils" "github.com/docker/engine-api/client" "github.com/docker/engine-api/types" eventtypes "github.com/docker/engine-api/types/events" diff --git a/src/core/docker_test.go b/src/core/docker_test.go index 0f59a0b..f624b65 100644 --- a/src/core/docker_test.go +++ b/src/core/docker_test.go @@ -9,7 +9,7 @@ package core import ( - "github.com/dz3n/dnsdock/src/servers" + "github.com/aacebedo/dnsdock/src/servers" "reflect" "testing" ) diff --git a/src/main.go b/src/main.go index f9eaff6..538d887 100644 --- a/src/main.go +++ b/src/main.go @@ -11,9 +11,9 @@ package main import ( "crypto/tls" "crypto/x509" - "github.com/dz3n/dnsdock/src/core" - "github.com/dz3n/dnsdock/src/servers" - "github.com/dz3n/dnsdock/src/utils" + "github.com/aacebedo/dnsdock/src/core" + "github.com/aacebedo/dnsdock/src/servers" + "github.com/aacebedo/dnsdock/src/utils" "github.com/op/go-logging" "io/ioutil" "os" diff --git a/src/servers/dnsserver.go b/src/servers/dnsserver.go index b76da0f..03a0437 100644 --- a/src/servers/dnsserver.go +++ b/src/servers/dnsserver.go @@ -11,7 +11,7 @@ package servers import ( "errors" "fmt" - "github.com/dz3n/dnsdock/src/utils" + "github.com/aacebedo/dnsdock/src/utils" "github.com/miekg/dns" "net" "regexp" diff --git a/src/servers/dnsserver_test.go b/src/servers/dnsserver_test.go index f423189..2ec748a 100644 --- a/src/servers/dnsserver_test.go +++ b/src/servers/dnsserver_test.go @@ -9,7 +9,7 @@ package servers import ( - "github.com/dz3n/dnsdock/src/utils" + "github.com/aacebedo/dnsdock/src/utils" "github.com/miekg/dns" "net" "strings" diff --git a/src/servers/http.go b/src/servers/http.go index 1c05ad6..14ff203 100644 --- a/src/servers/http.go +++ b/src/servers/http.go @@ -10,7 +10,7 @@ package servers import ( "encoding/json" - "github.com/dz3n/dnsdock/src/utils" + "github.com/aacebedo/dnsdock/src/utils" "github.com/gorilla/mux" "net/http" ) diff --git a/src/servers/http_test.go b/src/servers/http_test.go index f6dc43a..97a44b3 100644 --- a/src/servers/http_test.go +++ b/src/servers/http_test.go @@ -9,7 +9,7 @@ package servers import ( - "github.com/dz3n/dnsdock/src/utils" + "github.com/aacebedo/dnsdock/src/utils" "io/ioutil" "net/http" "strings" From 2f62930285ece71f618a80f4a793add5207d15c7 Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Mon, 22 Jan 2024 15:09:29 +0200 Subject: [PATCH 6/6] change docker api --- Rockerfile | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Rockerfile diff --git a/Rockerfile b/Rockerfile new file mode 100644 index 0000000..d434782 --- /dev/null +++ b/Rockerfile @@ -0,0 +1,85 @@ +# This file is part of DNSDock +# MIT +# +# Copyright (C) 2014 Tõnis Tiigi +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +{{$GOLANG_VERSION := "1.6.3"}} +{{$ARCH:= (or .ARCH "amd64")}} +{{$GIT_COMMIT:= (or .GIT_COMMIT "develop")}} +{{$DOCKERIMAGE_VERSION:= (or .DOCKERIMAGE_VERSION "dev")}} +{{$SRC_DIR:= (or .SRC_DIR ".")}} + +# build image +FROM alpine:3.4 +RUN apk update +RUN apk upgrade +RUN apk add go>{{$GOLANG_VERSION}} go-tools>{{$GOLANG_VERSION}} git musl-dev + +ENV GOPATH=/go +ENV PATH=${PATH}:/go/bin +ENV CGO_ENABLED=0 + +RUN go get -v github.com/tools/godep +RUN go get -u github.com/golang/lint/golint +RUN go get github.com/ahmetb/govvv + +RUN mkdir -p /go/src/github.com/aacebedo/dnsdock +WORKDIR /go/src/github.com/aacebedo/dnsdock +{{if .SRC_DIR}} + MOUNT {{$SRC_DIR}}:/go/src/github.com/aacebedo/dnsdock +{{else}} + RUN git clone https://github.com/aacebedo/dnsdock /go/src/github.com/aacebedo/dnsdock + RUN git checkout {{$GIT_COMMIT}} +{{end}} + +{{if .OUTPUT_DIR}} + MOUNT {{.OUTPUT_DIR}}:/tmp/output +{{else}} + RUN mkdir /tmp/output +{{end}} + +WORKDIR /go/src/github.com/aacebedo/dnsdock +RUN godep restore +ENV GOARCH={{$ARCH}} +WORKDIR /go/src/github.com/aacebedo/dnsdock/src +ATTACH sh +RUN govvv build -o /tmp/output/dnsdock +RUN golint -set_exit_status +{{if eq $ARCH "amd64"}} +RUN go vet +RUN go test ./... +{{end}} +TAG aacebedo/dnsdock-devenv:latest-{{$ARCH}} +EXPORT /tmp/output/dnsdock ./dnsdock + +# run image +{{if eq $ARCH "amd64"}} +FROM alpine +{{else}} +FROM easypi/alpine-arm +{{end}} +IMPORT ./dnsdock /bin/dnsdock +ENTRYPOINT ["dnsdock"] +TAG aacebedo/dnsdock:{{$DOCKERIMAGE_VERSION}}-{{$ARCH}} + +{{if ne $DOCKERIMAGE_VERSION "dev"}} +TAG aacebedo/dnsdock:latest-{{$ARCH}} +{{end}}