diff --git a/docker/go-1.9.0/Dockerfile b/docker/go-1.9.0/Dockerfile new file mode 100644 index 00000000..392d91b6 --- /dev/null +++ b/docker/go-1.9.0/Dockerfile @@ -0,0 +1,17 @@ +# Go cross compiler (xgo): Go 1.9 +# Copyright (c) 2017 Péter Szilágyi. All rights reserved. +# +# Released under the MIT license. + +FROM karalabe/xgo-base + +MAINTAINER Péter Szilágyi + +# Configure the root Go distribution and bootstrap based on it +ENV GO_VERSION 190 + +RUN \ + export ROOT_DIST=https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz && \ + export ROOT_DIST_SHA=d70eadefce8e160638a9a6db97f7192d8463069ab33138893ad3bf31b0650a79 && \ + \ + $BOOTSTRAP_PURE diff --git a/docker/go-1.9.1/Dockerfile b/docker/go-1.9.1/Dockerfile new file mode 100644 index 00000000..8b24b7c9 --- /dev/null +++ b/docker/go-1.9.1/Dockerfile @@ -0,0 +1,17 @@ +# Go cross compiler (xgo): Go 1.9 +# Copyright (c) 2017 Péter Szilágyi. All rights reserved. +# +# Released under the MIT license. + +FROM karalabe/xgo-base + +MAINTAINER Péter Szilágyi + +# Configure the root Go distribution and bootstrap based on it +ENV GO_VERSION 191 + +RUN \ + export ROOT_DIST=https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz && \ + export ROOT_DIST_SHA=07d81c6b6b4c2dcf1b5ef7c27aaebd3691cdb40548500941f92b221147c5d9c7 && \ + \ + $BOOTSTRAP_PURE diff --git a/docker/go-1.9.x/Dockerfile b/docker/go-1.9.x/Dockerfile new file mode 100644 index 00000000..855b8ac9 --- /dev/null +++ b/docker/go-1.9.x/Dockerfile @@ -0,0 +1,8 @@ +# Go cross compiler (xgo): Wildcard layer to the latest 1.9 release +# Copyright (c) 2017 Péter Szilágyi. All rights reserved. +# +# Released under the MIT license. + +FROM karalabe/xgo-1.9.1 + +MAINTAINER Péter Szilágyi diff --git a/docker/go-latest/Dockerfile b/docker/go-latest/Dockerfile index 47955717..644d6b2e 100644 --- a/docker/go-latest/Dockerfile +++ b/docker/go-latest/Dockerfile @@ -3,6 +3,6 @@ # # Released under the MIT license. -FROM karalabe/xgo-1.8.x +FROM karalabe/xgo-1.9.x MAINTAINER Péter Szilágyi diff --git a/xgo.go b/xgo.go index b2bae9ce..ee42b8f1 100644 --- a/xgo.go +++ b/xgo.go @@ -53,6 +53,8 @@ var ( crossDeps = flag.String("deps", "", "CGO dependencies (configure/make based archives)") crossArgs = flag.String("depsargs", "", "CGO dependency configure arguments") targets = flag.String("targets", "*/*", "Comma separated targets to build for") + privileged = flag.Bool("privileged", false, "Flag for privileged container, by default, containers are unprivileged") + mountList = flag.String("mounts", "", "User-defined mount directories, use ',' to separate. (host-path1:image-path1:ro,host-path2:image-path2:rw)") dockerImage = flag.String("image", "", "Use custom docker image instead of official distribution") ) @@ -66,6 +68,8 @@ type ConfigFlags struct { Dependencies string // CGO dependencies (configure/make based archives) Arguments string // CGO dependency configure arguments Targets []string // Targets to build for + Privileged bool // Flag for privileged container + MountList []string // Mount directories } // Command line arguments to pass to go build @@ -172,6 +176,8 @@ func main() { Dependencies: *crossDeps, Arguments: *crossArgs, Targets: strings.Split(*targets, ","), + Privileged: *privileged, + MountList: strings.Split(*mountList, ","), } flags := &BuildFlags{ Verbose: *buildVerbose, @@ -299,9 +305,15 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string "-e", fmt.Sprintf("FLAG_BUILDMODE=%s", flags.Mode), "-e", "TARGETS=" + strings.Replace(strings.Join(config.Targets, " "), "*", ".", -1), } + if config.Privileged { + args = append(args, "--privileged=true") + } for i := 0; i < len(locals); i++ { args = append(args, []string{"-v", fmt.Sprintf("%s:%s:ro", locals[i], mounts[i])}...) } + for i := 0; i < len(config.MountList); i++ { + args = append(args, []string{"-v", config.MountList[i]}...) + } args = append(args, []string{"-e", "EXT_GOPATH=" + strings.Join(paths, ":")}...) args = append(args, []string{image, config.Repository}...)