From e01fdee37feee47f74d9042ab3c0a41595fe90c1 Mon Sep 17 00:00:00 2001 From: Matthew Green Date: Tue, 8 Apr 2025 15:25:33 -0500 Subject: [PATCH] Swapped to debian and fixing user issues. --- Dockerfile | 28 ++++++++++++++++++---------- start.sh | 15 ++++++--------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 14d7de9..f2e29b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM steamcmd/steamcmd:latest +FROM steamcmd/steamcmd:debian ENV PORT=7777 ENV UID=1000 @@ -16,18 +16,26 @@ RUN mkdir -p ${INSTALL_DIR} ${SERVER_DIR} ${CONFIG_DIR} RUN apt-get update && \ apt-get install -y libicu-dev -# Create a new group and user using groupadd/useradd instead of addgroup/adduser -RUN groupadd --gid $GID steam && \ - useradd --disabled-password --gecos '' --uid $UID --gid $GID steam - -COPY start.sh $INSTALL_DIR/start.sh # COPY config_gameplay.txt $CONFIGS/config_gameplay.txt # COPY config_remoteadmin.txt $CONFIGS/config_remoteadmin.txt # COPY config_localadmin_global.txt $CONFIGS/../config_localadmin_global.txt # COPY localadmin_internal_data.json $CONFIGS/../localadmin_internal_data.json -# Change ownership of directories and set the start script as executable -RUN chown $UID:$GID -R ${STEAM_DIR} ${INSTALL_DIR} ${SERVER_DIR} ${CONFIG_DIR} && \ - chmod +x ${INSTALL_DIR}/start.sh +# Create steam user and group +RUN groupadd --gid $GID steam && \ + useradd --create-home -c 'Steam User' -l --uid $UID --gid $GID --home-dir $INSTALL_DIR steam && \ + chown -R steam:steam ${INSTALL_DIR} -ENTRYPOINT /bin/sh ${INSTALL_DIR}/start.sh \ No newline at end of file +# Copy and prepare start script +COPY start.sh $INSTALL_DIR/start.sh +RUN chmod +x ${INSTALL_DIR}/start.sh && \ + chown steam:steam ${INSTALL_DIR}/start.sh + +# Switch to steam user +USER steam +WORKDIR $INSTALL_DIR + +# Set HOME environment variable to INSTALL_DIR to force steamcmd to use it +ENV HOME=$INSTALL_DIR + +ENTRYPOINT ["/bin/sh", "start.sh"] \ No newline at end of file diff --git a/start.sh b/start.sh index 9e934cb..4be3f43 100644 --- a/start.sh +++ b/start.sh @@ -4,14 +4,11 @@ echo "Current user is: $(whoami)" # Install/update SCP:SL server steamcmd +force_install_dir $SERVER_DIR +login anonymous +app_update 996560 validate +quit -# Ensure proper ownership -chown -R steam:steam $INSTALL_DIR +# # Define config directory path +# CONFIGS="$INSTALL_DIR/.config/SCP Secret Laboratory/config/$PORT" -# Define config directory path -CONFIGS="$INSTALL_DIR/.config/SCP Secret Laboratory/config/$PORT" +# # Ensure config directory exists +# mkdir -p "$CONFIGS" -# Ensure config directory exists -mkdir -p "$CONFIGS" - -# Switch to steam user and run server -su - steam -c "cd $SERVER_DIR && HOME=$INSTALL_DIR ./LocalAdmin $PORT --config \"$CONFIGS\"" \ No newline at end of file +# Run server directly (no need to su) +cd $SERVER_DIR && HOME=$INSTALL_DIR ./LocalAdmin $PORT #--config "$CONFIGS" \ No newline at end of file