From b0abd0079ebc0106cca3e8c6057010fae608eade Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Tue, 16 Nov 2021 18:27:39 -0600 Subject: [PATCH] init --- .gitignore | 2 ++ Dockerfile | 55 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 6 +++++ build-image-files.sh | 19 +++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 build-image-files.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0f96d17 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +steamcmd-fedora-*.img* +*.swp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..81ee834 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,55 @@ +# based on 'CM2Walki/steamcmd' +# modified for a more familiar/up-to-date base (fedora+test run) + +FROM fedora:35 +LABEL maintainer="me@jlay.io" \ + org.opencontainers.image.authors="me@jlay.io" +ARG PUID=1000 + +ENV USER steam +ENV HOMEDIR "/home/${USER}" +ENV STEAMCMDDIR "${HOMEDIR}/steamcmd" + +# Install, update & upgrade packages +# Create user for the server +# This also creates the home directory we later need +# Clean TMP, dnf cache and other stuff to make the image smaller +# Create Directory for SteamCMD +# Download SteamCMD +# Extract and delete archive +# Run steamcmd once to test things out/let it update +# +# NOTE: steamcmd doesn't appreciate the 'upstream' LANG: +# WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work. +# may drop this. +RUN set -x \ + && sed -i -e 's/^LANG=".*"$/LANG="en_US.UTF-8"/' /etc/locale.conf \ + && echo -e 'max_parallel_downloads=20\nfastestmirror=False\ndeltarpm=False\n' | tee -a /etc/dnf/dnf.conf \ + && dnf install -y \ + util-linux \ + findutils \ + wget \ + ca-certificates \ + vim \ + SDL2.{x86_64,i686} \ + less \ + curl \ + libstdc++.{x86_64,i686} \ + libgcc.{x86_64,i686} \ + glibc.{x86_64,i686} \ + && useradd -u "${PUID}" -m "${USER}" \ + && su "${USER}" -c \ + "mkdir -p \"${STEAMCMDDIR}\" \ + && wget -qO- 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz' | tar xvzf - -C \"${STEAMCMDDIR}\" \ + && \"./${STEAMCMDDIR}/steamcmd.sh\" +quit \ + && mkdir -p \"${HOMEDIR}/.steam/sdk32\" \ + && ln -s \"${STEAMCMDDIR}/linux32/steamclient.so\" \"${HOMEDIR}/.steam/sdk32/steamclient.so\" \ + && ln -s \"${STEAMCMDDIR}/linux32/steamcmd\" \"${STEAMCMDDIR}/linux32/steam\" \ + && ln -s \"${STEAMCMDDIR}/steamcmd.sh\" \"${STEAMCMDDIR}/steam.sh\"" \ + && ln -s "${STEAMCMDDIR}/linux64/steamclient.so" "/usr/lib64/steamclient.so" \ + && dnf clean all \ + && ${STEAMCMDDIR}/steamcmd.sh +quit + +WORKDIR ${STEAMCMDDIR} + +VOLUME ${STEAMCMDDIR} diff --git a/README.md b/README.md new file mode 100644 index 0000000..668cb63 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +### steamcmd-docker +Extended version of [CM2Walki/steamcmd] (https://www.github.com/CM2Walki/steamcmd) + +Based on Fedora 35, a newer/more familiar OS (for me). Runs `steamcmd` once on build to update the client from the archive. No other notable changes. + +Some bootstrap utilities left around for convenience (eg: `wget`, `less`, `find`), at the cost of size. That is *not* a priority for this image, nearing 500MB. diff --git a/build-image-files.sh b/build-image-files.sh new file mode 100755 index 0000000..f6b15b9 --- /dev/null +++ b/build-image-files.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# base vars +NOW=$(date +%s) # epoch timestamp, eg: 1622772927 +BASE_TAG=$(awk '$1 == "FROM" {print $2}' Dockerfile | cut -d\: -f2) # eg: 2.7.1 +BUILD_TAG="fedora-${BASE_TAG}-${NOW}" +IMAGE_FILE="steamcmd-${BUILD_TAG}.img" + +echo "Building image steamcmd:${BUILD_TAG}" +podman build --tag steamcmd:${BUILD_TAG} . +podman save localhost/steamcmd:${BUILD_TAG} > ${IMAGE_FILE} +echo "" +echo "Wrote ${IMAGE_FILE}, cleaning up" +podman rmi steamcmd:${BUILD_TAG} +echo "Attempting to compress the image (begin comforting music)" +xz --keep --compress -9 --extreme --threads=$(nproc) ${IMAGE_FILE} +echo "" +echo "Finished, (non)compressed images created:" +ls -lah ${IMAGE_FILE}*