blob: d1f212c68462d1e99faaccbe8542240c2caca82f [file] [log] [blame]
James Conroy210897d2022-08-04 16:55:05 +01001#
2# Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3# SPDX-License-Identifier: MIT
4#
5
6# Default build type is 'production'. Use 'dev' if supplying custom Arm NN / ACL repos from host
7ARG BUILD_TYPE=production
8
9ARG UBUNTU_VERSION=18.04
10FROM ubuntu:${UBUNTU_VERSION} AS build-production
11
12ENV DEBIAN_FRONTEND noninteractive
13
14# Install basic packages for Docker container (not specific to Arm NN)
15RUN apt-get update && \
16 apt-get install -y --no-install-recommends \
17 ca-certificates \
18 locales \
19 vim \
20 && \
21 apt-get clean && \
22 rm -rf /var/lib/apt/lists/*
23
24# Set locale for Docker container
25RUN locale-gen en_GB.UTF-8 && \
26 update-locale LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF-8
27ENV LANG en_GB.UTF-8
28ENV LC_ALL en_GB.UTF-8
29
30WORKDIR /root
31
32# Install system-wide packages specific to Arm NN
33COPY ./scripts/install-packages.sh .
34RUN ./install-packages.sh
35
36# Define user for non-root processes (overwriteable during 'docker build' with --build-arg)
37ARG USER_ID=1000
38ARG GROUP_ID=1000
39
40# Create non-root user 'arm-user' based on $USER_ID and $GROUP_ID above
41RUN addgroup --gid $GROUP_ID arm-user
42RUN useradd --create-home --shell /bin/bash --uid $USER_ID --gid $GROUP_ID arm-user
43
44# Switch to non-root user
45USER arm-user
46WORKDIR /home/arm-user
47
48# Copy scripts required by Setup into WORKDIR
49COPY --chown=arm-user:arm-user ./scripts/validation.sh .
50COPY --chown=arm-user:arm-user ./scripts/common.sh .
51COPY --chown=arm-user:arm-user ./scripts/setup-armnn.sh .
52
53# Run setup-armnn.sh: download and install Arm NN dependencies
54ARG SETUP_ARGS=""
55RUN echo "SETUP_ARGS: $SETUP_ARGS"
56RUN ./setup-armnn.sh $SETUP_ARGS
57
58# This build-dev stage (inherits 'build-production' stage) is only used in final image if $BUILD_TYPE is 'dev'
59FROM build-production as build-dev
60
61# Create directory for source repos in WORKDIR
62RUN mkdir -p source/armnn source/acl
63
64# Copy custom armnn/acl source repos from the build-tool directory on the host, if they exist (optional)
65# If repos not provided, the build-armnn.sh script will automatically download the latest release branches of Arm NN and ACL
66# Copies Dockerfile to ensure COPY works - at least one file must exist for COPY to work
67COPY --chown=arm-user:arm-user ./docker/Dockerfile ./armnn* ./source/armnn/
68COPY --chown=arm-user:arm-user ./docker/Dockerfile ./acl* ./source/acl/
69
70# Final stage which inherits either 'build-production' or 'build-dev' stage
71FROM build-${BUILD_TYPE} as final
72
73# Copy build script into WORKDIR
74COPY --chown=arm-user:arm-user ./scripts/build-armnn.sh .
75
76# Run build-armnn.sh: build Arm NN and ACL
77ARG BUILD_ARGS=""
78RUN echo "BUILD_ARGS: $BUILD_ARGS"
79RUN ./build-armnn.sh $BUILD_ARGS