Skip to content

Commit

Permalink
Merge pull request #85 from adamcavendish/user/adamcavendish/vanilla-env
Browse files Browse the repository at this point in the history
Update vanilla to respect WORLD_FILENAME
  • Loading branch information
ryansheehan authored Nov 20, 2021
2 parents 60ce6dd + 5ab7d8c commit 3a5ad3f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
17 changes: 14 additions & 3 deletions vanilla/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,36 @@ FROM alpine:3.11.6 AS base
RUN apk add --update-cache \
unzip

# add the bootstrap file
COPY bootstrap.sh /terraria-server/bootstrap.sh

ENV DL_LINK=https://terraria.org/api/download/pc-dedicated-server/terraria-server-143.zip
ENV DL_VERSION=143
ENV DL_FILE=terraria-server-143.zip

ADD $DL_LINK /$DL_FILE

RUN unzip /$DL_FILE -d /terraria && \
mkdir /terraria-server && \
mv /terraria/$DL_VERSION/Linux/* /terraria-server && \
chmod +x /terraria-server/TerrariaServer && \
chmod +x /terraria-server/TerrariaServer.bin.x86_64

FROM mono:6.8.0.96-slim
LABEL maintainer="Ryan Sheehan <rsheehan@gmail.com>"

# documenting ports
EXPOSE 7777

VOLUME ["/root/.local/share/Terraria/Worlds", "/config"]
# env used in the bootstrap
ENV LOGPATH=/terraria-server/logs
ENV WORLD_FILENAME=""

VOLUME ["/root/.local/share/Terraria/Worlds", "/config", "/terraria-server/logs"]

COPY --from=base /terraria-server/ /terraria-server/

ENTRYPOINT ["mono", "/terraria-server/TerrariaServer.exe"]
# Set working directory to server
WORKDIR /terraria-server

ENTRYPOINT [ "/bin/sh", "bootstrap.sh" ]

27 changes: 27 additions & 0 deletions vanilla/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

echo "Bootstrap:"
echo "world_file_name=$WORLD_FILENAME"
echo "logpath=$LOGPATH"

WORLD_PATH="/root/.local/share/Terraria/Worlds/$WORLD_FILENAME"
if [ -z "$WORLD_FILENAME" ]; then
echo "No world file specified in environment WORLD_FILENAME."
if [ -z "$@" ]; then
echo "Running server setup..."
else
echo "Running server with command flags: $@"
fi
mono TerrariaServer.exe -logpath "$LOGPATH" "$@"
else
echo "Environment WORLD_FILENAME specified"
if [ -f "$WORLD_PATH" ]; then
echo "Loading to world $WORLD_FILENAME..."
mono TerrariaServer.exe -logpath "$LOGPATH" "$@" -world "$WORLD_PATH" "$@"
else
echo "Unable to locate $WORLD_PATH."
echo "Please make sure your world file is volumed into docker: -v <path_to_world_file>:/root/.local/share/Terraria/Worlds"
exit 1
fi
fi

0 comments on commit 3a5ad3f

Please sign in to comment.