commit 5f7d650161da822a813fde89f20fb1f59ca9e17f Author: Pratyush Desai Date: Wed Apr 30 05:47:26 2025 +0530 SteamCMD podman compatible openSUSE contianer This is the initial work. Will add labels w/e Signed-off-by: Pratyush Desai diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..25dc646 --- /dev/null +++ b/Containerfile @@ -0,0 +1,45 @@ +# Stage 1: Build SteamCMD environment +FROM opensuse/leap:15.6 AS builder + +# Install dependencies +RUN --mount=type=cache,id=sle-pkgs,sharing=locked,target=/var/cache/zypp zypper --non-interactive update && \ + zypper --non-interactive install \ + bzip2 ca-certificates curl libarchive13 glibc-32bit libgcc_s1-32bit p7zip tar unzip gzip wget xz + +ENV LANG=en_US.UTF-8 +ENV LANGUAGE=en_US.UTF-8 +ENV HOME=/app + +RUN groupadd -g 1000 steamcmd && \ + useradd -u 1000 -g 1000 -d /app -s /bin/bash steamcmd && \ + mkdir -p /app /output && \ + chown 1000:1000 -R /app && \ + chown 1000:1000 -R /output + +USER steamcmd +WORKDIR /app + +# Download SteamCMD; run it once for self-updates +RUN wget -qO- http://media.steampowered.com/installer/steamcmd_linux.tar.gz | tar xz -C /app && \ + chmod +x /app/steamcmd.sh && \ + ./steamcmd.sh +force_install_dir /output +login anonymous +quit + +COPY --chown=1000:1000 setuser.sh /usr/local/bin/setuser.sh +RUN chmod +x /usr/local/bin/setuser.sh + +# Stage 2: Final Image +FROM opensuse/leap:15.6 + +# Copy SteamCMD files from builder stage +COPY --from=builder /app /app +COPY --from=builder /output /output +COPY --from=builder /usr/local/bin/setuser.sh /usr/local/bin/setuser.sh + +RUN chmod +x /usr/local/bin/setuser.sh + +ENV HOME=/app +USER steamcmd +WORKDIR /app + + +CMD ["/app/steamcmd.sh", "+quit"] \ No newline at end of file diff --git a/setuser.sh b/setuser.sh new file mode 100644 index 0000000..b34dd52 --- /dev/null +++ b/setuser.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# setuser.sh: Helper script to set the user and group. + +if [ -z "$1" ]; then + echo "Usage: setuser.sh " + exit 1 +fi + +USER_NAME="$1" +USER_ID="${2:-1000}" # Default to 1000 if not provided +GROUP_ID="${3:-1000}" # Default to 1000 if not provided + +# Check if the group exists, create if it doesn't +if ! getent group "$USER_NAME" >/dev/null 2>&1; then + groupadd -g "$GROUP_ID" "$USER_NAME" +fi + +# Check if the user exists, create if it doesn't +if ! id -u "$USER_NAME" >/dev/null 2>&1; then + useradd -u "$USER_ID" -g "$GROUP_ID" -d /home/"$USER_NAME" -s /bin/bash "$USER_NAME" +fi +USER="$USER_NAME" +# Set the user. +exec setpriv --reuid "$USER_ID" --regid "$GROUP_ID" --init-groups -- /bin/sh -c "$0" \ No newline at end of file