deis / prototype-repo

Prototype repository for a Deis v2 component
http://deis.io
MIT License
3 stars 6 forks source link

do builds in a separate container #6

Closed arschles closed 8 years ago

arschles commented 8 years ago

instead of building in the Dockerfile, build the binary in a separate container before running docker build, and copy the resulting binary into the image in the Dockerfile.

this command builds a binary that can run in alpine:3.1 and most linux based containers:

docker run --rm -it -e GO15VENDOREXPERIMENT=1 -v $$GOPATH:/gopath -e GOPATH=/gopath -e CGO_ENABLED=0 -w /gopath/src/github.com/deis/PROJ_NAME golang:1.5.1 go build -o /gopath/src/github.com/deis/PROJ_NAME/BINARY_NAME -a -installsuffix cgo -ldflags ${LDFLAGS}

technosophos commented 8 years ago

I'm nor clear what this is fixing. Which target does this belong in?

IIRC, what currently happens is that a new docker container is run and it runs make docker-build or something like that inside of the container, then leaves the artifact on disk. That seems to me to be a little easier to maintain than a single-line version that (it looks like) does about the same thing.

The idea was to make it easy to modify the docker-build target for other builds.

arschles commented 8 years ago

sorry, I wrote this at the end of a long day and I wrote it in response to the Dockerfile in deis/builder, which builds a go binary during the docker build process.

After looking and asking around, I see that it's an outlier and needs to be fixed (something I'm gonna do in the near-ish future). closing this