-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
483 changed files
with
409 additions
and
145,885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.