From bcbcef5d5c18bc8c8f174b893ab77ac359ddf76d Mon Sep 17 00:00:00 2001
From: Josh Veitch-Michaelis <j.veitchmichaelis+github@gmail.com>
Date: Sun, 24 Nov 2019 02:30:34 +0000
Subject: [PATCH] Tools: install ardupilot deps as non-root in Dockerfix for
 https://github.com/ArduPilot/ardupilot/issues/12513

---
 Dockerfile | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index d499c4450d..7130ae8153 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -8,15 +8,22 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install --no-instal
     lsb-release \
     sudo \
     software-properties-common \
-    python-software-properties && \
-    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+    python-software-properties
 
 ENV USER=ardupilot
 ADD . /ardupilot
-RUN chown -R ardupilot:ardupilot /ardupilot && \
-    bash -c "Tools/environment_install/install-prereqs-ubuntu.sh -y && apt-get install gcc-arm-none-eabi -y" && \
-    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+
+RUN echo "ardupilot ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ardupilot
+RUN chmod 0440 /etc/sudoers.d/ardupilot
+
+RUN chown -R ardupilot:ardupilot /ardupilot
 
 USER ardupilot
+RUN bash -c "Tools/environment_install/install-prereqs-ubuntu.sh -y"
+RUN sudo apt-get clean \
+    && sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+
 ENV CCACHE_MAXSIZE=1G
 ENV PATH /usr/lib/ccache:/ardupilot/Tools:${PATH}
+ENV PATH /ardupilot/Tools/autotest:${PATH}
+ENV PATH /ardupilot/.local/bin:$PATH