Dockerfile 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Copyright 2016 The Kubernetes Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # This file creates a standard build environment for building cross
  15. # platform go binary for the architecture kubernetes cares about.
  16. FROM golang:1.12.9
  17. ENV GOARM 7
  18. ENV KUBE_DYNAMIC_CROSSPLATFORMS \
  19. armhf \
  20. arm64 \
  21. s390x \
  22. ppc64el
  23. ENV KUBE_CROSSPLATFORMS \
  24. linux/386 \
  25. linux/arm linux/arm64 \
  26. linux/ppc64le \
  27. linux/s390x \
  28. darwin/amd64 darwin/386 \
  29. windows/amd64 windows/386
  30. # Pre-compile the standard go library when cross-compiling. This is much easier now when we have go1.5+
  31. RUN for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${platform##*/} go install std; done \
  32. && go clean -cache
  33. # Install g++, then download and install protoc for generating protobuf output
  34. RUN apt-get update \
  35. && apt-get install -y rsync jq apt-utils file patch unzip \
  36. && apt-get clean && rm -rf /var/lib/apt/lists/*
  37. # Use dynamic cgo linking for architectures other than amd64 for the server platforms
  38. # To install crossbuild essential for other architectures add the following repository.
  39. RUN echo "deb http://archive.ubuntu.com/ubuntu xenial main universe" > /etc/apt/sources.list.d/cgocrosscompiling.list \
  40. && apt-key adv --no-tty --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 3B4FE6ACC0B21F32 \
  41. && apt-get update \
  42. && apt-get install -y build-essential \
  43. && for platform in ${KUBE_DYNAMIC_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \
  44. && apt-get clean && rm -rf /var/lib/apt/lists/*
  45. RUN PROTOBUF_VERSION=3.0.2; ZIPNAME="protoc-${PROTOBUF_VERSION}-linux-x86_64.zip"; \
  46. mkdir /tmp/protoc && cd /tmp/protoc \
  47. && wget "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/${ZIPNAME}" \
  48. && unzip "${ZIPNAME}" \
  49. && chmod -R +rX /tmp/protoc \
  50. && cp -pr bin /usr/local \
  51. && cp -pr include /usr/local \
  52. && rm -rf /tmp/protoc \
  53. && protoc --version
  54. # work around 64MB tmpfs size in Docker 1.6
  55. ENV TMPDIR /tmp.k8s
  56. RUN mkdir $TMPDIR \
  57. && chmod a+rwx $TMPDIR \
  58. && chmod o+t $TMPDIR
  59. # Get the code coverage tool and goimports
  60. RUN go get golang.org/x/tools/cmd/cover \
  61. golang.org/x/tools/cmd/goimports \
  62. && go clean -cache
  63. # Download and symlink etcd. We need this for our integration tests.
  64. RUN export ETCD_VERSION=v3.2.24; \
  65. mkdir -p /usr/local/src/etcd \
  66. && cd /usr/local/src/etcd \
  67. && curl -fsSL https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz | tar -xz \
  68. && ln -s ../src/etcd/etcd-${ETCD_VERSION}-linux-amd64/etcd /usr/local/bin/