Skip to content

Commit 5fd1b50

Browse files
committed
Merged release/v1.13.0 into master
2 parents b25c088 + bf6e5c2 commit 5fd1b50

File tree

483 files changed

+409
-145885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

483 files changed

+409
-145885
lines changed

.travis.yml

+35-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
1-
language: go
1+
sudo: required
22

3-
go:
4-
- 1.6
3+
services:
4+
- docker
55

6-
before_script:
7-
8-
script: make test
6+
before_install:
7+
- sudo apt-get update
8+
- sudo apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y --force-yes -q docker-engine
9+
- wget https://github.com/grammarly/rocker/releases/download/1.2.0/rocker-1.2.0-linux_amd64.tar.gz -O /tmp/rocker.tar.gz
10+
- sudo tar -xvzf /tmp/rocker.tar.gz -C /usr/local/bin && sudo chmod +x /usr/local/bin/rocker
11+
- sudo mkdir -m 777 -p /build/amd64 /build/arm
12+
13+
script:
14+
- if git describe --contains ${TRAVIS_COMMIT} &>/dev/null; then export VERSIONARGS="-var DOCKERIMAGE_VERSION=`git describe --contains ${TRAVIS_COMMIT}`"; else unset VERSIONARGS; fi
15+
- rocker build --no-cache ${VERSIONARGS} -var GIT_COMMIT=${TRAVIS_COMMIT} -var OUTPUTDIR=/build/amd64 -var ARCH=amd64 .
16+
- rocker build --no-cache ${VERSIONARGS} -var GIT_COMMIT=${TRAVIS_COMMIT} -var OUTPUTDIR=/build/arm -var ARCH=arm .
17+
- sudo mv /build/amd64/dnsdock /build/dnsdock.amd64
18+
- sudo mv /build/arm/dnsdock /build/dnsdock.arm
19+
20+
deploy:
21+
- provider: releases
22+
skip_cleanup: true
23+
api-key:
24+
secure: $GITHUB_TOKEN
25+
file:
26+
- /build/dnsdock.amd64
27+
- /build/dnsdock.arm
28+
on:
29+
tags: true
30+
- provider: script
31+
script: rocker build --auth $DOCKER_USER:$DOCKER_PASS --push rocker build -var Arch=arm -var ${VERSIONARGS} .
32+
on:
33+
tags: true
34+
- provider: script
35+
script: rocker build --auth $DOCKER_USER:$DOCKER_PASS --push rocker build -var Arch=amd64 -var ${VERSIONARGS} .
36+
on:
37+
tags: true

Dockerfile

-9
This file was deleted.

Godeps/Godeps.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

-13
This file was deleted.

PULL_REQUEST_TEMPLATE.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Before creating your PR, execute the following command:
2+
$> go vet
3+
$> go lint
4+
$> go fmt
5+
$> go build
6+
$> go test
7+
8+
## PR source branches shall have the following name: feature/<PR_NAME>
9+
10+
## PR destination branch shall be develop
11+
12+
## Any PR not respecting those rules won't be merge and will be closed after a few weeks if not updated.

Rockerfile

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# This file is part of DNSDock
2+
# MIT
3+
#
4+
# Copyright (C) 2014 Tõnis Tiigi <tonistiigi@gmail.com>
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
23+
24+
{{$GOLANG_VERSION := "1.6.2-r4"}}
25+
{{$ARCH:= (or .ARCH "amd64")}}
26+
{{$GIT_COMMIT:= (or .GIT_COMMIT "develop")}}
27+
{{$DOCKERIMAGE_VERSION:= (or .DOCKERIMAGE_VERSION "develop")}}
28+
{{$SRCDIR:= (or .SRCDIR ".")}}
29+
30+
# build image
31+
FROM alpine
32+
33+
RUN apk update
34+
RUN apk upgrade
35+
RUN apk add go>{{$GOLANG_VERSION}} go-tools>{{$GOLANG_VERSION}} git
36+
37+
ENV GOPATH /go
38+
ENV CGO_ENABLED 0
39+
ENV PATH ${PATH}:/go/bin
40+
ENV CGO_ENABLED=0
41+
42+
RUN go get -v github.com/tools/godep
43+
44+
45+
{{if .SRCDIR}}
46+
MOUNT {{$SRCDIR}}:/go/src/github.com/tonistiigi/dnsdock
47+
{{else}}
48+
RUN go get github.com/tonistiigi/dnsdock
49+
WORKDIR /go/src/github.com/tonistiigi/dnsdock
50+
RUN git checkout {{$GIT_COMMIT}}
51+
{{end}}
52+
53+
{{if .OUTPUTDIR}}
54+
MOUNT {{.OUTPUTDIR}}:/tmp/output
55+
{{else}}
56+
RUN mkdir /tmp/output
57+
{{end}}
58+
59+
WORKDIR /go/src/github.com/tonistiigi/dnsdock
60+
RUN godep restore
61+
RUN go get -u github.com/golang/lint/golint
62+
63+
ENV GOARCH={{$ARCH}}
64+
WORKDIR /go/src/github.com/tonistiigi/dnsdock/src
65+
ATTACH sh
66+
RUN go build -o /tmp/output/dnsdock -ldflags "-X main.version=$(if version=$(git describe --contains HEAD 2>/dev/null); then echo $version; else echo "dev"; fi)"
67+
RUN golint -set_exit_status
68+
{{if eq $ARCH "amd64"}}
69+
RUN go vet
70+
RUN go test
71+
{{end}}
72+
EXPORT /tmp/output/dnsdock ./dnsdock
73+
74+
# run image
75+
{{ if eq $ARCH "amd64" }}
76+
FROM alpine
77+
{{ else }}
78+
FROM easypi/alpine-arm
79+
{{ end }}
80+
IMPORT ./dnsdock /bin/dnsdock
81+
ENTRYPOINT ["dnsdock"]
82+
TAG tonistiigi/dnsdock:{{$ARCH}}-{{$DOCKERIMAGE_VERSION}}
83+
PUSH tonistiigi/dnsdock:{{$ARCH}}-{{$DOCKERIMAGE_VERSION}}

