Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bootstrap to vanilla; enables use of env variables (a la tshock image) #68

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion vanilla/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ LABEL maintainer="Ryan Sheehan <[email protected]>"

EXPOSE 7777

# env used in the bootstrap
ENV CONFIGPATH=/root/.local/share/Terraria/Worlds
ENV WORLD_FILENAME=""

VOLUME ["/root/.local/share/Terraria/Worlds", "/config"]

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

ENTRYPOINT ["mono", "/terraria-server/TerrariaServer.exe"]
# add the bootstrap file
COPY bootstrap.sh /terraria-server/bootstrap.sh
RUN chmod +x /terraria-server/bootstrap.sh
ENTRYPOINT ["/terraria-server/bootstrap.sh"]
7 changes: 7 additions & 0 deletions vanilla/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

if [ -z "$WORLD_FILENAME" ]; then
/terraria-server/TerrariaServer $@
else
/terraria-server/TerrariaServer -world $CONFIGPATH/$WORLD_FILENAME $@
Copy link
Owner

@ryansheehan ryansheehan Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intent is that worlds are volumed in the /root/.local/share/Terraria/Worlds path where the executable defaults saving world files. Is the intent that the configuration data lives side-by-side with the world file on the host machine?

Making this change would force users through the bootstrapper. If they do not have a world file how would that work? They would have to volume in the directory to save the data and then copy the data to where they store their config.

Copy link
Author

@doctorjei doctorjei Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! You're right, I shouldn't have the "-world" on line 4. I can fix that.

The goal was to make it so that the bootstrapper is a pass-through if WORLD_FILENAME is not defined. I.e., if they do not define WORLD_FILENAME, it should just call "/terraria-server/TerrariaServer $@" (which should still work if the users append "-world somefile.wld").

With respect to the CONFIGPATH, this is really meant to sync up with the tshock version (which defaults to the world path - "ENV CONFIGPATH=/root/.local/share/Terraria/Worlds"). I actually moved over from the tshock version to vanilla (due to the most recent Terraria update), so my goal was to sync up with that. Alternatively, I could add another "WORLDPATH" variable if we wanted to separate the world and configuration paths.

The overall goal was to try avoiding the necessity of hardcoding world file paths into the entrypoint / command, but to do so by using an abstraction that might be helpful in the future (by adding a thin wrapper around the vanilla server launcher).

fi