f66ef163af17baba62750eb477061dd9a2cbcfc3
[iec.git] / src / use_cases / seba_on_arm / docker / build / cord-tester / Dockerfile.cord-tester
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
19 FROM ubuntu:xenial as build
20 ENV DIRPATH /workspace
21 WORKDIR $DIRPATH
22 # Dependency for kafka pip package; needed for aarch64 image
23 RUN apt update && apt install -y curl make build-essential
24 RUN curl -L https://github.com/edenhill/librdkafka/archive/v0.11.6.tar.gz | \
25     tar xzf - \
26     && cd librdkafka-0.11.6/ \
27     && ./configure --prefix=/usr \
28     && make -j
29 RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg > key.gpg
30
31 FROM ubuntu:xenial
32 ENV DIRPATH /workspace
33 WORKDIR $DIRPATH
34
35 # Preferred Kubernetes versions 1.13 for IEC Type 2
36 ARG KUBE_VERSION=1.13.0-00
37 ARG TEST_USER=ubuntu
38
39 COPY --from=build $DIRPATH/librdkafka-0.11.6 librdkafka-0.11.6
40 COPY --from=build $DIRPATH/key.gpg key.gpg
41 RUN apt-key add key.gpg
42
43 # Install packages required by cord-tester
44 RUN echo "deb http://packages.cloud.google.com/apt kubernetes-xenial main" >\
45     /etc/apt/sources.list.d/kubernetes.list
46 RUN apt update && apt install -y lsb-release openssh-server sudo \
47     python python-pip python-dev \
48     git make libffi-dev libssl-dev libpq-dev \
49     kubectl=$KUBE_VERSION
50
51 RUN make -C librdkafka-0.11.6 install && rm -rf librdkafka-0.11.6
52
53 RUN pip install virtualenv
54 RUN apt-mark hold kubectl && apt autoremove -y \
55     && rm -rf /var/lib/apt/lists/*
56 RUN useradd -m -s /bin/bash --system -G sudo \
57     -p $(openssl passwd -1 $TEST_USER) $TEST_USER
58 RUN echo "ubuntu\tALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/90-docker-users
59 USER $TEST_USER