33dad869d730deacd0d2ced36219462cc4cf8df2
[ta/caas-cpupooler.git] / docker-build / cpupooler / 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 DEPENDENCY_MANAGER
19 ENV DEP_VERSION=$DEPENDENCY_MANAGER
20 ARG CPUPOOLER
21 ENV CPUPOOLER_VERSION=$CPUPOOLER
22 ENV GOPATH /build
23 ENV PATH /usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
24
25 RUN apk update \
26 &&  apk upgrade \
27 &&  apk add --no-cache --virtual .build-deps build-base git mercurial go glide bash tar curl \
28 &&  mkdir -p $GOPATH/src/github.com/nokia/CPU-Pooler \
29 &&  curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 \
30 &&  chmod +x /usr/local/bin/dep \
31 &&  curl -fsSL -k https://github.com/nokia/CPU-Pooler/archive/v${CPUPOOLER_VERSION}.tar.gz | tar zx --strip-components=1 -C $GOPATH/src/github.com/nokia/CPU-Pooler \
32 &&  cd $GOPATH/src/github.com/nokia/CPU-Pooler \
33 &&  dep ensure --vendor-only \
34 # cpu-device-plugin
35 &&  CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o cpu-device-plugin ./cmd/cpu-device-plugin \
36 &&  mv $GOPATH/src/github.com/nokia/CPU-Pooler/cpu-device-plugin /cpu-device-plugin \
37 # cpu-setter
38 &&  CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o cpu-setter ./cmd/cpusetter \
39 &&  mv $GOPATH/src/github.com/nokia/CPU-Pooler/cpu-setter /cpu-setter \
40 # cpu-webhook
41 &&  CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o cpu-device-webhook ./cmd/webhook \
42 &&  mv $GOPATH/src/github.com/nokia/CPU-Pooler/cpu-device-webhook /cpu-device-webhook \
43 &&  apk del .build-deps \
44 &&  rm -rf $GOPATH \
45 &&  rm -rf /build \
46 &&  rm -rf /root/.glide
47