aboutsummaryrefslogtreecommitdiff
path: root/build-tool/docker
diff options
context:
space:
mode:
authorJames Conroy <james.conroy@arm.com>2022-08-04 16:55:05 +0100
committerNikhil Raj <nikhil.raj@arm.com>2022-08-05 16:33:41 +0100
commit210897d7afb4007fe06d390c2ec333a732390b5c (patch)
treefc172104328e511c3c262135f40cba0f25a96068 /build-tool/docker
parentdba6773af86ac3f79171503fd3b48b0bd1618239 (diff)
downloadarmnn-210897d7afb4007fe06d390c2ec333a732390b5c.tar.gz
IVGCVSW-6777 Add Arm NN build-tool Dockerfile
* Adds Dockerfile associated with Arm NN build-tool scripts. * The Dockerfile encapsulates the installation of system-wide packages (install-packages.sh), download/install of Arm NN dependencies (setup-armnn.sh) and the building of Arm NN and ACL (build-armnn.sh). * A helper script for copying build contents from the built Docker image is provided for by docker-copy-to-host.sh. * Modified existing scripts: moved the cloning of Arm NN and ACL from setup-armnn.sh to build-armnn.sh and decoupled setup-armnn.sh from scripts outside of build-tool directory e.g. armnn/scripts/get_tensorflow.sh. * The build-armnn.sh script clones the latest release branches of Arm NN and ACL by default. Custom repos can be placed in the build-tool directory prior to 'docker build' and they will be used instead (advanced usage). * Support added for Linux targets only, Android to be added in future work. Signed-off-by: James Conroy <james.conroy@arm.com> Change-Id: I336013cf93821d2cd3e5d9fe2ca4e955ffdd2386
Diffstat (limited to 'build-tool/docker')
-rw-r--r--build-tool/docker/Dockerfile79
1 files changed, 79 insertions, 0 deletions
diff --git a/build-tool/docker/Dockerfile b/build-tool/docker/Dockerfile
new file mode 100644
index 0000000000..d1f212c684
--- /dev/null
+++ b/build-tool/docker/Dockerfile
@@ -0,0 +1,79 @@
+#
+# Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
+# SPDX-License-Identifier: MIT
+#
+
+# Default build type is 'production'. Use 'dev' if supplying custom Arm NN / ACL repos from host
+ARG BUILD_TYPE=production
+
+ARG UBUNTU_VERSION=18.04
+FROM ubuntu:${UBUNTU_VERSION} AS build-production
+
+ENV DEBIAN_FRONTEND noninteractive
+
+# Install basic packages for Docker container (not specific to Arm NN)
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends \
+ ca-certificates \
+ locales \
+ vim \
+ && \
+ apt-get clean && \
+ rm -rf /var/lib/apt/lists/*
+
+# Set locale for Docker container
+RUN locale-gen en_GB.UTF-8 && \
+ update-locale LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF-8
+ENV LANG en_GB.UTF-8
+ENV LC_ALL en_GB.UTF-8
+
+WORKDIR /root
+
+# Install system-wide packages specific to Arm NN
+COPY ./scripts/install-packages.sh .
+RUN ./install-packages.sh
+
+# Define user for non-root processes (overwriteable during 'docker build' with --build-arg)
+ARG USER_ID=1000
+ARG GROUP_ID=1000
+
+# Create non-root user 'arm-user' based on $USER_ID and $GROUP_ID above
+RUN addgroup --gid $GROUP_ID arm-user
+RUN useradd --create-home --shell /bin/bash --uid $USER_ID --gid $GROUP_ID arm-user
+
+# Switch to non-root user
+USER arm-user
+WORKDIR /home/arm-user
+
+# Copy scripts required by Setup into WORKDIR
+COPY --chown=arm-user:arm-user ./scripts/validation.sh .
+COPY --chown=arm-user:arm-user ./scripts/common.sh .
+COPY --chown=arm-user:arm-user ./scripts/setup-armnn.sh .
+
+# Run setup-armnn.sh: download and install Arm NN dependencies
+ARG SETUP_ARGS=""
+RUN echo "SETUP_ARGS: $SETUP_ARGS"
+RUN ./setup-armnn.sh $SETUP_ARGS
+
+# This build-dev stage (inherits 'build-production' stage) is only used in final image if $BUILD_TYPE is 'dev'
+FROM build-production as build-dev
+
+# Create directory for source repos in WORKDIR
+RUN mkdir -p source/armnn source/acl
+
+# Copy custom armnn/acl source repos from the build-tool directory on the host, if they exist (optional)
+# If repos not provided, the build-armnn.sh script will automatically download the latest release branches of Arm NN and ACL
+# Copies Dockerfile to ensure COPY works - at least one file must exist for COPY to work
+COPY --chown=arm-user:arm-user ./docker/Dockerfile ./armnn* ./source/armnn/
+COPY --chown=arm-user:arm-user ./docker/Dockerfile ./acl* ./source/acl/
+
+# Final stage which inherits either 'build-production' or 'build-dev' stage
+FROM build-${BUILD_TYPE} as final
+
+# Copy build script into WORKDIR
+COPY --chown=arm-user:arm-user ./scripts/build-armnn.sh .
+
+# Run build-armnn.sh: build Arm NN and ACL
+ARG BUILD_ARGS=""
+RUN echo "BUILD_ARGS: $BUILD_ARGS"
+RUN ./build-armnn.sh $BUILD_ARGS \ No newline at end of file