Go version update to 1.12.9
[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 DEP_MAN_VERSION
19 ARG CPUPOOLER_VERSION
20 ARG go_install_dir="/usr/local/go"
21 ARG go_version
22 ENV GOPATH /build
23 ENV PATH $go_install_dir/bin:$PATH
24 ENV BUILD_DIR="$GOPATH/src/github.com/nokia/CPU-Pooler"
25
26 RUN apk update \
27 &&  apk upgrade \
28 &&  apk add --no-cache --virtual .build-deps build-base git mercurial go glide bash tar \
29 &&  apk add --no-cache curl \
30 &&  mkdir -p $go_install_dir \
31 &&  curl -fsSL -k https://dl.google.com/go/go${go_version}.src.tar.gz | tar zx --strip-components=1 -C ${go_install_dir} \
32 &&  cd ${go_install_dir}/src/ \
33 &&  ./make.bash \
34 &&  curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v${DEP_MAN_VERSION}/dep-linux-amd64 \
35 &&  chmod +x /usr/local/bin/dep \
36 &&  mkdir -p $BUILD_DIR \
37 &&  git clone https://github.com/nokia/CPU-Pooler.git $BUILD_DIR \
38 &&  cd $BUILD_DIR \
39 &&  git fetch --tags \
40 &&  git checkout ${CPUPOOLER_VERSION} \
41 &&  dep ensure --vendor-only \
42 # cpu-device-plugin
43 &&  CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o cpu-device-plugin ./cmd/cpu-device-plugin \
44 &&  mv $BUILD_DIR/cpu-device-plugin /cpu-device-plugin \
45 # cpu-setter
46 &&  CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o cpu-setter ./cmd/cpusetter \
47 &&  mv $BUILD_DIR/cpu-setter /cpu-setter \
48 # cpu-webhook
49 &&  CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o cpu-device-webhook ./cmd/webhook \
50 &&  mv $BUILD_DIR/cpu-device-webhook /cpu-device-webhook \
51 &&  apk del .build-deps \
52 &&  rm -rf $GOPATH \
53 &&  rm -rf $go_install_dir \
54 &&  rm -rf /build \
55 &&  rm -rf /root/.glide