forked from projectcalico/go-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.amd64
95 lines (72 loc) · 3.82 KB
/
Dockerfile.amd64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
FROM amd64/golang:1.12.14-alpine3.10
MAINTAINER Tom Denham <tom@projectcalico.org>
ARG QEMU_VERSION=2.9.1-1
# we need these two distinct lists. The first one is the names used by the qemu distributions
# these second is the names used by golang see https://github.com/golang/go/blob/master/src/go/build/syslist.go
# the primary difference as of this writing is that qemu uses aarch64 and golang uses arm64
ARG QEMU_ARCHS="aarch64 ppc64le s390x"
ARG CROSS_ARCHS="arm64 ppc64le s390x"
ARG MANIFEST_TOOL_VERSION=v0.7.0
# Install su-exec for use in the entrypoint.sh (so processes run as the right user)
# Install bash for the entry script (and because it's generally useful)
# Install curl to download glide
# Install git for fetching Go dependencies
# Install ssh for fetching Go dependencies
# Install mercurial for fetching go dependencies
# Install wget since it's useful for fetching
# Install make for building things
# Install util-linux for column command (used for output formatting).
# Install grep and sed for use in some Makefiles (e.g. pulling versions out of glide.yaml)
# Install libc6-compat for fossa client
# Install shadow for useradd (it allows to use big UID)
RUN apk update && apk upgrade --available
RUN apk add --no-cache su-exec curl bash git openssh mercurial make wget util-linux tini file grep sed libc6-compat shadow
RUN apk upgrade --no-cache
# Install fossa for foss license checks
ARG FOSSA_VER=1.0.1
RUN curl -L https://github.com/fossas/fossa-cli/releases/download/v${FOSSA_VER}/fossa-cli_${FOSSA_VER}_linux_amd64.tar.gz | tar zxvf - -C /usr/local/bin --extract fossa
RUN chmod +x /usr/local/bin/fossa
# Disable ssh host key checking
RUN echo 'Host *' >> /etc/ssh/ssh_config \
&& echo ' StrictHostKeyChecking no' >> /etc/ssh/ssh_config
# Disable cgo so that binaries we build will be fully static.
ENV CGO_ENABLED=0
# Recompile the standard library with cgo disabled. This prevents the standard library from being
# marked stale, causing full rebuilds every time.
RUN go install -v std
# Install glide
RUN go get github.com/Masterminds/glide
ENV GLIDE_HOME /home/user/.glide
# Install dep
RUN go get github.com/golang/dep/cmd/dep
# Install ginkgo CLI tool for running tests
RUN go get github.com/onsi/ginkgo/ginkgo
# Install linting tools.
RUN go get golang.org/x/tools/cmd/goimports
RUN wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.20.0
RUN golangci-lint --version
# Install license checking tool.
RUN go get github.com/pmezard/licenses
# Install tool to merge coverage reports.
RUN go get github.com/wadey/gocovmerge
# Install CLI tool for working with yaml files
RUN go get github.com/mikefarah/yaml
# Install vgo (should be removed once we take Go 1.11)
RUN go get -u golang.org/x/vgo
# Install tool to convert go-test output to junit
RUN go get -u github.com/jstemmer/go-junit-report
# Enable non-native runs on amd64 architecture hosts
RUN for i in ${QEMU_ARCHS}; do curl -L https://github.com/multiarch/qemu-user-static/releases/download/v${QEMU_VERSION}/qemu-${i}-static.tar.gz | tar zxvf - -C /usr/bin; done
RUN chmod +x /usr/bin/qemu-*
# When running cross built binaries run-times will be auto-installed,
# ensure the install directory is writable by everyone.
RUN for arch in ${CROSS_ARCHS}; do mkdir -m +w -p /usr/local/go/pkg/linux_${arch}; GOARCH=${arch} go install -v std; done
# Delete all the Go sources that were downloaded, we only rely on the binaries
RUN rm -rf /go/src/*
# Ensure that everything under the GOPATH is writable by everyone
RUN chmod -R 777 $GOPATH
RUN curl -sSL https://github.com/estesp/manifest-tool/releases/download/${MANIFEST_TOOL_VERSION}/manifest-tool-linux-amd64 > manifest-tool && \
chmod +x manifest-tool && \
mv manifest-tool /usr/bin/
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/entrypoint.sh"]