Added seed code for caas-metrics.
[ta/caas-metrics.git] / docker-build / metrics_server / 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 Szekeres Balazs <balazs.szekeres@nokia.com>
17
18 ARG DEPENDENCY_MANAGER
19 ENV DEPENDENCY_VERSION=$DEPENDENCY_MANAGER
20 ARG METRICS_SERVER
21 ENV METRICS_SERVER_VERSION=$METRICS_SERVER
22 ENV GOPATH /build
23 ENV PATH /usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
24
25 ENV VERSION_LDFLAGS='-extldflags "-static"'
26
27 RUN apk add --no-cache --virtual .build-deps build-base go godep curl tar git bash mercurial \
28 &&  curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v${DEPENDENCY_VERSION}/dep-linux-amd64 \
29 &&  chmod +x /usr/local/bin/dep \
30 &&  mkdir -p ${GOPATH}/src/github.com/kubernetes-incubator/metrics-server/ \
31 &&  curl -fsSL -k https://github.com/kubernetes-incubator/metrics-server/archive/v${METRICS_SERVER_VERSION}.tar.gz | tar zx --strip-components=1 -C ${GOPATH}/src/github.com/kubernetes-incubator/metrics-server/ \
32 &&  cd ${GOPATH}/src/github.com/kubernetes-incubator/metrics-server/ \
33 &&  dep ensure --vendor-only \
34 # static linking added
35 &&  sed -i "s?LDFLAGS=-w \$(VERSION_LDFLAGS)?LDFLAGS='-extldflags "-static"' -w \$(VERSION_LDFLAGS)?" ./Makefile \
36 &&  make \
37 &&  mv ./_output/amd64/metrics-server /metrics-server \
38 &&  apk del .build-deps \
39 &&  rm -rf ${GOPATH} \
40 &&  rm -rf /build
41