Skip to content

Commit cef5bd3

Browse files
committed
Merge branch 'master' of github.com:docker-library/golang
# Conflicts: # 1.6/Dockerfile
2 parents b9c722f + 301d61a commit cef5bd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1451
-814
lines changed

.appveyor.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: build-{build}.{branch}
2+
image: Visual Studio 2017
3+
4+
environment:
5+
matrix:
6+
- version: 1.11
7+
variant: windowsservercore-ltsc2016
8+
- version: 1.11
9+
variant: nanoserver-sac2016
10+
- version: 1.10
11+
variant: windowsservercore-ltsc2016
12+
- version: 1.10
13+
variant: nanoserver-sac2016
14+
15+
install:
16+
- ps: |
17+
[Environment]::SetEnvironmentVariable('dockerImage', ('golang:{0}' -f $env:version), [EnvironmentVariableTarget]::Process);
18+
[Environment]::SetEnvironmentVariable('buildDirectory', ('{0}/windows/{1}' -f $env:version, $env:variant), [EnvironmentVariableTarget]::Process);
19+
20+
build_script:
21+
- cmd: appveyor-retry docker build --pull -t %dockerImage% %buildDirectory%
22+
23+
after_build:
24+
- ps: docker images
25+
26+
test_script:
27+
- ps: docker run --rm $env:dockerImage go version

.architectures-lib

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
_awkArch() {
4+
local version="$1"; shift
5+
local awkExpr="$1"; shift
6+
awk "$@" "/^#|^\$/ { next } $awkExpr" "$version/release-architectures"
7+
}
8+
9+
dpkgArches() {
10+
local version="$1"; shift
11+
_awkArch "$version" '{ print $2 }'
12+
}
13+
14+
hasBashbrewArch() {
15+
local version="$1"; shift
16+
local bashbrewArch="$1"; shift
17+
_awkArch "$version" 'BEGIN { exitCode = 1 } $1 == bashbrewArch { exitCode = 0 } END { exit exitCode }' -v bashbrewArch="$bashbrewArch"
18+
}
19+
20+
dpkgToGoArch() {
21+
local version="$1"; shift
22+
local dpkgArch="$1"; shift
23+
_awkArch "$version" '$2 == dpkgArch { print $3; exit }' -v dpkgArch="$dpkgArch"
24+
}
25+
26+
_generateParentRepoToArches() {
27+
local repo="$1"; shift
28+
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
29+
30+
eval "declare -g -A parentRepoToArches=( $(
31+
find -name 'Dockerfile' -exec awk '
32+
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
33+
print "'"$officialImagesUrl"'" $2
34+
}
35+
' '{}' + \
36+
| sort -u \
37+
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
38+
) )"
39+
}
40+
_generateParentRepoToArches 'golang'
41+
42+
parentArches() {
43+
local version="$1"; shift # "1.8", etc
44+
local variant="$1"; shift # "", "stretch", etc
45+
46+
local parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")"
47+
echo "${parentRepoToArches[$parent]:-}"
48+
}
49+
variantArches() {
50+
local version="$1"; shift # "1.8", etc
51+
local variant="$1"; shift # "", "stretch", etc
52+
53+
local parentArches="$(parentArches "$version" "$variant")"
54+
55+
local variantArches=()
56+
for arch in $parentArches; do
57+
if hasBashbrewArch "$version" "$arch"; then
58+
variantArches+=( "$arch" )
59+
fi
60+
done
61+
echo "${variantArches[*]}"
62+
}

.travis.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,26 @@ language: bash
22
services: docker
33

44
env:
5-
- VERSION=1.6 VARIANT=
6-
- VERSION=1.6 VARIANT=wheezy
7-
- VERSION=1.6 VARIANT=alpine
8-
- VERSION=1.5 VARIANT=
9-
- VERSION=1.5 VARIANT=wheezy
10-
- VERSION=1.5 VARIANT=alpine
5+
- VERSION=1.11 VARIANT=stretch
6+
- VERSION=1.11 VARIANT=alpine3.8
7+
- VERSION=1.11 VARIANT=alpine3.7
8+
- VERSION=1.10 VARIANT=stretch
9+
- VERSION=1.10 VARIANT=alpine3.8
10+
- VERSION=1.10 VARIANT=alpine3.7
1111

1212
install:
1313
- git clone https://github.com/docker-library/official-images.git ~/official-images
1414

1515
before_script:
1616
- env | sort
1717
- cd "$VERSION"
18-
- image="$(awk '$1 == "FROM" { print $2; exit }' onbuild/Dockerfile)${VARIANT:+-$VARIANT}"
18+
- image="golang:$VERSION${VARIANT:+-$VARIANT}"
1919

