Merge pull request #255 from cerc-io/dboreham/fix-js-builder-gid-problem

Do not switch gid/uid for root and system users
This commit is contained in:
David Boreham 2023-03-28 19:54:37 -06:00 committed by GitHub
commit df23476f0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,12 +17,16 @@ ARG NPM_GLOBAL=/usr/local/share/npm-global
# Add NPM global to PATH. # Add NPM global to PATH.
ENV PATH=${NPM_GLOBAL}/bin:${PATH} ENV PATH=${NPM_GLOBAL}/bin:${PATH}
SHELL ["/bin/bash", "-c"]
RUN \ RUN \
if [ ${CERC_HOST_GID} -ne 1000 ] ; then \ # Don't switch container uid/gid if the host uid/gid is 1000 (which means it's already correct),
groupmod -g ${CERC_HOST_GID} ${USERNAME} ; \ # or root (which won't work anyway) or <= 100 (which also won't work).
if [[ ${CERC_HOST_GID} -ne 1000 && ${CERC_HOST_GID} -ne 0 && ${CERC_HOST_GID} -gt 100 ]]; then \
groupmod -g ${CERC_HOST_GID} ${USERNAME}; \
fi \ fi \
&& if [ ${CERC_HOST_UID} -ne 1000 ] ; then \ && if [[ ${CERC_HOST_UID} -ne 1000 && ${CERC_HOST_UID} -ne 0 && ${CERC_HOST_UID} -gt 100 ]]; then \
usermod -u ${CERC_HOST_UID} -g ${CERC_HOST_GID} ${USERNAME} && chown ${CERC_HOST_UID}:${CERC_HOST_GID} /home/${USERNAME} ; \ usermod -u ${CERC_HOST_UID} -g ${CERC_HOST_GID} ${USERNAME} && chown ${CERC_HOST_UID}:${CERC_HOST_GID} /home/${USERNAME}; \
fi fi
RUN \ RUN \