Merge "[RECV-94] Separate docker/robot invoking"
[validation.git] / docker / k8s / Dockerfile
1 ##############################################################################
2 # Copyright (c) 2019 AT&T, ENEA AB, Nokia and others                         #
3 #                                                                            #
4 # Licensed under the Apache License, Version 2.0 (the "License");            #
5 # you maynot use this file except in compliance with the License.            #
6 #                                                                            #
7 # You may obtain a copy of the License at                                    #
8 #       http://www.apache.org/licenses/LICENSE-2.0                           #
9 #                                                                            #
10 # Unless required by applicable law or agreed to in writing, software        #
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
13 # See the License for the specific language governing permissions and        #
14 # limitations under the License.                                             #
15 ##############################################################################
16
17 # ref: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#use-multi-stage-builds
18 FROM golang:alpine3.9 as build
19
20 # Sonobuoy supports Kubernetes versions 1.11, 1.12 and 1.13
21 ARG SB_TAG=v0.14.3
22 # Determine the latest stable git tag at build time based on stable major version
23 ARG K8S_VER=1.15
24
25 # Install dependencies
26 COPY pip-requirements.txt /wheels/requirements/pip-requirements.txt
27
28 RUN apk --no-cache add --update \
29         curl \
30         openssl \
31         python3 \
32         bash \
33         findutils \
34         gcc \
35         git \
36         grep \
37         libc-dev \
38         libffi \
39         libffi-dev \
40         make \
41         openssl-dev \
42         python3-dev \
43         py3-pip \
44         rsync
45
46 # Build binaries; detect the architecture automatically (default is amd64)
47 RUN git clone https://github.com/kubernetes/kubernetes /src/k8s.io/kubernetes
48 RUN if [ $(uname -m) == 'aarch64' ]; then HOST_ARCH=arm64; else HOST_ARCH=amd64; fi && \
49     echo "Building docker on $HOST_ARCH" && \
50     cd /src/k8s.io/kubernetes && \
51     git checkout $(curl \
52         https://storage.googleapis.com/kubernetes-release/release/stable-$K8S_VER.txt) && \
53     make kubectl ginkgo && \
54     make WHAT=test/e2e/e2e.test ARCH=$HOST_ARCH
55 RUN go get -d github.com/heptio/sonobuoy && \
56     cd /go/src/github.com/heptio/sonobuoy && \
57     git checkout $SB_TAG && \
58     go install
59 RUN git clone https://gerrit.akraino.org/r/validation /opt/akraino/validation
60 RUN cat /opt/akraino/validation/bluval/requirements.txt >> \
61     /wheels/requirements/pip-requirements.txt
62
63 WORKDIR /wheels
64 RUN pip3 install wheel
65 RUN pip3 wheel -r /wheels/requirements/pip-requirements.txt
66
67 # Copy binaries in the final contaier and install robot framework
68 FROM python:3.6-alpine3.9
69 COPY --from=build /src/k8s.io/kubernetes/_output/bin /usr/local/bin
70 COPY --from=build /go/bin/sonobuoy /bin/sonobuoy
71 COPY --from=build /wheels /wheels
72 COPY --from=build /opt/akraino/validation/ /opt/akraino/validation/
73
74 RUN pip3 install -r /wheels/requirements/pip-requirements.txt \
75                  -f /wheels && \
76      rm -rf /wheels && \
77      rm -rf /root/.cache/pip/*