-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
env: add dockerfile for cross compiling go for s390x
Update golang/go#16443 Change-Id: I59edb7334ad6236981b96faddb8aeb564579435b Reviewed-on: https://go-review.googlesource.com/27242 Reviewed-by: Brad Fitzpatrick <[email protected]>
- Loading branch information
Showing
5 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright 2016 The Go Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file. | ||
|
||
# Linux builder VM running Debian stretch (i.e. Debian testing) | ||
# Docker tag gobuilders/linux-s390x-stretch | ||
|
||
FROM debian:stretch | ||
MAINTAINER golang-dev <[email protected]> | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# curl: for getting and unpacking Go 1.4 source | ||
# git-core: for interacting with the Go source & subrepos | ||
# gcc, libc-dev: for building Go's bootstrap 'dist' prog | ||
# gcc-s390x-linux-gnu, libc6-dev-s390x-cross: for s390x builds | ||
# systemd: for init when image is used with docker2boot | ||
# net-tools, ifupdown, isc-dhcp-client: required for networking in a VM on GCE | ||
# procps, lsof, psmisc: misc tools | ||
RUN apt-get update && apt-get install -y \ | ||
bzip2 \ | ||
ca-certificates \ | ||
curl \ | ||
git-core \ | ||
gcc \ | ||
libc6-dev \ | ||
gcc-s390x-linux-gnu \ | ||
libc6-dev-s390x-cross \ | ||
systemd \ | ||
net-tools \ | ||
ifupdown \ | ||
isc-dhcp-client \ | ||
procps \ | ||
lsof \ | ||
psmisc \ | ||
--no-install-recommends \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p /go1.4-amd64 \ | ||
&& ( \ | ||
curl --silent https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz | tar -C /go1.4-amd64 -zxv \ | ||
) \ | ||
&& mv /go1.4-amd64/go /go1.4 \ | ||
&& rm -rf /go1.4-amd64 \ | ||
&& rm -rf /go1.4/pkg/linux_amd64_race \ | ||
/go1.4/api \ | ||
/go1.4/blog \ | ||
/go1.4/doc \ | ||
/go1.4/misc \ | ||
/go1.4/test \ | ||
&& find /go1.4 -type d -name testdata | xargs rm -rf | ||
|
||
RUN curl -o /usr/local/bin/stage0 https://storage.googleapis.com/go-builder-data/stage0.linux-amd64.92ebb4ec \ | ||
&& chmod +x /usr/local/bin/stage0 | ||
|
||
COPY buildlet.service /etc/systemd/system/buildlet.service | ||
RUN systemctl enable /etc/systemd/system/buildlet.service | ||
|
||
RUN rm -f /lib/systemd/system/multi-user.target.wants/systemd-logind.service | ||
RUN (echo "[Journal]"; echo "ForwardToConsole=yes") > /etc/systemd/journald.conf | ||
|
||
RUN (echo "auto lo"; echo "iface lo inet loopback"; echo "auto eth0"; echo "iface eth0 inet dhcp") > /etc/network/interfaces | ||
|
||
ENV GOROOT_BOOTSTRAP=/go1.4 GOOS=linux GOARCH=s390x CC_FOR_TARGET=s390x-linux-gnu-gcc | ||
COPY build-release.sh /usr/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright 2016 The Go Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file. | ||
|
||
docker: Dockerfile | ||
docker build --rm --force-rm -t gobuilders/linux-s390x-stretch . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
The docker image created from this directory can be used to cross compile go | ||
from linux/amd64 to linux/s390x. | ||
|
||
How to use: | ||
|
||
$ docker run --rm -it -v $(pwd)/artifacts:/artifacts \ | ||
gobuilders/linux-s390x-stretch build-release.sh $GIT_REV | ||
|
||
This will make the built go artifact, go-${GIT_REV}-linux-s390x.tar.gz, | ||
available in the directory you mounted as `/artifacts` in the container. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
# Copyright 2016 The Go Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file. | ||
set -e | ||
|
||
GIT_REV=$1 | ||
if [[ -z "$GIT_REV" ]]; then | ||
GIT_REV=master | ||
fi | ||
|
||
# fetch the source | ||
git clone https://go.googlesource.com/go /usr/src/go | ||
( | ||
cd /usr/src/go | ||
# checkout the specific revision | ||
git checkout "$GIT_REV" | ||
|
||
cd /usr/src/go/src | ||
# build | ||
./bootstrap.bash | ||
|
||
cd / | ||
mv /usr/src/go-${GOOS}-${GOARCH}-bootstrap /go | ||
mkdir -p /artifacts | ||
# tarball the artifact | ||
tar -czvf /artifacts/go-${GIT_REV}-${GOOS}-${GOARCH}.tar.gz /go | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Unit] | ||
Description=Buildlet | ||
|
||
[Service] | ||
ExecStart=/usr/local/bin/stage0 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |