From c6b9d0960286a4c0c2f02f1da5aa2a42de3aacba Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sun, 9 Aug 2015 15:36:25 -0700 Subject: [PATCH] added alpine build image --- .dockerignore | 1 + Dockerfile.alpine | 26 ++++++++++++++++++++++++++ cmd/drone-build/Dockerfile.alpine | 25 +++++++++++++++++++++++++ cmd/drone-server/drone.go | 2 +- make.go | 5 ++++- 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.alpine create mode 100644 cmd/drone-build/Dockerfile.alpine diff --git a/.dockerignore b/.dockerignore index d0effdff8..e1b68ff0c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,6 +3,7 @@ cmd/drone-server/drone_bindata.go dist/ doc/ +.git/ .dockerignore .drone.yml .gitignore diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 000000000..4ab4ba6aa --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,26 @@ +# Docker image for the Drone build runner +# +# docker build --file=Dockerfile.alpine --rm=true -t drone/drone-alpine . + +FROM alpine:3.2 + +EXPOSE 8080 + +ENV GOROOT=/usr/lib/go \ + GOPATH=/gopath \ + GOBIN=/gopath/bin \ + PATH=$PATH:$GOROOT/bin:$GOPATH/bin + +WORKDIR /gopath/src/github.com/drone/drone +ADD . /gopath/src/github.com/drone/drone + +RUN apk add -U go ca-certificates libc-dev gcc git sqlite-libs && \ + go get github.com/jteeuwen/go-bindata/... && \ + /gopath/bin/go-bindata -o="cmd/drone-server/drone_bindata.go" cmd/drone-server/static/... && \ + go run make.go build && \ + apk del git go gcc libc-dev && \ + mv bin/drone /bin/drone && \ + rm -rf /gopath && \ + rm -rf /var/cache/apk/* + +ENTRYPOINT ["/bin/drone"] diff --git a/cmd/drone-build/Dockerfile.alpine b/cmd/drone-build/Dockerfile.alpine new file mode 100644 index 000000000..afa3acd82 --- /dev/null +++ b/cmd/drone-build/Dockerfile.alpine @@ -0,0 +1,25 @@ +# Docker image for the Drone build runner +# +# cd $GOPATH/src/github.com/drone/drone +# docker build --file=cmd/drone-build/Dockerfile.alpine --rm=true -t drone/drone-build . + +FROM alpine:3.2 + +ENV GOROOT=/usr/lib/go \ + GOPATH=/gopath \ + GOBIN=/gopath/bin \ + CGO_ENABLED=0 \ + PATH=$PATH:$GOROOT/bin:$GOPATH/bin + +WORKDIR /gopath/src/github.com/drone/drone +ADD . /gopath/src/github.com/drone/drone + +RUN apk add -U go ca-certificates && \ + cd cmd/drone-build && \ + go build -a -tags netgo && \ + apk del go && \ + mv drone-build /bin/drone-build && \ + rm -rf /gopath && \ + rm -rf /var/cache/apk/* + +ENTRYPOINT ["/bin/drone-build"] diff --git a/cmd/drone-server/drone.go b/cmd/drone-server/drone.go index c4f4d080f..b12fe7c00 100644 --- a/cmd/drone-server/drone.go +++ b/cmd/drone-server/drone.go @@ -241,7 +241,7 @@ func main() { http.Handle("/static/", static()) http.Handle("/", r) - err = http.ListenAndServe(settings.Server.Addr, nil) + err = http.ListenAndServe(conf.server.addr, nil) if err != nil { log.Error("Cannot start server: ", err) } diff --git a/make.go b/make.go index b9b19cffc..6ee80bfcb 100644 --- a/make.go +++ b/make.go @@ -154,6 +154,9 @@ func trace(args []string) { // helper function to parse the git revision func rev() string { cmd := exec.Command("git", "rev-parse", "--short", "HEAD") - raw, _ := cmd.CombinedOutput() + raw, err := cmd.CombinedOutput() + if err != nil { + return "HEAD" + } return strings.Trim(string(raw), "\n") }