6a5f64ace6039947b231b871793a5ec8ce84c01c
[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 && DEBIAN_FRONTEND=noninteractive apt-get -qqy install doxygen graphviz wget zip unzip clang-format-3.9 python3 python3-pip python3-venv hdf5-tools pylint
34 RUN pip3 install --upgrade pip
35 RUN pip3 install yapf==0.22.0 numpy
36
37 # Install google test (source)
38 RUN apt-get update && apt-get -qqy install libgtest-dev
39
40 # Install build tool gcc version 8.x and set alternative link (c++17 support)
41 RUN apt-get update && apt-get -qqy install g++-8 g++-8-arm-linux-gnueabihf g++-8-aarch64-linux-gnu
42 RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 \
43     --slave /usr/bin/g++ g++ /usr/bin/g++-8 \
44     --slave /usr/bin/gcov gcov /usr/bin/gcov-8
45 RUN update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-8 80 \
46     --slave /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++-8 \
47     --slave /usr/bin/arm-linux-gnueabihf-gcov arm-linux-gnueabihf-gcov /usr/bin/arm-linux-gnueabihf-gcov-8
48 RUN update-alternatives --install /usr/bin/aarch64-linux-gnu-gcc aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-gcc-8 80 \
49     --slave /usr/bin/aarch64-linux-gnu-g++ aarch64-linux-gnu-g++ /usr/bin/aarch64-linux-gnu-g++-8 \
50     --slave /usr/bin/aarch64-linux-gnu-gcov aarch64-linux-gnu-gcov /usr/bin/aarch64-linux-gnu-gcov-8
51
52 # Install lcov 1.13-4 for gcc-8 support (installed lcov 1.13-3 can't support gcc-8)
53 RUN wget http://launchpadlibrarian.net/370213541/lcov_1.13-4_all.deb
54 RUN dpkg -i lcov_1.13-4_all.deb
55
56 # Build and install google test static libraries
57 WORKDIR /root/gtest
58 RUN cmake /usr/src/gtest
59 RUN make
60 RUN mv *.a /usr/lib
61 WORKDIR /root
62 RUN rm -rf gtest
63
64 # Install gbs & sdb
65 RUN echo 'deb [trusted=yes] http://download.tizen.org/tools/latest-release/Ubuntu_18.04/ /' | cat >> /etc/apt/sources.list
66 RUN apt-get update && apt-get -qqy install gbs
67 RUN wget http://download.tizen.org/sdk/tizenstudio/official/binary/sdb_3.1.4_ubuntu-64.zip -O sdb.zip
68 RUN unzip -d tmp sdb.zip && rm sdb.zip
69 RUN cp tmp/data/tools/sdb /usr/bin/. && rm -rf tmp
70
71 # Install java
72 RUN apt-get install -y --no-install-recommends openjdk-8-jdk
73
74 # download and install Gradle
75 # https://services.gradle.org/distributions/
76 ARG GRADLE_VERSION=6.4.1
77 ARG GRADLE_DIST=bin
78 RUN cd /opt && \
79     wget -q https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-${GRADLE_DIST}.zip && \
80     unzip gradle*.zip && \
81     ls -d */ | sed 's/\/*$//g' | xargs -I{} mv {} gradle && \
82     rm gradle*.zip
83
84 # download and install Android SDK
85 # https://developer.android.com/studio#command-tools
86 ARG ANDROID_SDK_VERSION=6514223
87 ENV ANDROID_SDK_ROOT /opt/android-sdk
88 RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
89     wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \
90     unzip *tools*linux*.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
91     rm *tools*linux*.zip
92
93 # accept the license agreements of the SDK components
94 RUN mkdir -p ${ANDROID_SDK_ROOT}/licenses
95 RUN echo 24333f8a63b6825ea9c5514f83c2829b004d1fee > ${ANDROID_SDK_ROOT}/licenses/android-sdk-license
96 RUN echo d56f5187479451eabf01fb78af6dfcb131a6481e >> ${ANDROID_SDK_ROOT}/licenses/android-sdk-license
97
98 # Env variable for gradle build
99 ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
100 ENV GRADLE_HOME /opt/gradle
101 ENV PATH ${PATH}:${GRADLE_HOME}/bin:${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${ANDROID_SDK_ROOT}/platform-tools
102 ENV ANDROID_HOME ${ANDROID_SDK_ROOT}
103
104 # Install NDK
105 RUN sdkmanager --install "ndk;20.0.5594570"
106 RUN sdkmanager "platform-tools"
107
108 # Env for ko encoding build
109 ENV LC_ALL "C.UTF-8"
110
111 # setup adb server
112 EXPOSE 5037
113
114 # Clean archives (to reduce image size)
115 RUN apt-get clean -y