Manifest update
[ta/caas-danm.git] / docker-build / netwatcher / 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 Levente Kale <levente.kale@nokia.com>
17
18 ARG NETWATCHER
19 ENV NETWATCHER_VERSION=$NETWATCHER
20 ENV GOPATH /go
21 ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
22 ENV CGO_ENABLED=0
23 ENV GOOS=linux
24 ARG code_generator_version="kubernetes-1.13.4"
25
26 WORKDIR /
27
28 RUN mkdir -p $GOPATH/bin \
29 &&  mkdir -p $GOPATH/src
30
31 RUN apk add --no-cache curl libcap iputils
32
33 RUN apk add --no-cache --virtual .tools ca-certificates gcc musl-dev go glide git \
34 &&  mkdir -p $GOPATH/src/github.com/nokia \
35 &&  git clone https://github.com/nokia/danm.git $GOPATH/src/github.com/nokia/danm \
36 &&  cd $GOPATH/src/github.com/nokia/danm \
37 &&  git fetch --tags \
38 &&  git checkout ${NETWATCHER_VERSION} \
39 &&  glide install --strip-vendor \
40 &&  go get -d github.com/vishvananda/netlink \
41 &&  go get github.com/containernetworking/plugins/pkg/ns \
42 &&  go get github.com/golang/groupcache/lru \
43 &&  rm -rf $GOPATH/src/k8s.io/code-generator \
44 &&  git clone -b ${code_generator_version} --depth 1 https://github.com/kubernetes/code-generator.git $GOPATH/src/k8s.io/code-generator \
45 &&  go install k8s.io/code-generator/cmd/deepcopy-gen \
46 &&  go install k8s.io/code-generator/cmd/client-gen \
47 &&  go install k8s.io/code-generator/cmd/lister-gen \
48 &&  go install k8s.io/code-generator/cmd/informer-gen \
49 &&  deepcopy-gen --alsologtostderr --input-dirs github.com/nokia/danm/crd/apis/danm/v1 -O zz_generated.deepcopy --bounding-dirs github.com/nokia/danm/crd/apis \
50 &&  client-gen --alsologtostderr --clientset-name versioned --input-base "" --input github.com/nokia/danm/crd/apis/danm/v1 --clientset-path github.com/nokia/danm/crd/client/clientset \
51 &&  lister-gen --alsologtostderr --input-dirs github.com/nokia/danm/crd/apis/danm/v1 --output-package github.com/nokia/danm/crd/client/listers \
52 &&  informer-gen --alsologtostderr --input-dirs github.com/nokia/danm/crd/apis/danm/v1 --versioned-clientset-package github.com/nokia/danm/crd/client/clientset/versioned --listers-package github.com/nokia/danm/crd/client/listers --output-package github.com/nokia/danm/crd/client/informers \
53 &&  go install -a -ldflags '-extldflags "-static"' github.com/nokia/danm/cmd/netwatcher \
54 &&  cp $GOPATH/bin/netwatcher /usr/local/bin/netwatcher \
55 &&  rm -rf $GOPATH/src \
56 &&  rm -rf $GOPATH/bin \
57 &&  apk del .tools \
58 &&  rm -rf /var/cache/apk/* \
59 &&  rm -rf /var/lib/apt/lists/* \
60 &&  rm -rf /tmp/* \
61 &&  rm -rf ~/.glide
62
63 RUN adduser -u 147 -D -H -s /sbin/nologin danm \
64 &&  chown root:danm /usr/local/bin/netwatcher \
65 &&  chmod 750 /usr/local/bin/netwatcher \
66 &&  setcap cap_sys_ptrace,cap_sys_admin,cap_net_admin=eip /usr/local/bin/netwatcher \
67 &&  setcap cap_net_raw=eip /usr/sbin/arping
68
69 USER danm
70
71 ENTRYPOINT ["/usr/local/bin/netwatcher"]