@@ -32,8 +32,12 @@ RUN apt-get update \
3232 gosu \
3333 tini \
3434 && rm -rf /var/lib/apt/lists/* \
35- && groupadd --gid "${TRUTHGATE_GID}" truthgate \
36- && useradd --uid "${TRUTHGATE_UID}" --gid truthgate --create-home --shell /usr/sbin/nologin truthgate \
35+ && if ! getent group "${TRUTHGATE_GID}" >/dev/null; then groupadd --gid "${TRUTHGATE_GID}" truthgate; fi \
36+ && if existing_user="$(getent passwd " ${TRUTHGATE_UID}" | cut -d: -f1)" && [ -n "${existing_user}" ]; then \
37+ usermod --login truthgate --home /home/truthgate --move-home --shell /usr/sbin/nologin "${existing_user}" ; \
38+ else \
39+ useradd --uid "${TRUTHGATE_UID}" --gid "${TRUTHGATE_GID}" --create-home --shell /usr/sbin/nologin truthgate; \
40+ fi \
3741 && mkdir -p /home/truthgate/.aspnet \
3842 && ln -s /data/truthgate/secrets/data-protection-keys /home/truthgate/.aspnet/DataProtection-Keys
3943
@@ -77,10 +81,14 @@ RUN apt-get update \
7781 gosu \
7882 tini \
7983 && rm -rf /var/lib/apt/lists/* \
80- && groupadd --gid "${TRUTHGATE_GID}" truthgate \
81- && useradd --uid "${TRUTHGATE_UID}" --gid truthgate --create-home --shell /bin/bash truthgate \
84+ && if ! getent group "${TRUTHGATE_GID}" >/dev/null; then groupadd --gid "${TRUTHGATE_GID}" truthgate; fi \
85+ && if existing_user="$(getent passwd " ${TRUTHGATE_UID}" | cut -d: -f1)" && [ -n "${existing_user}" ]; then \
86+ usermod --login truthgate --home /home/truthgate --move-home --shell /bin/bash "${existing_user}" ; \
87+ else \
88+ useradd --uid "${TRUTHGATE_UID}" --gid "${TRUTHGATE_GID}" --create-home --shell /bin/bash truthgate; \
89+ fi \
8290 && mkdir -p /workspace /home/truthgate/.aspnet \
83- && chown truthgate:truthgate /workspace \
91+ && chown "${TRUTHGATE_UID}:${TRUTHGATE_GID}" /workspace \
8492 && ln -s /data/truthgate/secrets/data-protection-keys /home/truthgate/.aspnet/DataProtection-Keys
8593
8694COPY --from=kubo /usr/local/bin/ipfs /usr/local/bin/ipfs
0 commit comments