Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / infra / docker / focal / Dockerfile
1 # Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 FROM ubuntu:20.04
16
17 ARG UBUNTU_MIRROR
18
19 # Install 'add-apt-repository'
20 RUN apt-get update && apt-get -qqy install software-properties-common
21
22 # Build tool
23 RUN apt-get update && apt-get -qqy install build-essential cmake scons git lcov g++-arm-linux-gnueabihf g++-aarch64-linux-gnu
24
25 # Debian build tool
26 RUN apt-get update && apt-get -qqy install fakeroot devscripts debhelper python3-all dh-python
27
28 # Install extra dependencies (Caffe, nnkit)
29 RUN apt-get update && apt-get -qqy install libboost-all-dev libgflags-dev libgoogle-glog-dev libatlas-base-dev libhdf5-dev
30
31 # Install protocol buffer
32 RUN apt-get update && apt-get -qqy install libprotobuf-dev protobuf-compiler
33
34 # Additonal tools
35 RUN apt-get update && \
36     DEBIAN_FRONTEND=noninteractive \
37     apt-get -qqy install doxygen graphviz wget zip unzip clang-format-8 python3 python3-pip python3-venv python3-dev hdf5-tools pylint curl
38 RUN python3 -m pip install --upgrade pip
39 RUN python3 -m pip install yapf==0.22.0 numpy flatbuffers
40
41 # Install google test (source)
42 RUN apt-get update && apt-get -qqy install libgtest-dev
43
44 # Install gbs & sdb
45 RUN echo 'deb [trusted=yes] http://download.tizen.org/tools/latest-release/Ubuntu_20.04/ /' | cat >> /etc/apt/sources.list
46 RUN apt-get update && apt-get -qqy install gbs
47 RUN wget http://download.tizen.org/sdk/tizenstudio/official/binary/sdb_4.2.19_ubuntu-64.zip -O sdb.zip
48 RUN unzip -d tmp sdb.zip && rm sdb.zip
49 RUN cp tmp/data/tools/sdb /usr/bin/. && rm -rf tmp/*
50
51 # ARM none eabi build tool
52 RUN apt-get update && apt-get -qqy install gcc-arm-none-eabi
53
54 # Install java
55 RUN apt-get install -y --no-install-recommends openjdk-8-jdk
56
57 # download and install Gradle
58 # https://services.gradle.org/distributions/
59 ARG GRADLE_VERSION=6.4.1
60 ARG GRADLE_DIST=bin
61 RUN cd /opt && \
62     wget -q https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-${GRADLE_DIST}.zip && \
63     unzip gradle*.zip && \
64     ls -d */ | sed 's/\/*$//g' | xargs -I{} mv {} gradle && \
65     rm gradle*.zip
66
67 # download and install Android SDK
68 # https://developer.android.com/studio#command-tools
69 ARG ANDROID_SDK_VERSION=6514223
70 ENV ANDROID_SDK_ROOT /opt/android-sdk
71 RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
72     wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \
73     unzip *tools*linux*.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
74     rm *tools*linux*.zip
75
76 # accept the license agreements of the SDK components
77 RUN mkdir -p ${ANDROID_SDK_ROOT}/licenses
78 RUN echo 24333f8a63b6825ea9c5514f83c2829b004d1fee > ${ANDROID_SDK_ROOT}/licenses/android-sdk-license
79 RUN echo d56f5187479451eabf01fb78af6dfcb131a6481e >> ${ANDROID_SDK_ROOT}/licenses/android-sdk-license
80
81 # Env variable for gradle build
82 ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
83 ENV GRADLE_HOME /opt/gradle
84 ENV PATH ${PATH}:${GRADLE_HOME}/bin:${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${ANDROID_SDK_ROOT}/platform-tools
85 ENV ANDROID_HOME ${ANDROID_SDK_ROOT}
86
87 # Install NDK
88 RUN sdkmanager --install "ndk;20.0.5594570"
89 RUN sdkmanager "platform-tools"
90
91 # Env for ko encoding build
92 ENV LC_ALL "C.UTF-8"
93
94 # setup adb server
95 EXPOSE 5037
96
97 # Setup user to match host user, and give superuser permissions
98 ARG USER_ID=1000
99 ARG GROUP_ID=${USER_ID}
100 RUN addgroup --gid ${GROUP_ID} ubuntu && adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} ubuntu && usermod -aG sudo ubuntu
101 RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
102 RUN echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
103
104 # Clean archives (to reduce image size)
105 RUN apt-get clean -y
106
107 # Set user to the one we just created
108 USER ${USER_ID}