Added seed code for caas-kubedns.
[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
19 ENV KUBEDNS_VERSION=$KUBEDNS
20 ENV GOPATH /build
21 ENV PATH /usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
22
23 RUN apk update \
24 &&  apk upgrade \
25 &&  apk add sudo \
26 &&  apk add --update libcap \
27 &&  adduser -u 145 -D -H -s /sbin/nologin kubedns \
28 &&  mkdir -p /home/kubedns \
29 &&  chown -R kubedns:kubedns /home/kubedns \
30 &&  chown -R kubedns:kubedns /etc \
31 &&  apk add --no-cache --virtual .build-deps build-base git mercurial go glide bash tar curl \
32 &&  apk add --no-cache dnsmasq \
33 &&  mkdir -p $GOPATH/src/k8s.io/dns \
34 &&  curl -fsSL -k https://github.com/kubernetes/dns/archive/${KUBEDNS_VERSION}.tar.gz | tar zx --strip-components=1 -C $GOPATH/src/k8s.io/dns \
35 &&  cd $GOPATH/src/k8s.io/dns \
36 &&  PKG=k8s.io/dns ARCH=amd64 VERSION=${KUBEDNS_VERSION} ./build/build.sh \
37 &&  mv $GOPATH/bin/linux_amd64/kube-dns /usr/bin/kube-dns \
38 &&  mv $GOPATH/bin/linux_amd64/dnsmasq-nanny /usr/bin/dnsmasq-nanny \
39 &&  setcap 'cap_net_bind_service=+ep' /usr/sbin/dnsmasq \
40 &&  apk del .build-deps \
41 &&  rm -rf $GOPATH \
42 &&  rm -rf /build \
43 &&  rm -rf /root/.glide
44
45 USER kubedns
46 ENV HOME /home/kubedns
47 WORKDIR $HOME
48
49