8000 Merge pull request #192 from sapk-fork/add-1.9-alpine-3.7 · tomlinux/golang@b928052 · GitHub
[go: up one dir, main page]

Skip to content

Commit b928052

Browse files
authored
Merge pull request docker-library#192 from sapk-fork/add-1.9-alpine-3.7
Add golang:1.9-alpine-3.7
2 parents b177ea2 + 1f07f9c commit b928052

File tree

5 files changed

+206
-0
lines changed

5 files changed

+206
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ services: docker
33

44
env:
55
- VERSION=1.9 VARIANT=stretch
6+
- VERSION=1.9 VARIANT=alpine3.7
67
- VERSION=1.9 VARIANT=alpine3.6
78
- VERSION=1.8 VARIANT=jessie
89
- VERSION=1.8 VARIANT=stretch

1.9/alpine3.7/Dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM alpine:3.7
2+
3+
RUN apk add --no-cache ca-certificates
4+
5+
ENV GOLANG_VERSION 1.9.2
6+
7+
# no-pic.patch: https://golang.org/issue/14851 (Go 1.8 & 1.7)
8+
COPY *.patch /go-alpine-patches/
9+
10+
RUN set -eux; \
11+
apk add --no-cache --virtual .build-deps \
12+
bash \
13+
gcc \
14+
musl-dev \
15+
openssl \
16+
go \
17+
; \
18+
export \
19+
# set GOROOT_BOOTSTRAP such that we can actually build Go
20+
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
21+
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
22+
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
23+
GOOS="$(go env GOOS)" \
24+
GOARCH="$(go env GOARCH)" \
25+
GOHOSTOS="$(go env GOHOSTOS)" \
26+
GOHOSTARCH="$(go env GOHOSTARCH)" \
27+
; \
28+
# also explicitly set GO386 and GOARM if appropriate
29+
# https://github.com/docker-library/golang/issues/184
30+
apkArch="$(apk --print-arch)"; \
31+
case "$apkArch" in \
32+
armhf) export GOARM='6' ;; \
33+
x86) export GO386='387' ;; \
34+
esac; \
35+
\
36+
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
37+
echo '665f184bf8ac89986cfd5a4460736976f60b57df6b320ad71ad4cef53bb143dc *go.tgz' | sha256sum -c -; \
38+
tar -C /usr/local -xzf go.tgz; \
39+
rm go.tgz; \
40+
\
41+
cd /usr/local/go/src; \
42+
for p in /go-alpine-patches/*.patch; do \
43+
[ -f "$p" ] || continue; \
44+
patch -p2 -i "$p"; \
45+
done; \
46+
./make.bash; \
47+
\
48+
rm -rf /go-alpine-patches; \
49+
apk del .build-deps; \
50+
\
51+
export PATH="/usr/local/go/bin:$PATH"; \
52+
go version
53+
54+
ENV GOPATH /go
55+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
56+
57+
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
58+
WORKDIR $GOPATH
59+
60+
COPY go-wrapper /usr/local/bin/
< 8000 div class="d-flex px-1 flex-items-center overflow-hidden flex-order-2 flex-sm-order-1">

1.9/alpine3.7/go-wrapper

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/sh
2+
set -e
3+
4+
usage() {
5+
base="$(basename "$0")"
6+
cat <<EOUSAGE
7+
8+
usage: $base command [args]
9+
10+
This script assumes that it is run from the root of your Go package (for
11+
example, "/go/src/app" if your GOPATH is set to "/go").
12+
13+
In Go 1.4, a feature was introduced to supply the canonical "import path" for a
14+
given package in a comment attached to a package statement
15+
(https://golang.org/s/go14customimport).
16+
17+
This script allows us to take a generic directory of Go source files such as
18+
"/go/src/app" and determine that the canonical "import path" of where that code
19+
expects to live and reference itself is "github.com/jsmith/my-cool-app". It
20+
will then ensure that "/go/src/github.com/jsmith/my-cool-app" is a symlink to
21+
"/go/src/app", which allows us to build and run it under the proper package
22+
name.
23+
24+
For compatibility with versions of Go older than 1.4, the "import path" may also
25+
be placed in a file named ".godir".
26+
27+
Available Commands:
28+
29+
$base download
30+
$base download -u
31+
(equivalent to "go get -d [args] [godir]")
32+
33+
$base install
34+
$base install -race
35+
(equivalent to "go install [args] [godir]")
36+
37+
$base run
38+
$base run -app -specific -arguments
39+
(assumes "GOPATH/bin" is in "PATH")
40+
41+
EOUSAGE
42+
}
43+
44+
# make sure there is a subcommand specified
45+
if [ "$#" -eq 0 ]; then
46+
usage >&2
47+
exit 1
48+
fi
49+
# "shift" so that "$@" becomes the remaining arguments and can be passed along to other "go" subcommands easily
50+
cmd="$1"
51+
shift
52+
53+
goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
54+
55+
if [ -z "$goDir" -a -s .godir ]; then
56+
goDir="$(cat .godir)"
57+
fi
58+
59+
dir="$(pwd -P)"
60+
if [ "$goDir" ]; then
61+
goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too)
62+
goDirPath="$goPath/src/$goDir"
63+
mkdir -p "$(dirname "$goDirPath")"
64+
if [ ! -e "$goDirPath" ]; then
65+
ln -sfv "$dir" "$goDirPath"
66+
elif [ ! -L "$goDirPath" ]; then
67+
echo >&2 "error: $goDirPath already exists but is unexpectedly not a symlink!"
68+
exit 1
69+
fi
70+
goBin="$goPath/bin/$(basename "$goDir")"
71+
else
72+
goBin="$(basename "$dir")" # likely "app"
73+
fi
74+
75+
case "$cmd" in
76+
download)
77+
set -- go get -v -d "$@"
78+
if [ "$goDir" ]; then set -- "$@" "$goDir"; fi
79+
set -x; exec "$@"
80+
;;
81+
82+
install)
83+
set -- go install -v "$@"
84+
if [ "$goDir" ]; then set -- "$@" "$goDir"; fi
85+
set -x; exec "$@"
86+
;;
87+
88+
run)
89+
set -x; exec "$goBin" "$@"
90+
;;
91+
92+
*)
93+
echo >&2 'error: unknown command:' "$cmd"
94+
usage >&2
95+
exit 1
96+
;;
97+
esac
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From 9aea0e89b6df032c29d0add8d69ba2c95f1106d9 Mon Sep 17 00:00:00 2001
2+
From: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
3+
Date: Thu, 10 Aug 2017 14:48:36 -0300
4+
Subject: [PATCH] runtime: make sure R0 is zero before _main on ppc64le
5+
6+
_main has an early check to verify if a binary is statically or dynamically
7+
linked that depends on R0 being zero. R0 is not guaranteed to be zero at that
8+
point and this was breaking Go on Alpine for ppc64le.
9+
10+
Change-Id: I4a1059ff7fd3db6fc489e7dcfe631c1814dd965b
11+
Reviewed-on: https://go-review.googlesource.com/54730
12+
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
13+
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
14+
---
15+
src/runtime/rt0_linux_ppc64le.s | 1 +
16+
1 file changed, 1 insertion(+)
17+
18+
diff --git a/src/runtime/rt0_linux_ppc64le.s b/src/runtime/rt0_linux_ppc64le.s
19+
index 134858bff8..73b9ae392d 100644
20+
--- a/src/runtime/rt0_linux_ppc64le.s
21+
+++ b/src/runtime/rt0_linux_ppc64le.s
22+
@@ -2,6 +2,7 @@
23+
#include "textflag.h"
24+
25+
TEXT _rt0_ppc64le_linux(SB),NOSPLIT,$0
26+
+ XOR R0, R0 // Make sure R0 is zero before _main
27+
BR _main<>(SB)
28+
29+
TEXT _rt0_ppc64le_linux_lib(SB),NOSPLIT,$-8
30+
--
31+
2.14.1
32+

1.9/alpine3.7/no-pic.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
2+
index 6252871..94ef43c 100644
3+
--- a/src/cmd/link/internal/ld/lib.go
4+
+++ b/src/cmd/link/internal/ld/lib.go
5+
@@ -1293,6 +1293,11 @@ func (l *Link) hostlink() {
6+
argv = append(argv, peimporteddlls()...)
7+
}
8+
9+
+ // The Go linker does not currently support building PIE
10+
+ // executables when using the external linker. See:
11+
+ // https://github.com/golang/go/issues/6940
12+
+ argv = append(argv, "-fno-PIC")
13+
+
14+
if l.Debugvlog != 0 {
15+
l.Logf("%5.2f host link:", Cputime())
16+
for _, v := range argv {

0 commit comments

Comments
 (0)
0