From a36ceddfaa7b4ab396e6593761fceb1ca55d9dad Mon Sep 17 00:00:00 2001 From: Taylor McKinnon Date: Fri, 1 Nov 2024 15:23:20 -0700 Subject: [PATCH] add valheim image --- images/valheim/Dockerfile | 51 +++++++++++++++++++++++++++++ images/valheim/docker-entrypoint.sh | 50 ++++++++++++++++++++++++++++ images/valheim/image.conf | 4 +++ 3 files changed, 105 insertions(+) create mode 100644 images/valheim/Dockerfile create mode 100755 images/valheim/docker-entrypoint.sh create mode 100644 images/valheim/image.conf diff --git a/images/valheim/Dockerfile b/images/valheim/Dockerfile new file mode 100644 index 0000000..ac5898b --- /dev/null +++ b/images/valheim/Dockerfile @@ -0,0 +1,51 @@ +######## INSTALL ######## + +# Set the base image +FROM ubuntu:24.04 + +# Set environment variables +ENV USER root +ENV HOME /root + +# Set working directory +WORKDIR $HOME + +# Insert Steam prompt answers +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN echo steam steam/question select "I AGREE" | debconf-set-selections \ + && echo steam steam/license note '' | debconf-set-selections + +# Update the repository and install SteamCMD +ARG DEBIAN_FRONTEND=noninteractive +RUN dpkg --add-architecture i386 \ + && apt-get update -y \ + && apt-get install -y --no-install-recommends ca-certificates locales steamcmd \ + && rm -rf /var/lib/apt/lists/* + +# Add unicode support +RUN locale-gen en_US.UTF-8 +ENV LANG 'en_US.UTF-8' +ENV LANGUAGE 'en_US:en' + +# Create symlink for executable +RUN ln -s /usr/games/steamcmd /usr/bin/steamcmd + +# Update SteamCMD and verify latest version +RUN steamcmd +quit + +# Fix missing directories and libraries +RUN mkdir -p $HOME/.steam \ + && ln -s $HOME/.local/share/Steam/steamcmd/linux32 $HOME/.steam/sdk32 \ + && ln -s $HOME/.local/share/Steam/steamcmd/linux64 $HOME/.steam/sdk64 \ + && ln -s $HOME/.steam/sdk32/steamclient.so $HOME/.steam/sdk32/steamservice.so \ + && ln -s $HOME/.steam/sdk64/steamclient.so $HOME/.steam/sdk64/steamservice.so + +# Add entrypoint script +COPY docker-entrypoint.sh /docker-entrypoint.sh + +ENV VALHEIM_SERVER_NAME="Valheim Server" +ENV VALHEIM_WORLD_NAME="Dedicated" +ENV VALHEIM_SERVER_PORT=2456 + +# Set default command +CMD ["/docker-entrypoint.sh"] diff --git a/images/valheim/docker-entrypoint.sh b/images/valheim/docker-entrypoint.sh new file mode 100755 index 0000000..088d3c7 --- /dev/null +++ b/images/valheim/docker-entrypoint.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +set -e + +if [ -z "$VALHEIM_SERVER_PORT" ]; then + echo "VALHEIM_SERVER_PORT must be set" + exit 1 +fi + +if [ -z "$VALHEIM_SERVER_NAME" ]; then + echo "VALHEIM_SERVER_NAME must be set" + exit 1 +fi + +if [ -z "$VALHEIM_SERVER_PASSWORD" ]; then + echo "VALHEIM_SERVER_PASSWORD must be set" + exit 1 +fi + +if [ -n "$VALHEIM_SERVER_PUBLIC" ]; then + _IS_PUBLIC=1 +else + _IS_PUBLIC=0 +fi + + +if [ ! -f "/data/.installed" ]; then + echo "Installing Valheim server..." + /usr/bin/steamcmd +force_install_dir /data/valheim +login anonymous +app_update 896660 validate +exit + touch /data/.initialized +else + echo "Updating Valheim server..." + /usr/bin/steamcmd +force_install_dir /data/valheim +login anonymous +app_update 896660 +quit +fi + + +echo "Starting Valheim server..." + +cd /data/valheim + +export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH +export SteamAppId=892970 + +./valheim_server.x86_64 \ + -name "$VALHEIM_SERVER_NAME" \ + -port "$VALHEIM_SERVER_PORT" \ + -world "$VALHEIM_WORLD_NAME" \ + -password "$VALHEIM_SERVER_PASSWORD" \ + -savedir "/data/saves" \ + -public "${_IS_PUBLIC}" diff --git a/images/valheim/image.conf b/images/valheim/image.conf new file mode 100644 index 0000000..6085275 --- /dev/null +++ b/images/valheim/image.conf @@ -0,0 +1,4 @@ +[image] +registry = ghcr.io +repository = tmacro/img +platforms = linux/amd64, linux/arm64