Skip to content

Commit e96924f

Browse files
committed
images: Move kube-cross image building to k/release
Signed-off-by: Stephen Augustus <[email protected]>
1 parent a860a07 commit e96924f

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed

images/build/cross/Dockerfile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
15+
# This file creates a standard build environment for building cross
16+
# platform go binary for the architecture kubernetes cares about.
17+
18+
FROM golang:1.13.8
19+
20+
ENV GOARM 7
21+
ENV KUBE_DYNAMIC_CROSSPLATFORMS \
22+
armhf \
23+
arm64 \
24+
s390x \
25+
ppc64el
26+
27+
ENV KUBE_CROSSPLATFORMS \
28+
linux/386 \
29+
linux/arm linux/arm64 \
30+
linux/ppc64le \
31+
linux/s390x \
32+
darwin/amd64 darwin/386 \
33+
windows/amd64 windows/386
34+
35+
# Pre-compile the standard go library when cross-compiling. This is much easier now when we have go1.5+
36+
RUN for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${platform##*/} go install std; done \
37+
&& go clean -cache
38+
39+
# Install g++, then download and install protoc for generating protobuf output
40+
RUN apt-get update \
41+
&& apt-get install -y rsync jq apt-utils file patch unzip \
42+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
43+
44+
# Use dynamic cgo linking for architectures other than amd64 for the server platforms
45+
# To install crossbuild essential for other architectures add the following repository.
46+
RUN echo "deb http://archive.ubuntu.com/ubuntu xenial main universe" > /etc/apt/sources.list.d/cgocrosscompiling.list \
47+
&& apt-key adv --no-tty --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 3B4FE6ACC0B21F32 \
48+
&& apt-get update \
49+
&& apt-get install -y build-essential \
50+
&& for platform in ${KUBE_DYNAMIC_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \
51+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
52+
53+
RUN PROTOBUF_VERSION=3.0.2; ZIPNAME="protoc-${PROTOBUF_VERSION}-linux-x86_64.zip"; \
54+
mkdir /tmp/protoc && cd /tmp/protoc \
55+
&& wget "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/${ZIPNAME}" \
56+
&& unzip "${ZIPNAME}" \
57+
&& chmod -R +rX /tmp/protoc \
58+
&& cp -pr bin /usr/local \
59+
&& cp -pr include /usr/local \
60+
&& rm -rf /tmp/protoc \
61+
&& protoc --version
62+
63+
# work around 64MB tmpfs size in Docker 1.6
64+
ENV TMPDIR /tmp.k8s
65+
RUN mkdir $TMPDIR \
66+
&& chmod a+rwx $TMPDIR \
67+
&& chmod o+t $TMPDIR
68+
69+
# Get the code coverage tool and goimports
70+
RUN go get golang.org/x/tools/cmd/cover \
71+
golang.org/x/tools/cmd/goimports \
72+
&& go clean -cache
73+
74+
# Download and symlink etcd. We need this for our integration tests.
75+
RUN export ETCD_VERSION=v3.2.24; \
76+
mkdir -p /usr/local/src/etcd \
77+
&& cd /usr/local/src/etcd \
78+
&& curl -fsSL https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz | tar -xz \
79+
&& ln -s ../src/etcd/etcd-${ETCD_VERSION}-linux-amd64/etcd /usr/local/bin/

images/build/cross/Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
15+
.PHONY: build push
16+
17+
STAGING_REGISTRY?=gcr.io/k8s-staging-build-image
18+
PROD_REGISTRY?=us.gcr.io/k8s-artifacts-prod/build-image
19+
IMAGE=kube-cross
20+
21+
TAG?=kubernetes-$(shell git describe --tags --match='v*' --abbrev=14)
22+
KUBE_CROSS_VERSION=$(shell cat VERSION)
23+
24+
all: build push
25+
26+
build:
27+
docker build \
28+
-t $(STAGING_REGISTRY)/$(IMAGE):$(TAG) \
29+
-t $(STAGING_REGISTRY)/$(IMAGE):$(KUBE_CROSS_VERSION) \
30+
-t $(PROD_REGISTRY)/$(IMAGE):$(KUBE_CROSS_VERSION) \
31+
.
32+
33+
push:
34+
docker push $(STAGING_REGISTRY)/$(IMAGE):$(TAG)
35+
docker push $(STAGING_REGISTRY)/$(IMAGE):$(KUBE_CROSS_VERSION)

images/build/cross/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v1.13.8-1

images/build/cross/cloudbuild.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# See https://cloud.google.com/cloud-build/docs/build-config
2+
timeout: 1200s
3+
options:
4+
substitution_option: ALLOW_LOOSE
5+
steps:
6+
- name: 'gcr.io/k8s-testimages/gcb-docker-gcloud:v20191019-6567e5c'
7+
entrypoint: make
8+
env:
9+
- DOCKER_CLI_EXPERIMENTAL=enabled
10+
args:
11+
- all
12+
images:
13+
- 'gcr.io/$PROJECT_ID/kube-cross:kubernetes-${_GIT_TAG}'

0 commit comments

Comments
 (0)