From 8a6b828ab750b6fb8682534aea45ed1fdc3610d0 Mon Sep 17 00:00:00 2001
From: Peter Feerick <peter.feerick@gmail.com>
Date: Sat, 12 Dec 2020 12:56:21 +1000
Subject: [PATCH] Move user block to reduce layer change breakage + tweaks

---
 docker/amd64/Dockerfile   | 12 +++++-------
 docker/arm64v8/Dockerfile | 12 +++++-------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/docker/amd64/Dockerfile b/docker/amd64/Dockerfile
index 1b7932f2..0ea2c0a9 100644
--- a/docker/amd64/Dockerfile
+++ b/docker/amd64/Dockerfile
@@ -1,11 +1,5 @@
 FROM amd64/ubuntu:18.04
 
-ARG USER_ID
-ARG GROUP_ID
-
-RUN addgroup --gid $GROUP_ID user
-RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user
-
 RUN apt-get update -qq && apt-get install -y wget unzip cmake make build-essential git python3 python3-pip
 RUN wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz -O - | tar -xj -C /opt/
 RUN wget -q https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip && unzip -q nRF5_SDK_15.3.0_59ac345.zip -d /opt/ && rm nRF5_SDK_15.3.0_59ac345.zip
@@ -13,5 +7,9 @@ RUN wget -q https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_
 RUN git clone https://github.com/JuulLabs-OSS/mcuboot.git /opt/mcuboot && pip3 install -r /opt/mcuboot/scripts/requirements.txt
 RUN pip3 install adafruit-nrfutil
 
-USER user
+ARG PUID=1000
+ARG PGID=1000
+RUN groupadd --system --gid $PGID infinitime && useradd --system --uid $PUID --gid $PGID infinitime
+
+USER infinitime:infinitime
 CMD ["/sources/docker/build.sh"]
\ No newline at end of file
diff --git a/docker/arm64v8/Dockerfile b/docker/arm64v8/Dockerfile
index c95f6254..8b9e4514 100644
--- a/docker/arm64v8/Dockerfile
+++ b/docker/arm64v8/Dockerfile
@@ -1,11 +1,5 @@
 FROM arm64v8/ubuntu:18.04
 
-ARG USER_ID
-ARG GROUP_ID
-
-RUN addgroup --gid $GROUP_ID user
-RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user
-
 RUN apt-get update -qq && apt-get install -y wget unzip cmake make build-essential git python3 python3-pip libffi-dev libssl-dev python3-dev
 RUN wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-aarch64-linux.tar.bz2 -O - | tar -xj -C /opt/
 RUN wget -q https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip && unzip -q nRF5_SDK_15.3.0_59ac345.zip -d /opt/ && rm nRF5_SDK_15.3.0_59ac345.zip
@@ -13,5 +7,9 @@ RUN wget -q https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_
 RUN git clone https://github.com/JuulLabs-OSS/mcuboot.git /opt/mcuboot && pip3 install -r /opt/mcuboot/scripts/requirements.txt
 RUN pip3 install adafruit-nrfutil
 
-USER user
+ARG PUID=1000
+ARG PGID=1000
+RUN groupadd --system --gid $PGID infinitime && useradd --system --uid $PUID --gid $PGID infinitime
+
+USER infinitime:infinitime
 CMD ["/sources/docker/build.sh"]