From 93c3105e13bb685f25225bff2a3447f8dc0b081f Mon Sep 17 00:00:00 2001 From: Frederic LESUR Date: Mon, 9 Sep 2024 19:24:28 +0900 Subject: [PATCH] Add UID of user when building to avoid permission issue (#1343) * Add UID of user when building to avoid permission issue * Add way to change timezone too --- docker/Dockerfile | 6 +++++- docker/README.md | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index a86bcbf29..32e0e8151 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,6 +2,10 @@ FROM --platform=linux/amd64 ubuntu:20.04 ARG DEBIAN_FRONTEND=noninteractive ARG USERNAME=devuser +ARG UID=1000 +ARG TZ="Etc/UTC" + +RUN echo "$TZ" > /etc/timezone RUN dpkg --add-architecture i386 \ && apt-get update \ @@ -13,7 +17,7 @@ RUN dpkg --add-architecture i386 \ RUN pip3 install pycryptodomex configobj toml fdt -RUN useradd -m -s /bin/bash ${USERNAME} +RUN useradd -m -s /bin/bash -u "${UID}" ${USERNAME} COPY build_target_platforms.sh /build_target_platforms.sh RUN chmod 775 /build_target_platforms.sh diff --git a/docker/README.md b/docker/README.md index b2c85d1b1..7bb9e4d99 100644 --- a/docker/README.md +++ b/docker/README.md @@ -3,10 +3,24 @@ This docker will build all or some of the platforms that OpenBeken supports. To use, first build the docker image: ```sh -docker build -t openbk_build --build-arg USERNAME=$USER . +docker build -t openbk_build --build-arg UID=$UID --build-arg USERNAME=$USER . +``` + +Note that the current user name and user ID is passed through to the docker image build. +This is to preserve local file permissions when OpenBeken is built. + +If you want to change the timezone you can use the argument TZ for that like + +```sh +docker build -t openbk_build --build-arg UID=$UID --build-arg USERNAME=$USER --build-arg TZ="Etc/UTC" . +``` + +or + +```sh +docker build -t openbk_build --build-arg UID=$UID --build-arg USERNAME=$USER --build-arg TZ="Asia/Tokyo" . ``` -Note that the current user name is passed through to the docker image build. This is to preserve local file permissions when OpenBeken is built. Once the docker image is build, you can use it to build the SDKs as follows (assumed you are in the current `docker` directory):