2020
script:
21-
- docker build -t "$image" "${VARIANT:-.}"
21+
- travis_retry docker build -t "$image" "${VARIANT:-.}"
2222
- ~/official-images/test/run.sh "$image"
2323
# the "onbuild" variant has to happen with the base variant because it's FROM it
24-
- true && [ "$VARIANT" ] || docker build -t "${image}-onbuild" onbuild
25-
# the "cross" variant has to happen with the base variant because it's FROM it
26-
- if [ -d cross -a -z "$VARIANT" ]; then
27-
docker build -t "${image}-cross" cross;
28-
fi
24+
- if [ -z "$VARIANT" ] && [ -d onbuild ]; then travis_retry docker build -t "${image}-onbuild" onbuild; fi
2925

3026
after_script:
3127
- docker images

1.10/alpine3.7/Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM alpine:3.7
2+
3+
RUN apk add --no-cache \
4+
ca-certificates
5+
6+
# set up nsswitch.conf for Go's "netgo" implementation
7+
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
8+
# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
9+
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
10+
11+
ENV GOLANG_VERSION 1.10.4
12+
13+
RUN set -eux; \
14+
apk add --no-cache --virtual .build-deps \
15+
bash \
16+
gcc \
17+
musl-dev \
18+
openssl \
19+
go \
20+
; \
21+
export \
22+
# set GOROOT_BOOTSTRAP such that we can actually build Go
23+
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
24+
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
25+
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
26+
GOOS="$(go env GOOS)" \
27+
GOARCH="$(go env GOARCH)" \
28+
GOHOSTOS="$(go env GOHOSTOS)" \
29+
GOHOSTARCH="$(go env GOHOSTARCH)" \
30+
; \
31+
# also explicitly set GO386 and GOARM if appropriate
32+
# https://github.com/docker-library/golang/issues/184
33+
apkArch="$(apk --print-arch)"; \
34+
case "$apkArch" in \
35+
armhf) export GOARM='6' ;; \
36+
x86) export GO386='387' ;; \
37+
esac; \
38+
\
39+
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
40+
echo '6fe44965ed453cd968a81988523e9b0e794d3a478f91fd7983c28763d52d5781 *go.tgz' | sha256sum -c -; \
41+
tar -C /usr/local -xzf go.tgz; \
42+
rm go.tgz; \
43+
\
44+
cd /usr/local/go/src; \
45+
./make.bash; \
46+
\
47+
rm -rf \
48+
# https://github.com/golang/go/blob/0b30cf534a03618162d3015c8705dd2231e34703/src/cmd/dist/buildtool.go#L121-L125
49+
/usr/local/go/pkg/bootstrap \
50+
# https://golang.org/cl/82095
51+
# https://github.com/golang/build/blob/e3fe1605c30f6a3fd136b561569933312ede8782/cmd/release/releaselet.go#L56
52+
/usr/local/go/pkg/obj \
53+
; \
54+
apk del .build-deps; \
55+
\
56+
export PATH="/usr/local/go/bin:$PATH"; \
57+
go version
58+
59+
ENV GOPATH /go
60+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
61+
62+
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
63+
WORKDIR $GOPATH

1.10/alpine3.8/Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM alpine:3.8
2+
3+
RUN apk add --no-cache \
4+
ca-certificates
5+
6+
# set up nsswitch.conf for Go's "netgo" implementation
7+
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
8+
# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
9+
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
10+
11+
ENV GOLANG_VERSION 1.10.4
12+
13+
RUN set -eux; \
14+
apk add --no-cache --virtual .build-deps \
15+
bash \
16+
gcc \
17+
musl-dev \
18+
openssl \
19+
go \
20+
; \
21+
export \
22+
# set GOROOT_BOOTSTRAP such that we can actually build Go
23+
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
24+
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
25+
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
26+
GOOS="$(go env GOOS)" \
27+
GOARCH="$(go env GOARCH)" \
28+
GOHOSTOS="$(go env GOHOSTOS)" \
29+
GOHOSTARCH="$(go env GOHOSTARCH)" \
30+
; \
31+
# also explicitly set GO386 and GOARM if appropriate
32+
# https://github.com/docker-library/golang/issues/184
33+
apkArch="$(apk --print-arch)"; \
34+
case "$apkArch" in \
35+
armhf) export GOARM='6' ;; \
36+
x86) export GO386='387' ;; \
37+
esac; \
38+
\
39+
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
40+
echo '6fe44965ed453cd968a81988523e9b0e794d3a478f91fd7983c28763d52d5781 *go.tgz' | sha256sum -c -; \
41+
tar -C /usr/local -xzf go.tgz; \
42+
rm go.tgz; \
43+
\
44+
cd /usr/local/go/src; \
45+
./make.bash; \
46+
\
47+
rm -rf \
48+
# https://github.com/golang/go/blob/0b30cf534a03618162d3015c8705dd2231e34703/src/cmd/dist/buildtool.go#L121-L125
49+
/usr/local/go/pkg/bootstrap \
50+
# https://golang.org/cl/82095
51+
# https://github.com/golang/build/blob/e3fe1605c30f6a3fd136b561569933312ede8782/cmd/release/releaselet.go#L56
52+
/usr/local/go/pkg/obj \
53+
; \
54+
apk del .build-deps; \
55+
\
56+
export PATH="/usr/local/go/bin:$PATH"; \
57+
go version
58+
59+
ENV GOPATH /go
60+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
61+
62+
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
63+
WORKDIR $GOPATH