config.go

-62
This file was deleted.

readme.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,32 @@ specific tag that was used when the container was created. This means that if a
3737
new version of an image comes out and untags the image that your container
3838
still uses, the DNS requests for this old container still work.
3939

40-
#### Usage
40+
#### Build
41+
42+
##### Building without docker:
43+
44+
Install a golang development environment on your host and type the following commands:
45+
```
46+
export GOPATH=/tmp/go
47+
export PATH=${PATH}:${GOPATH}/bin
48+
go get -v github.com/tools/godep
49+
go get -d -v https://github.com/tonistiigi/dnsdock
50+
cd ${GOPATH}/src/github.com/tonistiigi/dnsdock
51+
godep restore
52+
cd ${GOPATH}/src/github.com/tonistiigi/dnsdock/src
53+
go build -o ${GOPATH}/bin/dnsdock
54+
```
4155

56+
##### Building with docker:
57+
58+
To build with docker you need [rocker](https://github.com/grammarly/rocker). Check the
59+
website to install it and type the following commands:
60+
```
61+
if git describe --contains HEAD &>/dev/null; then export VERSIONARGS="-var DNSDockVersion=`git describe --contains HEAD`"; else unset VERSIONARGS; fi
62+
rocker build -var Arch=[amd64|arm] ${VERSIONARGS} -var OutputDir=<outputdir> .
63+
```
64+
65+
#### Usage
4266
Dnsdock connects to Docker Remote API and keeps an up to date list of running
4367
containers. If a DNS request matches some of the containers their local IP
4468
addresses are returned.

src/config.go

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"strings"
6+
)
7+
8+
// Domain represents a domain
9+
type Domain []string
10+
11+
// NewDomain creates a new domain
12+
func NewDomain(s string) Domain {
13+
s = strings.Replace(s, "..", ".", -1)
14+
if s[:1] == "." {
15+
s = s[1:]
16+
}
17+
if s[len(s)-1:] == "." {
18+
s = s[:len(s)-1]
19+
}
20+
return Domain(strings.Split(s, "."))
21+
}
22+
23+
func (d *Domain) String() string {
24+
return strings.Join([]string(*d), ".")
25+
}
26+
27+
// type that knows how to parse CSV strings and store the values in a slice
28+
type nameservers []string
29+
30+
func (n *nameservers) String() string {
31+
return strings.Join(*n, " ")
32+
}
33+
34+
// accumulate the CSV string of nameservers
35+
func (n *nameservers) Set(value string) error {
36+
*n = nil
37+
for _, ns := range strings.Split(value, ",") {
38+
ns = strings.Trim(ns, " ")
39+
*n = append(*n, ns)
40+
}
41+
42+
return nil
43+
}
44+
45+
// Config contains DNSDock configuration
46+
type Config struct {
47+
nameserver nameservers
48+
dnsAddr string
49+
domain Domain
50+
dockerHost string
51+
tlsVerify bool
52+
tlsCaCert string
53+
tlsCert string
54+
tlsKey string
55+
verbose bool
56+
httpAddr string
57+
ttl int
58+
createAlias bool
59+
}
60+
61+
// NewConfig creates a new config
62+
func NewConfig() *Config {
63+
dockerHost := os.Getenv("DOCKER_HOST")
64+
if len(dockerHost) == 0 {
65+
dockerHost = "unix:///var/run/docker.sock"
66+
}
67+
tlsVerify := len(os.Getenv("DOCKER_TLS_VERIFY")) != 0
68+
dockerCerts := os.Getenv("DOCKER_CERT_PATH")
69+
if len(dockerCerts) == 0 {
70+
dockerCerts = os.Getenv("HOME") + "/.docker"
71+
}
72+
73+
return &Config{
74+
nameserver: nameservers{"8.8.8.8:53"},
75+
dnsAddr: ":53",
76+
domain: NewDomain("docker"),
77+
dockerHost: dockerHost,
78+
httpAddr: ":80",
79+
createAlias: false,
80+
tlsVerify: tlsVerify,
81+
tlsCaCert: dockerCerts + "/ca.pem",
82+
tlsCert: dockerCerts + "/cert.pem",
83+
tlsKey: dockerCerts + "/key.pem",
84+
}
85+
86+
}

config_test.go src/config_test.go

File renamed without changes.

0 commit comments

Comments
 (0)