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
This commit is contained in:
Frederic LESUR
2024-09-09 19:24:28 +09:00
committed by GitHub
parent 6594d4499b
commit 93c3105e13
2 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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):