Skip to content

Commit

Permalink
Merged release/v1.13.0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebedo committed Jul 16, 2016
2 parents b25c088 + bf6e5c2 commit 5fd1b50
Show file tree
Hide file tree
Showing 483 changed files with 409 additions and 145,885 deletions.
41 changes: 35 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
language: go
sudo: required

go:
- 1.6
services:
- docker

before_script:

script: make test
before_install:
- sudo apt-get update
- sudo apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y --force-yes -q docker-engine
- wget https://github.com/grammarly/rocker/releases/download/1.2.0/rocker-1.2.0-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
- rocker build --no-cache ${VERSIONARGS} -var GIT_COMMIT=${TRAVIS_COMMIT} -var OUTPUTDIR=/build/amd64 -var ARCH=amd64 .
- rocker build --no-cache ${VERSIONARGS} -var GIT_COMMIT=${TRAVIS_COMMIT} -var OUTPUTDIR=/build/arm -var ARCH=arm .
- sudo mv /build/amd64/dnsdock /build/dnsdock.amd64
- sudo mv /build/arm/dnsdock /build/dnsdock.arm

deploy:
- provider: releases
skip_cleanup: true
api-key:
secure: $GITHUB_TOKEN
file:
- /build/dnsdock.amd64
- /build/dnsdock.arm
on:
tags: true
- provider: script
script: rocker build --auth $DOCKER_USER:$DOCKER_PASS --push rocker build -var Arch=arm -var ${VERSIONARGS} .
on:
tags: true
- provider: script
script: rocker build --auth $DOCKER_USER:$DOCKER_PASS --push rocker build -var Arch=amd64 -var ${VERSIONARGS} .
on:
tags: true
9 changes: 0 additions & 9 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions Makefile

This file was deleted.

12 changes: 12 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Before creating your PR, execute the following command:
$> go vet
$> go lint
$> go fmt
$> go build
$> go test

## PR source branches shall have the following name: feature/<PR_NAME>

## PR destination branch shall be develop

## Any PR not respecting those rules won't be merge and will be closed after a few weeks if not updated.
83 changes: 83 additions & 0 deletions Rockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This file is part of DNSDock
# MIT
#
# Copyright (C) 2014 Tõnis Tiigi <[email protected]>
#
# 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.2-r4"}}
{{$ARCH:= (or .ARCH "amd64")}}
{{$GIT_COMMIT:= (or .GIT_COMMIT "develop")}}
{{$DOCKERIMAGE_VERSION:= (or .DOCKERIMAGE_VERSION "develop")}}
{{$SRCDIR:= (or .SRCDIR ".")}}

# build image
FROM alpine

RUN apk update
RUN apk upgrade
RUN apk add go>{{$GOLANG_VERSION}} go-tools>{{$GOLANG_VERSION}} git

ENV GOPATH /go
ENV CGO_ENABLED 0
ENV PATH ${PATH}:/go/bin
ENV CGO_ENABLED=0

RUN go get -v github.com/tools/godep


{{if .SRCDIR}}
MOUNT {{$SRCDIR}}:/go/src/github.com/tonistiigi/dnsdock
{{else}}
RUN go get github.com/tonistiigi/dnsdock
WORKDIR /go/src/github.com/tonistiigi/dnsdock
RUN git checkout {{$GIT_COMMIT}}
{{end}}

{{if .OUTPUTDIR}}
MOUNT {{.OUTPUTDIR}}:/tmp/output
{{else}}
RUN mkdir /tmp/output
{{end}}

WORKDIR /go/src/github.com/tonistiigi/dnsdock
RUN godep restore
RUN go get -u github.com/golang/lint/golint

