Swapped to debian and fixing user issues.

This commit is contained in:
Matthew Green 2025-04-08 15:25:33 -05:00
parent bf552562bb
commit e01fdee37f
2 changed files with 24 additions and 19 deletions

View file

@ -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
# 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"]

View file

@ -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\""
# Run server directly (no need to su)
cd $SERVER_DIR && HOME=$INSTALL_DIR ./LocalAdmin $PORT #--config "$CONFIGS"