Skip to content

Commit bf471a7

Browse files
committed
Support overriding uid of default user in container
1 parent 83a27ea commit bf471a7

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

container/debian-11-arm-dev/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
FROM debian:11
77

8+
# Optionally override uid of default user in container, e.g.,
9+
# docker build --build-arg uid=1001 ...
10+
ARG uid
11+
812
WORKDIR /work
913

1014
# Before using a new script, update .github/workflows/container.yml
@@ -32,7 +36,7 @@ RUN dpkg --add-architecture armhf \
3236
libelf-dev:armhf \
3337
zlib1g-dev:armhf \
3438
&& apt-get -y clean \
35-
&& useradd --system --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
39+
&& useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
3640
&& echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \
3741
&& rm -rf "$PWD"
3842

container/opensuse-leap-15-dev/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
FROM opensuse/leap:15
77

8+
# Optionally override uid of default user in container, e.g.,
9+
# docker build --build-arg uid=1001 ...
10+
ARG uid
11+
812
WORKDIR /work
913

1014
# Before using a new script, update .github/workflows/container.yml
@@ -32,7 +36,7 @@ RUN zypper -n update \
3236
zlib-devel \
3337
&& zypper -n clean \
3438
&& ./install_aocl.sh /opt/aocl \
35-
&& useradd --system --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
39+
&& useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
3640
&& echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \
3741
&& rm -rf "$PWD"
3842

container/rockylinux-8-dev/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
FROM rockylinux:8
77

8+
# Optionally override uid of default user in container, e.g.,
9+
# docker build --build-arg uid=1001 ...
10+
ARG uid
11+
812
WORKDIR /work
913

1014
# Before using a new script, update .github/workflows/container.yml
@@ -38,7 +42,7 @@ RUN \
3842
zlib-devel \
3943
&& yum -y clean all \
4044
&& ./install_aocl.sh /opt/aocl \
41-
&& useradd --system --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
45+
&& useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
4246
&& echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \
4347
&& rm -rf "$PWD"
4448

container/ubuntu-18.04-dev/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
FROM ubuntu:18.04
77

8+
# Optionally override uid of default user in container, e.g.,
9+
# docker build --build-arg uid=1001 ...
10+
ARG uid
11+
812
WORKDIR /work
913

1014
# Before using a new script, update .github/workflows/container.yml
@@ -41,7 +45,7 @@ RUN apt-get -y update \
4145
zlib1g-dev \
4246
&& apt-get -y clean \
4347
&& ./install_aocl.sh /opt/aocl \
44-
&& useradd --system --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
48+
&& useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
4549
&& echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \
4650
&& rm -rf "$PWD"
4751

container/ubuntu-20.04-clang/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ ARG clang_archive_sig=$clang_archive.sig
1212
ARG clang_archive_url=https://github.com/llvm/llvm-project/releases/download/llvmorg-$clang_version/$clang_archive
1313
ARG clang_archive_sig_url=$clang_archive_url.sig
1414

15+
# Optionally override uid of default user in container, e.g.,
16+
# docker build --build-arg uid=1001 ...
17+
ARG uid
18+
1519
WORKDIR /work
1620

1721
# https://releases.llvm.org/download.html
@@ -33,7 +37,7 @@ RUN apt-get -y update \
3337
&& tar --strip-components=1 -C "$clang_installdir" -xf "$clang_archive" \
3438
&& chown -R root:root "$clang_installdir" \
3539
&& chmod -R u=rwX,g=rX,o=rX "$clang_installdir" \
36-
&& useradd --system --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
40+
&& useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
3741
&& echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \
3842
&& rm -rf "$PWD"
3943

container/ubuntu-20.04-dev/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
FROM ubuntu:20.04
77

8+
# Optionally override uid of default user in container, e.g.,
9+
# docker build --build-arg uid=1001 ...
10+
ARG uid
11+
812
WORKDIR /work
913

1014
# Before using a new script, update .github/workflows/container.yml
@@ -28,7 +32,7 @@ RUN apt-get -y update \
2832
zlib1g-dev \
2933
&& apt-get -y clean \
3034
&& ./install_aocl.sh /opt/aocl \
31-
&& useradd --system --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
35+
&& useradd --system ${uid:+--uid "$uid"} --user-group --shell /sbin/nologin --create-home --home-dir /home/build build \
3236
&& echo 'build ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/build \
3337
&& rm -rf "$PWD"
3438

0 commit comments

Comments
 (0)