CaaS storage seed code
[ta/caas-storage.git] / docker-build / dynamic_local_pv_provisioner / 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
17 ARG go_install_dir="/usr/local/go"
18 ARG go_version
19 ARG DYNAMIC_LOCAL_PV_PROVISIONER_VERSION
20 ARG DEPENDENCY_MANAGER_VERSION
21 ENV GOPATH /build
22 ENV PATH $go_install_dir/bin:$PATH
23 ENV BUILD_DIR="$GOPATH/src/github.com/nokia/dynamic-local-pv-provisioner"
24
25 RUN apk update \
26 &&  apk upgrade \
27 &&  apk add --no-cache --virtual .build-deps build-base git mercurial go glide bash tar \
28 &&  apk add --no-cache curl e2fsprogs xfsprogs-extra \
29 &&  mkdir -p $go_install_dir \
30 &&  curl -fsSL -k https://dl.google.com/go/go${go_version}.src.tar.gz | tar zx --strip-components=1 -C ${go_install_dir} \
31 &&  cd ${go_install_dir}/src/ \
32 &&  ./make.bash \
33 &&  if [ $(uname -m) == 'aarch64' ]; then HOST_ARCH=arm64; else HOST_ARCH=amd64; fi \
34 &&  curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v${DEPENDENCY_MANAGER_VERSION}/dep-linux-${HOST_ARCH} \
35 &&  chmod +x /usr/local/bin/dep \
36 &&  mkdir -p $BUILD_DIR \
37 # &&  git clone https://github.com/balintTobik/dynamic-local-pv-provisioner.git $BUILD_DIR \ 
38 # &&  git clone https://github.com/nokia/dynamic-local-pv-provisioner.git $BUILD_DIR \
39 &&  git clone https://github.com/nokia/dynamic-local-pv-provisioner-fork.git $BUILD_DIR \
40 &&  cd $BUILD_DIR \
41 &&  git fetch --tags \
42 &&  git checkout ${DYNAMIC_LOCAL_PV_PROVISIONER_VERSION} \
43 &&  dep init \
44 &&  dep ensure --vendor-only \
45 &&  CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o executor ./cmd/executor \
46 &&  mv $BUILD_DIR/executor /executor \
47 &&  CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o provisioner ./cmd/provisioner \
48 &&  mv $BUILD_DIR/provisioner /provisioner \
49 &&  apk del .build-deps \
50 &&  rm -rf $GOPATH \
51 &&  rm -rf $go_install_dir \
52 &&  rm -rf /build \
53 &&  rm -rf /root/.glide
54