misc/docker: Go1.5 update + related simplifications

Update our Go image to use Go1.5.

Also, with Go1.5, we can compile static binaries (with CGO_ENABLED=0 and
--tags=netgo) without having to first rebuild Go itself from source with
CGO_ENABLED=0.

Finally, with Go1.5, we can now cross-compile straight outta the (linux)
binary tarball (without having to first build the necessary runtime in
src).

For both these above reasons, we don't need to use the Go -src tarball,
and we don't need to have a dedicated Go docker image for each GOOS we
cross-compile too.

Yay, progress!

Change-Id: Ibafb542a4771b151638e796ad3df78e0c8f1a4bf
This commit is contained in:
mpl 2015-08-25 18:26:17 +02:00
parent 91c0467302
commit b432bf01c7
4 changed files with 8 additions and 20 deletions

View File

@ -103,9 +103,6 @@ func genCamlistore(ctxDir string) {
func genBinaries(ctxDir string) {
check(os.Mkdir(filepath.Join(ctxDir, "/camlistore.org"), 0755))
image := goDockerImage
if *buildOS != "linux" {
image += "-" + *buildOS
}
args := []string{
"run",
"--rm",
@ -358,11 +355,10 @@ func main() {
// using docker all along, and it's convenient for now for code reuse. I
// can refactor it all out of dock.go afterwards if we like the process.
if *doBinaries {
goDir := "go"
if *buildOS != "linux" {
goDir = path.Join(goDir, *buildOS)
}
buildDockerImage(goDir, goDockerImage+"-"+*buildOS)
// TODO(mpl): consider using an "official" or trusted existing
// Go docker image, since we don't do anything special anymore in
// ours?
buildDockerImage("go", goDockerImage+"-linux")
ctxDir, err := ioutil.TempDir("", "camli-build")
if err != nil {
log.Fatal(err)

View File

@ -7,11 +7,6 @@ RUN apt-get -y --no-install-recommends install ca-certificates libc6-dev
# Get Go stable release
WORKDIR /tmp
# TODO(mpl): good enough for now with binary version. switch back to src tarball when go1.5 is out, if needed.
RUN curl -O https://storage.googleapis.com/golang/go1.5rc1.linux-amd64.tar.gz
RUN echo '2abf55effd93f5c2dcef306eaf14d3e7f614a407 go1.5rc1.linux-amd64.tar.gz' | sha1sum -c
RUN tar -C /usr/local -xzf go1.5rc1.linux-amd64.tar.gz
# rebuild Go with cgo disabled so we can build static binaries
#WORKDIR /usr/local/go/src
#RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux ./make.bash
RUN curl -O https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz
RUN echo '46eecd290d8803887dec718c691cc243f2175fe0 go1.5.1.linux-amd64.tar.gz' | sha1sum -c
RUN tar -C /usr/local -xzf go1.5.1.linux-amd64.tar.gz

View File

@ -1,4 +0,0 @@
# Copyright 2015 The Camlistore Authors.
FROM camlistore/go
WORKDIR /usr/local/go/src
RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin ./make.bash --no-clean

View File

@ -118,6 +118,7 @@ func fetchCamliSrc() {
func build() {
check(os.Chdir("/gopath/src/camlistore.org"))
oldPath := os.Getenv("PATH")
// Note: no need to set GO15VENDOREXPERIMENT because make.go does it.
os.Setenv("GOPATH", "/gopath")
os.Setenv("PATH", "/usr/local/go/bin:"+oldPath)
cmd := exec.Command("go", "run", "make.go", "--use_gopath", "--os", *buildOS)