Skip to content

Commit

Permalink
add valheim image
Browse files Browse the repository at this point in the history
  • Loading branch information
tmacro committed Nov 1, 2024
1 parent 4474d28 commit a36cedd
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
51 changes: 51 additions & 0 deletions images/valheim/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
50 changes: 50 additions & 0 deletions images/valheim/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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}"
4 changes: 4 additions & 0 deletions images/valheim/image.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[image]
registry = ghcr.io
repository = tmacro/img
platforms = linux/amd64, linux/arm64

0 comments on commit a36cedd

Please sign in to comment.