Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

add two parameters, privileged and mounts #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docker/go-1.9.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

# 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
17 changes: 17 additions & 0 deletions docker/go-1.9.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

# 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
8 changes: 8 additions & 0 deletions docker/go-1.9.x/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
2 changes: 1 addition & 1 deletion docker/go-latest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
12 changes: 12 additions & 0 deletions xgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

Expand All @@ -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
Expand Down Expand Up @@ -172,6 +176,8 @@ func main() {
Dependencies: *crossDeps,
Arguments: *crossArgs,
Targets: strings.Split(*targets, ","),
Privileged: *privileged,
MountList: strings.Split(*mountList, ","),
}
flags := &BuildFlags{
Verbose: *buildVerbose,
Expand Down Expand Up @@ -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}...)
Expand Down