diff --git a/Dockerfile.ubuntu-1804 b/Dockerfile.ubuntu-1804 index 3f9bac1..bb1f8e1 100644 --- a/Dockerfile.ubuntu-1804 +++ b/Dockerfile.ubuntu-1804 @@ -17,7 +17,7 @@ ENV LGSM_SERVERFILES=/data/serverfiles ENV LGSM_CONFIG=/data/config-lgsm ENV GAMESERVER=jc2server ENV UPDATE_CHECK=1800 -ENV USERNAME=linuxgsm +ENV USER=linuxgsm ENV UID=1000 ENV GID=1000 @@ -70,9 +70,13 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \ # Install Node.js RUN echo "**** Install Node.js ****" \ - && curl -sL https://deb.nodesource.com/setup_16.x | bash - \ + && set -uex \ + && mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && NODE_MAJOR=16 \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \ && apt-get update \ - && apt-get install -y nodejs \ + && apt-get install nodejs -y \ && apt-get -y autoremove \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/* \ @@ -89,13 +93,13 @@ WORKDIR /app RUN echo "**** Add linuxgsm user ****" \ && mkdir /data \ # Create the user - && groupadd --gid $GID $USERNAME \ - && useradd --uid $UID --gid $GID -m $USERNAME \ + && groupadd --gid $GID $USER \ + && useradd --uid $UID --gid $GID -m $USER \ # # [Optional] Add sudo support. Omit if you don't need to install software after connecting. - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && chown $USERNAME:$USERNAME /data + && echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \ + && chmod 0440 /etc/sudoers.d/$USER \ + && chown $USER:$USER /data HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /app/entrypoint-healthcheck.sh || exit 1 @@ -116,7 +120,7 @@ RUN echo "**** Get LinuxGSM Modules ****" \ && chmod +x /app/lgsm/modules/* \ && cd ../ \ && rm -rf LinuxGSM \ - && chown -R $USERNAME:$USERNAME /app + && chown -R $USER:$USER /app ARG CACHEBUST=1 RUN echo "$CACHEBUST" diff --git a/Dockerfile.ubuntu-2004 b/Dockerfile.ubuntu-2004 index 521cf5c..19d99ff 100644 --- a/Dockerfile.ubuntu-2004 +++ b/Dockerfile.ubuntu-2004 @@ -17,7 +17,7 @@ ENV LGSM_SERVERFILES=/data/serverfiles ENV LGSM_CONFIG=/data/config-lgsm ENV GAMESERVER=jc2server ENV UPDATE_CHECK=1800 -ENV USERNAME=linuxgsm +ENV USER=linuxgsm ENV UID=1000 ENV GID=1000 @@ -70,9 +70,13 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \ # Install Node.js RUN echo "**** Install Node.js ****" \ - && curl -sL https://deb.nodesource.com/setup_20.x | bash - \ + && set -uex \ + && mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && NODE_MAJOR=20 \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \ && apt-get update \ - && apt-get install -y nodejs \ + && apt-get install nodejs -y \ && apt-get -y autoremove \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/* \ @@ -89,13 +93,13 @@ WORKDIR /app RUN echo "**** Add linuxgsm user ****" \ && mkdir /data \ # Create the user - && groupadd --gid $GID $USERNAME \ - && useradd --uid $UID --gid $GID -m $USERNAME \ + && groupadd --gid $GID $USER \ + && useradd --uid $UID --gid $GID -m $USER \ # # [Optional] Add sudo support. Omit if you don't need to install software after connecting. - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && chown $USERNAME:$USERNAME /data + && echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \ + && chmod 0440 /etc/sudoers.d/$USER \ + && chown $USER:$USER /data HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /app/entrypoint-healthcheck.sh || exit 1 @@ -116,7 +120,7 @@ RUN echo "**** Get LinuxGSM Modules ****" \ && chmod +x /app/lgsm/modules/* \ && cd ../ \ && rm -rf LinuxGSM \ - && chown -R $USERNAME:$USERNAME /app + && chown -R $USER:$USER /app ARG CACHEBUST=1 RUN echo "$CACHEBUST" diff --git a/Dockerfile.ubuntu-2204 b/Dockerfile.ubuntu-2204 index d262160..0bc7d22 100644 --- a/Dockerfile.ubuntu-2204 +++ b/Dockerfile.ubuntu-2204 @@ -17,7 +17,7 @@ ENV LGSM_SERVERFILES=/data/serverfiles ENV LGSM_CONFIG=/data/config-lgsm ENV GAMESERVER=jc2server ENV UPDATE_CHECK=1800 -ENV USERNAME=linuxgsm +ENV USER=linuxgsm ENV UID=1000 ENV GID=1000 @@ -42,6 +42,7 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \ distro-info \ file \ git \ + gnupg \ gosu \ gzip \ hostname \ @@ -70,9 +71,13 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \ # Install Node.js RUN echo "**** Install Node.js ****" \ - && curl -sL https://deb.nodesource.com/setup_20.x | bash - \ + && set -uex \ + && mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && NODE_MAJOR=20 \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \ && apt-get update \ - && apt-get install -y nodejs \ + && apt-get install nodejs -y \ && apt-get -y autoremove \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/* \ @@ -89,13 +94,13 @@ WORKDIR /app RUN echo "**** Add linuxgsm user ****" \ && mkdir /data \ # Create the user - && groupadd --gid $GID $USERNAME \ - && useradd --uid $UID --gid $GID -m $USERNAME \ + && groupadd --gid $GID $USER \ + && useradd --uid $UID --gid $GID -m $USER \ # # [Optional] Add sudo support. Omit if you don't need to install software after connecting. - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && chown $USERNAME:$USERNAME /data + && echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \ + && chmod 0440 /etc/sudoers.d/$USER \ + && chown $USER:$USER /data HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /app/entrypoint-healthcheck.sh || exit 1 @@ -116,7 +121,7 @@ RUN echo "**** Get LinuxGSM Modules ****" \ && chmod +x /app/lgsm/modules/* \ && cd ../ \ && rm -rf LinuxGSM \ - && chown -R $USERNAME:$USERNAME /app + && chown -R $USER:$USER /app ARG CACHEBUST=1 RUN echo "$CACHEBUST" diff --git a/entrypoint-healthcheck.sh b/entrypoint-healthcheck.sh index 96091ac..8e2a849 100755 --- a/entrypoint-healthcheck.sh +++ b/entrypoint-healthcheck.sh @@ -1,2 +1,2 @@ #!/bin/bash -exec gosu "${USERNAME}" /app/*server monitor || exit 1 +exec gosu "${USER}" /app/*server monitor || exit 1 diff --git a/entrypoint-user.sh b/entrypoint-user.sh index e7d0b86..debc3af 100755 --- a/entrypoint-user.sh +++ b/entrypoint-user.sh @@ -12,9 +12,6 @@ exit_handler_user() { echo -e "Loading exit handler" trap exit_handler_user SIGQUIT SIGINT SIGTERM -# Define ${USER} as missing in docker container -USER="${USERNAME}" - # Setup game server if [ ! -f "${GAMESERVER}" ]; then echo -e "" diff --git a/entrypoint.sh b/entrypoint.sh index 967244c..7cfa8e6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,7 +3,7 @@ exit_handler() { # Execute the shutdown commands echo -e "Stopping ${GAMESERVER}" - exec gosu "${USERNAME}" ./"${GAMESERVER}" stop + exec gosu "${USER}" ./"${GAMESERVER}" stop exitcode=$? exit ${exitcode} } @@ -21,7 +21,7 @@ echo -e "BUILD TIME: $(cat /build-time.txt)" echo -e "GAMESERVER: ${GAMESERVER}" echo -e "DISTRO: ${DISTRO}" echo -e "" -echo -e "USER: ${USERNAME}" +echo -e "USER: ${USER}" echo -e "UID: ${UID}" echo -e "GID: ${GID}" echo -e "" @@ -53,11 +53,11 @@ usermod -u "${UID}" -m -d /data linuxgsm > /dev/null 2>&1 echo -e "setting GID to ${GID}" groupmod -g "${GID}" linuxgsm echo -e "updating permissions" -chown -R "${USERNAME}":"${USERNAME}" /data +chown -R "${USER}":"${USER}" /data export HOME=/data echo -e "" -echo -e "Switch to user ${USERNAME}" +echo -e "Switch to user ${USER}" echo -e "=================================" -exec gosu "${USERNAME}" /app/entrypoint-user.sh & +exec gosu "${USER}" /app/entrypoint-user.sh & wait