Fix building base image on Mac. (#22)

Mac uses low group IDs for the default user, which would cause groupadd
to fail as the group already existed. Only make a new group if it
doesn't already exist.

This does raise other questions though as now we are technically having
the container run with a "services" group.
This commit is contained in:
ashmrtn 2022-05-09 17:20:03 -07:00 committed by GitHub
parent 82c9a1f182
commit 4ac3aa08f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ ARG gid=1000
# with the same UID and GID as the current user so that the mounted directory # with the same UID and GID as the current user so that the mounted directory
# doesn't end up with files with strange permissions. # doesn't end up with files with strange permissions.
RUN groupadd -g "${gid}" build && \ RUN if [ ! $(getent group ${gid}) ]; then groupadd -g "${gid}" build; fi && \
useradd -m -u "${uid}" -g "${gid}" build useradd -m -u "${uid}" -g "${gid}" build
USER build:build USER build:${gid}