convert docker to alpine (#207)

This commit is contained in:
Craig Peterson 2017-09-18 09:44:24 -04:00 committed by GitHub
parent dd39e9a4be
commit ae14b0e790
3 changed files with 19 additions and 9 deletions

2
.gitignore vendored
View file

@ -10,4 +10,4 @@ docs/_site
powershell.log
zones/
*.env
node_modules
certs/

View file

@ -1,13 +1,13 @@
FROM golang:1.9 AS build-env
FROM golang:1.9-alpine AS build-env
WORKDIR /go/src/github.com/StackExchange/dnscontrol
ADD . .
RUN go run build/build.go
RUN apk update && apk add git
RUN go run build/build.go -os=linux
RUN cp dnscontrol-Linux /go/bin/dnscontrol
RUN dnscontrol version
FROM ubuntu:xenial
FROM alpine
COPY --from=build-env /go/bin/dnscontrol /usr/local/bin
WORKDIR /dns
RUN apt-get update
RUN apt-get install -y ca-certificates
RUN dnscontrol version
CMD dnscontrol

View file

@ -12,6 +12,8 @@ import (
var sha = flag.String("sha", "", "SHA of current commit")
var goos = flag.String("os", "", "OS to build (linux, windows, or darwin) Defaults to all.")
func main() {
flag.Parse()
flags := fmt.Sprintf(`-s -w -X main.SHA="%s" -X main.BuildTime=%d`, getVersion(), time.Now().Unix())
@ -29,9 +31,17 @@ func main() {
}
}
build("dnscontrol-Linux", "linux")
build("dnscontrol.exe", "windows")
build("dnscontrol-Darwin", "darwin")
for _, env := range []struct {
binary, goos string
}{
{"dnscontrol-Linux", "linux"},
{"dnscontrol.exe", "windows"},
{"dnscontrol-Darwin", "darwin"},
} {
if *goos == "" || *goos == env.goos {
build(env.binary, env.goos)
}
}
}
func getVersion() string {