mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-09-12 16:14:42 +08:00
convert docker to alpine (#207)
This commit is contained in:
parent
dd39e9a4be
commit
ae14b0e790
3 changed files with 19 additions and 9 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -10,4 +10,4 @@ docs/_site
|
||||||
powershell.log
|
powershell.log
|
||||||
zones/
|
zones/
|
||||||
*.env
|
*.env
|
||||||
node_modules
|
certs/
|
||||||
|
|
10
Dockerfile
10
Dockerfile
|
@ -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
|
WORKDIR /go/src/github.com/StackExchange/dnscontrol
|
||||||
ADD . .
|
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 cp dnscontrol-Linux /go/bin/dnscontrol
|
||||||
RUN dnscontrol version
|
RUN dnscontrol version
|
||||||
|
|
||||||
FROM ubuntu:xenial
|
FROM alpine
|
||||||
COPY --from=build-env /go/bin/dnscontrol /usr/local/bin
|
COPY --from=build-env /go/bin/dnscontrol /usr/local/bin
|
||||||
WORKDIR /dns
|
WORKDIR /dns
|
||||||
RUN apt-get update
|
RUN dnscontrol version
|
||||||
RUN apt-get install -y ca-certificates
|
|
||||||
CMD dnscontrol
|
CMD dnscontrol
|
|
@ -12,6 +12,8 @@ import (
|
||||||
|
|
||||||
var sha = flag.String("sha", "", "SHA of current commit")
|
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() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
flags := fmt.Sprintf(`-s -w -X main.SHA="%s" -X main.BuildTime=%d`, getVersion(), time.Now().Unix())
|
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")
|
for _, env := range []struct {
|
||||||
build("dnscontrol.exe", "windows")
|
binary, goos string
|
||||||
build("dnscontrol-Darwin", "darwin")
|
}{
|
||||||
|
{"dnscontrol-Linux", "linux"},
|
||||||
|
{"dnscontrol.exe", "windows"},
|
||||||
|
{"dnscontrol-Darwin", "darwin"},
|
||||||
|
} {
|
||||||
|
if *goos == "" || *goos == env.goos {
|
||||||
|
build(env.binary, env.goos)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVersion() string {
|
func getVersion() string {
|
||||||
|
|
Loading…
Add table
Reference in a new issue