Skip to content

Commit a8af028

Browse files
authored
feat(docker): add configurable user and group IDs for non-root user (#80)
* Introduced `ARG PUID` and `ARG PGID` to allow customization of user and group IDs. * Updated user creation command to use these arguments for better flexibility.
1 parent e44b762 commit a8af028

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Dockerfile.ubuntu-2004

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM ubuntu:20.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG PUID=1000
5+
ARG PGID=1000
46
ARG BUILD_DATE
57
ARG VCS_REF
68

@@ -34,8 +36,9 @@ RUN locale-gen en_US.UTF-8
3436
ENV LANG=en_US.UTF-8
3537
ENV LANGUAGE=en_US:en
3638

37-
# Create non-root user
38-
RUN useradd -m -d /home/steam -s /bin/bash steam \
39+
# Create non-root user/group with configurable IDs
40+
RUN groupadd -g "${PGID}" steam \
41+
&& useradd -l -u "${PUID}" -g steam -m -d /home/steam -s /bin/bash steam \
3942
&& mkdir -p /home/steam/Steam \
4043
&& chown -R steam:steam /home/steam
4144
USER steam

Dockerfile.ubuntu-2204

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM ubuntu:22.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG PUID=1000
5+
ARG PGID=1000
46
ARG BUILD_DATE
57
ARG VCS_REF
68

@@ -34,8 +36,9 @@ RUN locale-gen en_US.UTF-8
3436
ENV LANG=en_US.UTF-8
3537
ENV LANGUAGE=en_US:en
3638

37-
# Create non-root user
38-
RUN useradd -m -d /home/steam -s /bin/bash steam \
39+
# Create non-root user/group with configurable IDs
40+
RUN groupadd -g "${PGID}" steam \
41+
&& useradd -l -u "${PUID}" -g steam -m -d /home/steam -s /bin/bash steam \
3942
&& mkdir -p /home/steam/Steam \
4043
&& chown -R steam:steam /home/steam
4144
USER steam

Dockerfile.ubuntu-2404

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM ubuntu:24.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG PUID=1000
5+
ARG PGID=1000
46
ARG BUILD_DATE
57
ARG VCS_REF
68

@@ -35,7 +37,8 @@ ENV LANG=en_US.UTF-8
3537
ENV LANGUAGE=en_US:en
3638

3739
# Create non-root user
38-
RUN useradd -m -d /home/steam -s /bin/bash steam \
40+
RUN groupadd -g "${PGID}" steam \
41+
&& useradd -l -u "${PUID}" -g steam -m -d /home/steam -s /bin/bash steam \
3942
&& mkdir -p /home/steam/Steam \
4043
&& chown -R steam:steam /home/steam
4144
USER steam

0 commit comments

Comments
 (0)