AArch64 support
[ta/caas-kubedns.git] / docker-build / kubedns / Dockerfile
1 # Copyright 2019 Nokia
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 FROM alpine:3.9
16 MAINTAINER Balazs Szekeres <balazs.szekeres@nokia.com>
17
18 ARG KUBEDNS_VERSION
19 ENV GOPATH /build
20 ARG go_install_dir="/usr/local/go"
21 ARG go_version
22 ENV PATH="$go_install_dir/bin:$PATH"
23
24 RUN apk update \
25 &&  apk upgrade \
26 &&  apk add sudo \
27 &&  apk add --update libcap \
28 &&  adduser -u 145 -D -H -s /sbin/nologin kubedns \
29 &&  mkdir -p /home/kubedns \
30 &&  chown -R kubedns:kubedns /home/kubedns \
31 &&  chown -R kubedns:kubedns /etc \
32 &&  apk add --no-cache --virtual .build-deps build-base git mercurial go glide bash tar curl \
33 &&  apk add --no-cache dnsmasq \
34 &&  mkdir -p $go_install_dir \
35 &&  curl -fsSL -k https://dl.google.com/go/go${go_version}.src.tar.gz | tar zx --strip-components=1 -C ${go_install_dir} \
36 &&  cd ${go_install_dir}/src/ \
37 &&  ./make.bash \
38 &&  mkdir -p $GOPATH/src/k8s.io/dns \
39 &&  curl -fsSL -k https://github.com/kubernetes/dns/archive/${KUBEDNS_VERSION}.tar.gz | tar zx --strip-components=1 -C $GOPATH/src/k8s.io/dns \
40 &&  cd $GOPATH/src/k8s.io/dns \
41 &&  if [ $(uname -m) == 'aarch64' ]; then HOST_ARCH=arm64; else HOST_ARCH=amd64; ARCH_SUBDIR=linux_amd64; fi \
42 &&  PKG=k8s.io/dns ARCH=${HOST_ARCH} VERSION=${KUBEDNS_VERSION} ./build/build.sh \
43 &&  mv $GOPATH/bin/${ARCH_SUBDIR:-}/kube-dns /usr/bin/kube-dns \
44 &&  mv $GOPATH/bin/${ARCH_SUBDIR:-}/dnsmasq-nanny /usr/bin/dnsmasq-nanny \
45 &&  setcap 'cap_net_bind_service=+ep' /usr/sbin/dnsmasq \
46 &&  apk del .build-deps \
47 &&  rm -rf $GOPATH \
48 &&  rm -rf $go_install_dir \
49 &&  rm -rf /build \
50 &&  rm -rf /root/.glide
51
52 USER kubedns
53 ENV HOME /home/kubedns
54 WORKDIR $HOME
55
56