f9f992b003790a95812371f63fa24d2e65667f7c
[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:1.16.5-alpine3.13 as build
19
20 # Sonobuoy supports 3 Kubernetes minor versions: the current release and 2
21 # minor versions before.
22 ARG SB_TAG=v0.18.2
23 # Determine the latest stable git tag at build time based on stable major version
24 ARG K8S_VER=1.18
25
26 # Install dependencies
27 COPY pip-requirements.txt /wheels/requirements/pip-requirements.txt
28
29 RUN apk --no-cache add --update \
30         bash \
31         build-base \
32         cairo \
33         cairo-dev \
34         cargo \
35         curl \
36         findutils \
37         freetype-dev \
38         gcc \
39         gdk-pixbuf-dev \
40         gettext \
41         git \
42         grep \
43         jpeg-dev \
44         lcms2-dev \
45         libc-dev \
46         libffi-dev \
47         make \
48         musl-dev \
49         openjpeg-dev \
50         openssl-dev \
51         pango-dev \
52         poppler-utils \
53         postgresql-client \
54         postgresql-dev \
55         py-cffi \
56         python3-dev \
57         py3-pip \
58         rsync \
59         rust \
60         tcl-dev \
61         tiff-dev \
62         tk-dev \
63         zlib-dev
64
65 # Build binaries; detect the architecture automatically (default is amd64)
66 RUN git clone https://github.com/kubernetes/kubernetes /src/k8s.io/kubernetes
67 RUN if [ $(uname -m) == 'aarch64' ]; then HOST_ARCH=arm64; else HOST_ARCH=amd64; fi && \
68     echo "Building docker on $HOST_ARCH" && \
69     cd /src/k8s.io/kubernetes && \
70     git checkout $(curl \
71         https://storage.googleapis.com/kubernetes-release/release/stable-$K8S_VER.txt) && \
72     make kubectl ginkgo && \
73     make WHAT=test/e2e/e2e.test ARCH=$HOST_ARCH
74 RUN git clone https://github.com/heptio/sonobuoy /go/src/github.com/heptio/sonobuoy && \
75     cd /go/src/github.com/heptio/sonobuoy && \
76     git checkout $SB_TAG && \
77     go install
78 RUN git clone https://gerrit.akraino.org/r/validation /opt/akraino/validation
79 RUN cat /opt/akraino/validation/bluval/requirements.txt >> \
80     /wheels/requirements/pip-requirements.txt
81
82 WORKDIR /wheels
83 RUN pip3 install wheel
84 RUN pip3 wheel -r /wheels/requirements/pip-requirements.txt
85
86 # Copy binaries in the final container and install robot framework
87 FROM python:3.10.0b1-alpine3.13
88 COPY --from=build /src/k8s.io/kubernetes/_output/bin /usr/local/bin
89 COPY --from=build /go/bin/sonobuoy /bin/sonobuoy
90 COPY --from=build /wheels /wheels
91 COPY --from=build /opt/akraino/validation/ /opt/akraino/validation/
92
93 RUN apk --no-cache add --update \
94         bash \
95         build-base \
96         cairo \
97         cairo-dev \
98         cargo \
99         curl \
100         findutils \
101         freetype-dev \
102         gcc \
103         gdk-pixbuf-dev \
104         gettext \
105         git \
106         grep \
107         jpeg-dev \
108         lcms2-dev \
109         libc-dev \
110         libffi-dev \
111         make \
112         musl-dev \
113         openjpeg-dev \
114         openssl-dev \
115         pango-dev \
116         poppler-utils \
117         postgresql-client \
118         postgresql-dev \
119         py-cffi \
120         python3-dev \
121         py3-pip \
122         rsync \
123         rust \
124         tcl-dev \
125         tiff-dev \
126         tk-dev \
127         zlib-dev
128
129 RUN pip3 install -r /wheels/requirements/pip-requirements.txt \
130                  -f /wheels && \
131      rm -rf /wheels && \
132      rm -rf /root/.cache/pip/*