1.10/release-architectures

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# see https://golang.org/dl/
2+
3+
# bashbrew-arch dpkg-arch golang-release-arch
4+
amd64 amd64 amd64
5+
arm32v7 armhf armv6l
6+
arm64v8 arm64 arm64
7+
i386 i386 386
8+
ppc64le ppc64el ppc64le
9+
s390x s390x s390x

1.10/stretch/Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM buildpack-deps:stretch-scm
2+
3+
# gcc for cgo
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
g++ \
6+
gcc \
7+
libc6-dev \
8+
make \
9+
pkg-config \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
ENV GOLANG_VERSION 1.10.4
13+
14+
RUN set -eux; \
15+
\
16+
# this "case" statement is generated via "update.sh"
17+
dpkgArch="$(dpkg --print-architecture)"; \
18+
case "${dpkgArch##*-}" in \
19+
amd64) goRelArch='linux-amd64'; goRelSha256='fa04efdb17a275a0c6e137f969a1c4eb878939e91e1da16060ce42f02c2ec5ec' ;; \
20+
armhf) goRelArch='linux-armv6l'; goRelSha256='4e1e80bd98f3598c0c48ba0c189c836d01b602bfc769b827a4bfed01d2c14b21' ;; \
21+
arm64) goRelArch='linux-arm64'; goRelSha256='2e0f9e99aeefaabba280b2bf85db0336da122accde73603159b3d72d0b2bd512' ;; \
22+
i386) goRelArch='linux-386'; goRelSha256='771f48e55776d4abc9c2a74907457066c7c282ac05fa01cf5ff4422ced76d2ee' ;; \
23+
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='1cfc147357c0be91a988998046997c5f30b20c6baaeb6cd5774717714db76093' ;; \
24+
s390x) goRelArch='linux-s390x'; goRelSha256='5593d770d6544090c1bb20d57bb34c743131470695e195fbe5352bf056927a35' ;; \
25+
*) goRelArch='src'; goRelSha256='6fe44965ed453cd968a81988523e9b0e794d3a478f91fd7983c28763d52d5781'; \
26+
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
27+
esac; \
28+
\
29+
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
30+
wget -O go.tgz "$url"; \
31+
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
32+
tar -C /usr/local -xzf go.tgz; \
33+
rm go.tgz; \
34+
\
35+
if [ "$goRelArch" = 'src' ]; then \
36+
echo >&2; \
37+
echo >&2 'error: UNIMPLEMENTED'; \
38+
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
39+
echo >&2; \
40+
exit 1; \
41+
fi; \
42+
\
43+
export PATH="/usr/local/go/bin:$PATH"; \
44+
go version
45+
46+
ENV GOPATH /go
47+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
48+
49+
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
50+
WORKDIR $GOPATH
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM microsoft/nanoserver:sac2016
2+
3+
# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
4+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
5+
6+
# no Git installed (intentionally)
7+
# -- Nano Server is "Windows Slim"
8+
9+
# ideally, this would be C:\go to match Linux a bit closer, but C:\go is the recommended install path for Go itself on Windows
10+
ENV GOPATH C:\\gopath
11+
12+
# PATH isn't actually set in the Docker image, so we have to set it from within the container
13+
RUN $newPath = ('{0}\bin;C:\go\bin;{1}' -f $env:GOPATH, $env:PATH); \
14+
Write-Host ('Updating PATH: {0}' -f $newPath); \
15+
# Nano Server does not have "[Environment]::SetEnvironmentVariable()"
16+
setx /M PATH $newPath;
17+
# doing this first to share cache across versions more aggressively
18+
19+
ENV GOLANG_VERSION 1.10.4
20+
21+
RUN $url = ('https://golang.org/dl/go{0}.windows-amd64.zip' -f $env:GOLANG_VERSION); \
22+
Write-Host ('Downloading {0} ...' -f $url); \
23+
Invoke-WebRequest -Uri $url -OutFile 'go.zip'; \
24+
\
25+
$sha256 = '5499aa98399664df8dc1da5c3aaaed14b3130b79c713b5677a0ee9e93854476c'; \
26+
Write-Host ('Verifying sha256 ({0}) ...' -f $sha256); \
27+
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $sha256) { \
28+
Write-Host 'FAILED!'; \
29+
exit 1; \
30+
}; \
31+
\
32+
Write-Host 'Expanding ...'; \
33+
Expand-Archive go.zip -DestinationPath C:\; \
34+
\
35+
Write-Host 'Verifying install ("go version") ...'; \
36+
go version; \
37+
\
38+
Write-Host 'Removing ...'; \
39+
Remove-Item go.zip -Force; \
40+
\
41+
Write-Host 'Complete.';
42+
43+
WORKDIR $GOPATH

0 commit comments

Comments
 (0)