Imported Upstream version 1.12.0
[platform/core/ml/nnfw.git] / infra / docker / bionic / Dockerfile
1 # Copyright 2016-2020 Jing Li
2 # Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
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,
12 # WITHOUT 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 FROM ubuntu:18.04
17
18 ARG UBUNTU_MIRROR
19
20 # Install 'add-apt-repository'
21 RUN apt-get update && apt-get -qqy install software-properties-common
22
23 # Build tool
24 RUN apt-get update && apt-get -qqy install build-essential cmake scons git g++-arm-linux-gnueabihf g++-aarch64-linux-gnu
25
26 # Install extra dependencies (Caffe, nnkit)
27 RUN apt-get update && apt-get -qqy install libboost-all-dev libgflags-dev libgoogle-glog-dev libatlas-base-dev libhdf5-dev
28
29 # Install protocol buffer
30 RUN apt-get update && apt-get -qqy install libprotobuf-dev protobuf-compiler
31
32 # Additonal tools
33 RUN apt-get update && \
34     DEBIAN_FRONTEND=noninteractive \
35     apt-get -qqy install doxygen graphviz wget zip unzip clang-format-3.9 clang-format-8 python3 python3-pip python3-venv hdf5-tools pylint curl
36 RUN pip3 install --upgrade pip
37 RUN pip3 install yapf==0.22.0 numpy
38
39 # Install google test (source)
40 RUN apt-get update && apt-get -qqy install libgtest-dev
41
42 # Install build tool gcc version 8.x and set alternative link (c++17 support)
43 RUN apt-get update && apt-get -qqy install g++-8 g++-8-arm-linux-gnueabihf g++-8-aarch64-linux-gnu
44 RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 \
45     --slave /usr/bin/g++ g++ /usr/bin/g++-8 \
46     --slave /usr/bin/gcov gcov /usr/bin/gcov-8
47 RUN update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-8 80 \
48     --slave /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++-8 \
49     --slave /usr/bin/arm-linux-gnueabihf-gcov arm-linux-gnueabihf-gcov /usr/bin/arm-linux-gnueabihf-gcov-8
50 RUN update-alternatives --install /usr/bin/aarch64-linux-gnu-gcc aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-gcc-8 80 \
51     --slave /usr/bin/aarch64-linux-gnu-g++ aarch64-linux-gnu-g++ /usr/bin/aarch64-linux-gnu-g++-8 \
52     --slave /usr/bin/aarch64-linux-gnu-gcov aarch64-linux-gnu-gcov /usr/bin/aarch64-linux-gnu-gcov-8
53
54 # Install lcov 1.14-2 for gcc-8 support
55 #   Default version lcov 1.13-3 can't support gcc-8
56 #   lcov 1.13-4 with gcc-8 have bug: reports no coverage for class declaration
57 WORKDIR /root/lcov
58 RUN wget http://archive.ubuntu.com/ubuntu/pool/universe/l/lcov/lcov_1.14-2_all.deb
59 RUN apt-get update && apt-get -qqy install libperlio-gzip-perl libjson-perl
60 RUN dpkg -i lcov_1.14-2_all.deb
61 WORKDIR /root
62 RUN rm -rf /root/lcov
63
64 # Build and install google test static libraries
65 WORKDIR /root/gtest
66 RUN cmake /usr/src/gtest
67 RUN make
68 RUN mv *.a /usr/lib
69 WORKDIR /root
70 RUN rm -rf gtest
71
72 # Install gbs & sdb
73 RUN echo 'deb [trusted=yes] http://download.tizen.org/tools/latest-release/Ubuntu_18.04/ /' | cat >> /etc/apt/sources.list
74 RUN apt-get update && apt-get -qqy install gbs
75 RUN wget http://download.tizen.org/sdk/tizenstudio/official/binary/sdb_3.1.4_ubuntu-64.zip -O sdb.zip
76 RUN unzip -d tmp sdb.zip && rm sdb.zip
77 RUN cp tmp/data/tools/sdb /usr/bin/. && rm -rf tmp
78
79 # Install java
80 RUN apt-get install -y --no-install-recommends openjdk-8-jdk
81
82 # download and install Gradle
83 # https://services.gradle.org/distributions/
84 ARG GRADLE_VERSION=6.4.1
85 ARG GRADLE_DIST=bin
86 RUN cd /opt && \
87     wget -q https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-${GRADLE_DIST}.zip && \
88     unzip gradle*.zip && \
89     ls -d */ | sed 's/\/*$//g' | xargs -I{} mv {} gradle && \
90     rm gradle*.zip
91
92 # download and install Android SDK
93 # https://developer.android.com/studio#command-tools
94 ARG ANDROID_SDK_VERSION=6514223
95 ENV ANDROID_SDK_ROOT /opt/android-sdk
96 RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
97     wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \
98     unzip *tools*linux*.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
99     rm *tools*linux*.zip
100
101 # accept the license agreements of the SDK components
102 RUN mkdir -p ${ANDROID_SDK_ROOT}/licenses
103 RUN echo 24333f8a63b6825ea9c5514f83c2829b004d1fee > ${ANDROID_SDK_ROOT}/licenses/android-sdk-license
104 RUN echo d56f5187479451eabf01fb78af6dfcb131a6481e >> ${ANDROID_SDK_ROOT}/licenses/android-sdk-license
105
106 # Env variable for gradle build
107 ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
108 ENV GRADLE_HOME /opt/gradle
109 ENV PATH ${PATH}:${GRADLE_HOME}/bin:${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${ANDROID_SDK_ROOT}/platform-tools
110 ENV ANDROID_HOME ${ANDROID_SDK_ROOT}
111
112 # Install NDK
113 RUN sdkmanager --install "ndk;20.0.5594570"
114 RUN sdkmanager "platform-tools"
115
116 # Env for ko encoding build
117 ENV LC_ALL "C.UTF-8"
118
119 # setup adb server
120 EXPOSE 5037
121
122 # Clean archives (to reduce image size)
123 RUN apt-get clean -y