-
Notifications
You must be signed in to change notification settings - Fork 0
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
Terraria TModLoader Server Stack #1
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/.env |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
WEBHOOK_URL=https://discord.com/api/webhooks/123456789012345678/addyourownvalidwebhook-thisonewillnotwork | ||
SFTP_USERS=root:pass # required by image but not used | ||
SFTP_PASS=<FILL IN YOUR OWN> # Invalid default value, used by sftp.d script to set root pass (terraria image runs as root) | ||
DISCORD_USER=terraria.yourhostname.xyz |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
config.txt | ||
data |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM frolvlad/alpine-glibc:alpine-3.10 as build | ||
|
||
ARG TMOD_VERSION=0.11.8.5 | ||
ARG TERRARIA_VERSION=1353 | ||
|
||
RUN apk update &&\ | ||
apk add --no-cache --virtual build curl unzip &&\ | ||
apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing mono | ||
|
||
WORKDIR /tmod | ||
|
||
RUN cp /usr/lib/libMonoPosixHelper.so . | ||
|
||
# Server URL changed or down? | ||
#RUN curl -SLO "http://terraria.org/server/terraria-server-${TERRARIA_VERSION}.zip" &&\ | ||
# unzip terraria-server-*.zip &&\ | ||
# rm terraria-server-*.zip &&\ | ||
# cp --verbose -a "${TERRARIA_VERSION}/Linux/." . &&\ | ||
# rm -rf "${TERRARIA_VERSION}" &&\ | ||
# rm TerrariaServer.bin.x86 TerrariaServer.exe | ||
|
||
|
||
RUN curl -SL "https://github.com/tModLoader/tModLoader/releases/download/v${TMOD_VERSION}/tModLoader.Linux.v${TMOD_VERSION}.tar.gz" | tar -xvz &&\ | ||
rm -r lib tModLoader.bin.x86 tModLoaderServer.bin.x86 &&\ | ||
chmod u+x tModLoaderServer* | ||
|
||
FROM rfvgyhn/tmodloader:latest | ||
|
||
WORKDIR /terraria-server | ||
COPY --from=build /tmod ./ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Terraria tMod docker-compose | ||
|
||
Terraria tModLoader server. Used for Calamity Mod in my case. | ||
|
||
Image used: https://github.com/Rfvgyhn/tmodloader-docker (Stale, building updated PR fork for latest) | ||
|
||
## Optional notify container for non 24/7 servers | ||
|
||
Notify container for discord, dead simple webhook message poster to notify if server is up/down. Include a MSG with your hours. | ||
|
||
Edit your crontab (`crontab -e`) with hours you what your server to maintain. Slightly odd to not just do 24/7 but I believe it encourage more group play if you set server hours. | ||
|
||
``` crontab | ||
PATH=/usr/local/bin:/usr/bin:/bin | ||
45 20 * * 2-5 /home/a/game-server-stacks/terraria-tmod/online.sh | ||
0 0 * * 3-6 /home/a/game-server-stacks/terraria-tmod/offline.sh | ||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
version: '3' | ||
|
||
services: | ||
# --- Main TMOD Server, be sure to read parent image README for details/features/usage | ||
tmod: | ||
#image: 'rfvgyhn/tmodloader:latest' | ||
# Building latest tmod version from PR fork/custom Dockerfile tweaks | ||
build: | ||
context: . | ||
container_name: 'tmod' | ||
ports: | ||
- 7777:7777 | ||
volumes: | ||
- /etc/localtime:/etc/localtime:ro | ||
- ./data:/terraria | ||
- ./config.txt:/terraria-server/config.txt | ||
environment: | ||
- TMOD_SHUTDOWN_MSG="See ya!" | ||
# --- SFTP for manually managing mods/resources | ||
sftp: | ||
image: atmoz/sftp | ||
volumes: | ||
- ./data:/root/data | ||
- ./config.txt:/root/config.txt | ||
- /etc/ssh/ | ||
- ./enable-root-ssh:/etc/sftp.d/enable-root-ssh | ||
ports: | ||
- 2277:22 | ||
environment: | ||
- SFTP_USERS # .env but not used | ||
- SFTP_PASS # .env used to setup root in enable-root-ssh | ||
# --- Custom notification scripts to let discord friends know when servers up or down | ||
discord-notify: | ||
image: curlimages/curl | ||
environment: | ||
- WEBHOOK_URL | ||
- DISCORD_USER | ||
- MSG=Test Message | ||
volumes: | ||
- ./notify.sh:/usr/local/bin/notify.sh | ||
entrypoint: /usr/local/bin/notify.sh | ||
# --- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sed -i 's|PermitRootLogin no|PermitRootLogin yes|g' /etc/ssh/sshd_config | ||
echo -e "${SFTP_PASS}\n${SFTP_PASS}" | passwd root |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env sh | ||
set -ex | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should remove -x debug |
||
|
||
env | ||
|
||
echo '{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test if MSG is null and don't try to send to make container noop by default. |
||
"username": "' ${DISCORD_USER} '", | ||
"content": "' ${MSG} '" | ||
}' | curl \ | ||
-H "Content-Type: application/json" \ | ||
-d@- \ | ||
"${WEBHOOK_URL}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
set -ex | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should remove -x debug |
||
pushd "$(dirname $0)" # enables crontab to use this file | ||
if [ -n "$(docker ps -q --filter name=tmod)" ] || [ -n "$FORCE" ] ; then | ||
docker-compose stop tmod | ||
docker-compose run --rm -e MSG="[Offline] Shutdown!" discord-notify | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
set -ex | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should remove -x debug |
||
pushd "$(dirname $0)" # enables crontab to use this file | ||
if [ -z "$(docker ps -q --filter name=tmod)" ] || [ -n "$FORCE" ] ; then | ||
docker-compose up -d tmod | ||
docker-compose run --rm -e MSG="[Online] Calamity Mod Server started, connect using TModLoader. Hours: 9PM-Mid Tue-Fri" discord-notify | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disable auto-starting and sending 'test message' or modify script to just not send anything if MSG is null as a workaround to avoid using bleeding edge profile/docker-compose 2 beta features: https://stackoverflow.com/a/65957695/895792