1
0
mirror of https://github.com/tianon/gosu.git synced 2025-04-18 19:04:06 +03:00

CROSS COMPILE ALL THE THINGS

This commit is contained in:
Tianon Gravi 2014-11-11 17:16:30 -07:00
parent 4ac858eb1a
commit b304eab5a6
4 changed files with 21 additions and 14 deletions

1
.dockerignore Symbolic link
View File

@ -0,0 +1 @@
.gitignore

2
.gitignore vendored
View File

@ -1 +1 @@
gosu
gosu*

View File

@ -1,17 +1,22 @@
FROM golang
FROM golang:cross
RUN mkdir -p /go/src/github.com/docker \
&& git clone https://github.com/docker/libcontainer.git /go/src/github.com/docker/libcontainer
&& git clone https://github.com/docker/libcontainer.git /go/src/github.com/docker/libcontainer \
&& cd /go/src/github.com/docker/libcontainer \
&& git checkout --quiet 4ae31b6ceb2c2557c9f05f42da61b0b808faa5a4
ENV GOPATH $GOPATH:/go/src/github.com/docker/libcontainer/vendor
# TODO pin specific commit
# cache-fill
RUN go get -d -v github.com/docker/libcontainer/namespaces
ENV GOSU_ARCHES amd64 386 arm
COPY . /go/src/github.com/tianon/gosu
# disable CGO for ALL THE THINGS (to help ensure no libc)
ENV CGO_ENABLED 0
COPY *.go /go/src/github.com/tianon/gosu/
WORKDIR /go/src/github.com/tianon/gosu
RUN go get -d -v ./...
RUN go build -v
CMD [ "cat", "gosu" ]
RUN GOARCH=amd64 go build -v -ldflags -d -o /go/bin/gosu-amd64
RUN GOARCH=386 go build -v -ldflags -d -o /go/bin/gosu-386
RUN GOARCH=arm GOARM=5 go build -v -ldflags -d -o /go/bin/gosu-armv5
RUN GOARCH=arm GOARM=6 go build -v -ldflags -d -o /go/bin/gosu-armv6
RUN GOARCH=arm GOARM=7 go build -v -ldflags -d -o /go/bin/gosu-armv7

View File

@ -5,6 +5,7 @@ cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
set -x
docker build -t gosu .
docker run --rm gosu > gosu
chmod +x gosu
./gosu
rm -f gosu*
docker run --rm gosu bash -c 'cd /go/bin && tar -c gosu*' | tar -xv
ls -lFh gosu*
./gosu-amd64