ENV GOARCH={{$ARCH}}
WORKDIR /go/src/github.com/tonistiigi/dnsdock/src
ATTACH sh
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)"
RUN golint -set_exit_status
{{if eq $ARCH "amd64"}}
RUN go vet
RUN go test
{{end}}
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 tonistiigi/dnsdock:{{$ARCH}}-{{$DOCKERIMAGE_VERSION}}
PUSH tonistiigi/dnsdock:{{$ARCH}}-{{$DOCKERIMAGE_VERSION}}
62 changes: 0 additions & 62 deletions config.go

This file was deleted.

26 changes: 25 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,32 @@ specific tag that was used when the container was created. This means that if a
new version of an image comes out and untags the image that your container
still uses, the DNS requests for this old container still work.

#### Usage
#### Build

##### Building without docker:

Install a golang development environment on your host and type the following commands:
```
export GOPATH=/tmp/go
export PATH=${PATH}:${GOPATH}/bin
go get -v github.com/tools/godep
go get -d -v https://github.com/tonistiigi/dnsdock
cd ${GOPATH}/src/github.com/tonistiigi/dnsdock
godep restore
cd ${GOPATH}/src/github.com/tonistiigi/dnsdock/src
go build -o ${GOPATH}/bin/dnsdock
```

##### Building with docker:

To build with docker you need [rocker](https://github.com/grammarly/rocker). Check the
website to install it and type the following commands:
```
if git describe --contains HEAD &>/dev/null; then export VERSIONARGS="-var DNSDockVersion=`git describe --contains HEAD`"; else unset VERSIONARGS; fi
rocker build -var Arch=[amd64|arm] ${VERSIONARGS} -var OutputDir=<outputdir> .
```

#### Usage
Dnsdock connects to Docker Remote API and keeps an up to date list of running
containers. If a DNS request matches some of the containers their local IP
addresses are returned.
Expand Down
86 changes: 86 additions & 0 deletions src/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package main

import (
"os"
"strings"
)

// Domain represents a domain
type Domain []string

// NewDomain creates a new domain
func NewDomain(s string) Domain {
s = strings.Replace(s, "..", ".", -1)
if s[:1] == "." {
s = s[1:]
}
if s[len(s)-1:] == "." {
s = s[:len(s)-1]
}
return Domain(strings.Split(s, "."))
}

func (d *Domain) String() string {
return strings.Join([]string(*d), ".")
}

// type that knows how to parse CSV strings and store the values in a slice
type nameservers []string

func (n *nameservers) String() string {
return strings.Join(*n, " ")
}

// accumulate the CSV string of nameservers
func (n *nameservers) Set(value string) error {
*n = nil
for _, ns := range strings.Split(value, ",") {
ns = strings.Trim(ns, " ")
*n = append(*n, ns)
}

return nil
}

// Config contains DNSDock configuration
type Config struct {
nameserver nameservers
dnsAddr string
domain Domain
dockerHost string
tlsVerify bool
tlsCaCert string
tlsCert string
tlsKey string
verbose bool
httpAddr string
ttl int
createAlias bool
}

// NewConfig creates a new config
func NewConfig() *Config {
dockerHost := os.Getenv("DOCKER_HOST")
if len(dockerHost) == 0 {
dockerHost = "unix:///var/run/docker.sock"
}
tlsVerify := len(os.Getenv("DOCKER_TLS_VERIFY")) != 0
dockerCerts := os.Getenv("DOCKER_CERT_PATH")
if len(dockerCerts) == 0 {
dockerCerts = os.Getenv("HOME") + "/.docker"
}

return &Config{
nameserver: nameservers{"8.8.8.8:53"},
dnsAddr: ":53",
domain: NewDomain("docker"),
dockerHost: dockerHost,
httpAddr: ":80",
createAlias: false,
tlsVerify: tlsVerify,
tlsCaCert: dockerCerts + "/ca.pem",
tlsCert: dockerCerts + "/cert.pem",
tlsKey: dockerCerts + "/key.pem",
}

}
File renamed without changes.
Loading

0 comments on commit 5fd1b50

Please sign in to comment.