ci: make container build handle being built as 'root' correctly
This commit is contained in:
parent
8b674a0dea
commit
195c8f980e
@ -12,10 +12,14 @@ RUN GOBIN=/usr/local/bin go install git.offline-twitter.com/offline-labs/gocheck
|
|||||||
|
|
||||||
# Create a user in the container with the same UID as on the host machine, to avoid ownership conflicts.
|
# Create a user in the container with the same UID as on the host machine, to avoid ownership conflicts.
|
||||||
# The user gets sudo of course.
|
# The user gets sudo of course.
|
||||||
|
#
|
||||||
|
# If the host user is `root` (uid = 0), we skip creating a new user, because it will fail otherwise.
|
||||||
ARG USERNAME
|
ARG USERNAME
|
||||||
ARG UID
|
ARG UID
|
||||||
ARG GID
|
ARG GID
|
||||||
RUN addgroup -g ${GID} ${USERNAME}
|
RUN if [ "${UID}" -ne 0 ]; then \
|
||||||
RUN adduser -D -u ${UID} -G ${USERNAME} ${USERNAME}
|
addgroup -g "${GID}" "${USERNAME}" && \
|
||||||
RUN echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME}
|
adduser -D -u "${UID}" -G "${USERNAME}" "${USERNAME}" && \
|
||||||
|
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/"${USERNAME}"; \
|
||||||
|
fi
|
||||||
USER ${USERNAME}
|
USER ${USERNAME}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user