Files
tshock/Dockerfile

63 lines
1.9 KiB
Docker
Raw Normal View History

2025-12-30 17:58:31 +00:00
# syntax=docker/dockerfile:1.6
#
# TShock v5.2.4 for Terraria 1.4.4.9 (Linux amd64/arm64)
# - Pulls the official release asset from GitHub and extracts it
# - Runs as a non-root user
# - Persists runtime data under /data
#
FROM mcr.microsoft.com/dotnet/runtime:6.0-bookworm-slim
ARG TSHOCK_VERSION=5.2.4
ARG TERRARIA_VERSION=1.4.4.9
ARG TARGETARCH
ENV \
TSHOCK_VERSION="${TSHOCK_VERSION}" \
TERRARIA_VERSION="${TERRARIA_VERSION}" \
TSHOCK_DIR="/opt/tshock" \
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
unzip \
tar \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user and directories
RUN useradd -m -u 10001 -s /usr/sbin/nologin tshock \
&& mkdir -p "${TSHOCK_DIR}" /data \
&& chown -R tshock:tshock "${TSHOCK_DIR}" /data
WORKDIR /tmp
# Download the correct TShock release asset for the platform and extract it.
RUN set -eux; \
case "${TARGETARCH}" in \
amd64) ASSET_ARCH="amd64" ;; \
arm64) ASSET_ARCH="arm64" ;; \
*) echo "Unsupported TARGETARCH: ${TARGETARCH}"; exit 1 ;; \
esac; \
ASSET="TShock-${TSHOCK_VERSION}-for-Terraria-${TERRARIA_VERSION}-linux-${ASSET_ARCH}-Release.zip"; \
URL="https://github.com/Pryaxis/TShock/releases/download/v${TSHOCK_VERSION}/${ASSET}"; \
echo "Downloading ${URL}"; \
curl -fL --retry 5 --retry-delay 2 -o tshock.zip "${URL}"; \
unzip -q tshock.zip; \
# Release zip contains a tar; extract the first .tar found.
TAR="$(ls -1 *.tar | head -n 1)"; \
test -n "${TAR}"; \
tar -xf "${TAR}" -C "${TSHOCK_DIR}"; \
rm -rf /tmp/*; \
chmod +x "${TSHOCK_DIR}/TShock.Server" "${TSHOCK_DIR}/TShock.Installer" || true; \
chown -R tshock:tshock "${TSHOCK_DIR}"
# Persist server data (worlds/config/db/logs/etc). Bind-mount /data in compose.
VOLUME ["/data"]
EXPOSE 7777/tcp
USER tshock
WORKDIR /data
ENTRYPOINT ["/opt/tshock/TShock.Server"]