Skip to content

Commit 9f9a67f

Browse files
committed
Fixed docker test image (wrt alpine) used for running local-process tests
1 parent 2dc76aa commit 9f9a67f

File tree

3 files changed

+99
-40
lines changed

3 files changed

+99
-40
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ run-tests-local-process: build test-images
167167
--rm \
168168
--name=$(TESTCONTAINER) \
169169
-v $(ROOTDIR):/usr/code \
170+
-e CGO_ENABLED=0 \
170171
-e GOPATH=/usr/code/.gobuild \
171172
-e DATA_DIR=/tmp \
172173
-e STARTER=/usr/code/bin/linux/amd64/arangodb \

test/Dockerfile-arangodb-golang

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,14 @@
11
ARG from
22
FROM ${from}
33

4-
# gcc for cgo
5-
RUN apt-get update && apt-get install -y --no-install-recommends \
6-
g++ \
7-
gcc \
8-
libc6-dev \
9-
make \
10-
pkg-config \
11-
wget \
12-
ca-certificates \
13-
procps \
14-
&& rm -rf /var/lib/apt/lists/*
4+
RUN uname -a
155

16-
ENV GOLANG_VERSION 1.9
6+
# If you change this, make matching changes in docker_install_go.sh
7+
# to reflect the hashes.
8+
ENV GOLANG_VERSION 1.10.1
179

18-
RUN set -eux; \
19-
\
20-
dpkgArch="$(dpkg --print-architecture)"; \
21-
case "${dpkgArch##*-}" in \
22-
ppc64el) goRelArch='linux-ppc64le';; \
23-
i386) goRelArch='linux-386';; \
24-
s390x) goRelArch='linux-s390x';; \
25-
armhf) goRelArch='linux-armv6l';; \
26-
amd64) goRelArch='linux-amd64';; \
27-
*) goRelArch='src'; \
28-
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
29-
esac; \
30-
\
31-
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
32-
wget -q -O go.tgz "$url"; \
33-
tar -C /usr/local -xzf go.tgz; \
34-
rm go.tgz; \
35-
\
36-
if [ "$goRelArch" = 'src' ]; then \
37-
echo >&2; \
38-
echo >&2 'error: UNIMPLEMENTED'; \
39-
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
40-
echo >&2; \
41-
exit 1; \
42-
fi; \
43-
\
44-
export PATH="/usr/local/go/bin:$PATH"; \
45-
go version
10+
ADD test/docker_install_go.sh /bin
11+
RUN /bin/docker_install_go.sh
4612

4713
ENV GOPATH /go
4814
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH

test/docker_install_go.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/sh
2+
3+
if [ ! -z "$(which apt-get)" ]; then
4+
# Install for debian
5+
# gcc for cgo
6+
apt-get update && apt-get install -y --no-install-recommends \
7+
g++ \
8+
gcc \
9+
libc6-dev \
10+
make \
11+
pkg-config \
12+
wget \
13+
procps \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
set -eux; \
17+
\
18+
# this "case" statement is generated via "update.sh"
19+
dpkgArch="$(dpkg --print-architecture)"; \
20+
case "${dpkgArch##*-}" in \
21+
amd64) goRelArch='linux-amd64'; goRelSha256='72d820dec546752e5a8303b33b009079c15c2390ce76d67cf514991646c6127b' ;; \
22+
armhf) goRelArch='linux-armv6l'; goRelSha256='feca4e920d5ca25001dc0823390df79bc7ea5b5b8c03483e5a2c54f164654936' ;; \
23+
arm64) goRelArch='linux-arm64'; goRelSha256='1e07a159414b5090d31166d1a06ee501762076ef21140dcd54cdcbe4e68a9c9b' ;; \
24+
i386) goRelArch='linux-386'; goRelSha256='acbe19d56123549faf747b4f61b730008b185a0e2145d220527d2383627dfe69' ;; \
25+
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='91d0026bbed601c4aad332473ed02f9a460b31437cbc6f2a37a88c0376fc3a65' ;; \
26+
s390x) goRelArch='linux-s390x'; goRelSha256='e211a5abdacf843e16ac33a309d554403beb63959f96f9db70051f303035434b' ;; \
27+
*) goRelArch='src'; goRelSha256='589449ff6c3ccbff1d391d4e7ab5bb5d5643a5a41a04c99315e55c16bbf73ddc'; \
28+
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
29+
esac; \
30+
\
31+
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
32+
wget -O go.tgz "$url"; \
33+
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
34+
tar -C /usr/local -xzf go.tgz; \
35+
rm go.tgz; \
36+
\
37+
if [ "$goRelArch" = 'src' ]; then \
38+
echo >&2; \
39+
echo >&2 'error: UNIMPLEMENTED'; \
40+
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
41+
echo >&2; \
42+
exit 1; \
43+
fi; \
44+
\
45+
export PATH="/usr/local/go/bin:$PATH"; \
46+
go version
47+
else
48+
# Install for alpine
49+
set -eux; \
50+
apk add --no-cache --virtual .build-deps \
51+
bash \
52+
gcc \
53+
musl-dev \
54+
openssl \
55+
go \
56+
; \
57+
export \
58+
# set GOROOT_BOOTSTRAP such that we can actually build Go
59+
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
60+
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
61+
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
62+
GOOS="$(go env GOOS)" \
63+
GOARCH="$(go env GOARCH)" \
64+
GOHOSTOS="$(go env GOHOSTOS)" \
65+
GOHOSTARCH="$(go env GOHOSTARCH)" \
66+
; \
67+
# also explicitly set GO386 and GOARM if appropriate
68+
# https://github.com/docker-library/golang/issues/184
69+
apkArch="$(apk --print-arch)"; \
70+
case "$apkArch" in \
71+
armhf) export GOARM='6' ;; \
72+
x86) export GO386='387' ;; \
73+
esac; \
74+
\
75+
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
76+
echo '589449ff6c3ccbff1d391d4e7ab5bb5d5643a5a41a04c99315e55c16bbf73ddc *go.tgz' | sha256sum -c -; \
77+
tar -C /usr/local -xzf go.tgz; \
78+
rm go.tgz; \
79+
\
80+
cd /usr/local/go/src; \
81+
for p in /go-alpine-patches/*.patch; do \
82+
[ -f "$p" ] || continue; \
83+
patch -p2 -i "$p"; \
84+
done; \
85+
./make.bash; \
86+
\
87+
rm -rf /go-alpine-patches; \
88+
apk del .build-deps; \
89+
\
90+
export PATH="/usr/local/go/bin:$PATH"; \
91+
go version
92+
fi

0 commit comments

Comments
 (0)