mirror of
https://github.com/luzifer-docker/terraria.git
synced 2024-11-08 12:40:02 +00:00
Improve image, add command wrapper
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9ec74b9601
commit
1c5ee42f5c
5 changed files with 41 additions and 21 deletions
30
Dockerfile
30
Dockerfile
|
@ -1,7 +1,11 @@
|
|||
FROM debian:stretch
|
||||
|
||||
ENV TERRARIA_VERISON=1353 \
|
||||
DUMB_INIT_VERSION=1.2.1
|
||||
DUMB_INIT_VERSION=1.2.1 \
|
||||
GOSU_VERSION=1.10 \
|
||||
TERRARIA_DOCKER_VERSION=v0.1.0 \
|
||||
HOME=/home/gameserver \
|
||||
SERVER=/home/gameserver/terraria
|
||||
|
||||
RUN set -ex \
|
||||
&& apt-get update \
|
||||
|
@ -12,22 +16,22 @@ RUN set -ex \
|
|||
unzip \
|
||||
&& useradd -m gameserver \
|
||||
&& mkdir /data && chown gameserver: /data \
|
||||
&& curl -sSfLo /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_amd64 \
|
||||
&& chmod +x /usr/local/bin/dumb-init \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
USER gameserver
|
||||
ENV HOME /home/gameserver
|
||||
ENV SERVER $HOME/terraria
|
||||
|
||||
RUN set -ex \
|
||||
&& curl -sSfLo /usr/local/bin/dumb-init "https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_amd64" \
|
||||
&& curl -sSfLo /usr/local/bin/gosu https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64 \
|
||||
&& curl -sSfL "https://github.com/Luzifer/terraria-docker/releases/download/${TERRARIA_DOCKER_VERSION}/terraria-docker_linux_amd64.tar.gz" | tar -xz -C /usr/local/bin \
|
||||
&& chmod +x \
|
||||
/usr/local/bin/dumb-init \
|
||||
/usr/local/bin/gosu \
|
||||
&& mkdir -p ${SERVER} \
|
||||
&& curl -sSLo /tmp/terraria.zip http://terraria.org/server/terraria-server-${TERRARIA_VERISON}.zip && unzip -d ${SERVER} /tmp/terraria.zip \
|
||||
&& ln -s ${SERVER}/terraria-server-* ${SERVER}/server \
|
||||
&& rm /tmp/terraria.zip
|
||||
&& curl -sSfLo /tmp/terraria.zip "http://terraria.org/server/terraria-server-${TERRARIA_VERISON}.zip" \
|
||||
&& unzip -d ${SERVER} /tmp/terraria.zip \
|
||||
&& chown -R gameserver:gameserver ${SERVER} \
|
||||
&& rm /tmp/terraria.zip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY config.ini ${SERVER}/config.ini.default
|
||||
COPY start.sh ${SERVER}/start.sh
|
||||
COPY terraria_cmd.sh /usr/local/bin/terraria_cmd
|
||||
|
||||
VOLUME /data
|
||||
EXPOSE 7777/udp 7777
|
||||
|
|
15
README.md
15
README.md
|
@ -6,13 +6,20 @@ This image contains a [Terraria](http://terraria.org/) 1.3.5.3 server with autom
|
|||
|
||||
You can simply run the image with the default settings:
|
||||
|
||||
```
|
||||
docker run -d -p 7777:7777 luzifer/terraria
|
||||
```console
|
||||
$ docker run -d --name=terraria -p 7777:7777 luzifer/terraria
|
||||
```
|
||||
|
||||
If you want the world to persist you can mount a volume into the container:
|
||||
|
||||
```
|
||||
docker run -d -p 7777:7777 -v ~/terraria:/data luzifer/terraria
|
||||
```console
|
||||
$ docker run -d --name=terraria -p 7777:7777 -v ~/terraria:/data luzifer/terraria
|
||||
```
|
||||
|
||||
### Interacting with the server command line
|
||||
|
||||
In case you want to use the [console commands](https://terraria.gamepedia.com/Server#List_of_console_commands) on the Terraria server this image has a helper for you:
|
||||
|
||||
```console
|
||||
$ docker exec terraria terraria_cmd save
|
||||
```
|
||||
|
|
|
@ -30,7 +30,7 @@ world=/data/world/Terraria.wld
|
|||
|
||||
#Creates a new world if none is found. World size is specified by: 1(small), 2(medium), and 3(large).
|
||||
#autocreate=1
|
||||
autocreate=3
|
||||
autocreate=1
|
||||
|
||||
#Sets the world seed when using autocreate
|
||||
#seed=AwesomeSeed
|
||||
|
|
11
start.sh
11
start.sh
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
#!/usr/local/bin/dumb-init /bin/bash
|
||||
set -euxo pipefail
|
||||
|
||||
if ! [ -e /data/config.ini ]; then
|
||||
cp ${SERVER}/config.ini.default /data/config.ini
|
||||
cp ${SERVER}/config.ini.default /data/config.ini
|
||||
fi
|
||||
|
||||
SERVER_BINARY=$(find /home/gameserver -name 'TerrariaServer.bin.x86_64')
|
||||
|
@ -10,4 +10,9 @@ SERVER_BINARY=$(find /home/gameserver -name 'TerrariaServer.bin.x86_64')
|
|||
# FIX: The ZIP archive does not have correct permissions
|
||||
chmod +x "${SERVER_BINARY}"
|
||||
|
||||
exec tail -f /dev/null | "${SERVER_BINARY}" -config /data/config.ini "$@"
|
||||
# Force data path to be writable
|
||||
chown -R gameserver:gameserver /data
|
||||
|
||||
exec terraria-docker_linux_amd64 | /usr/local/bin/gosu \
|
||||
gameserver \
|
||||
${SERVER_BINARY} -config /data/config.ini "$@"
|
||||
|
|
4
terraria_cmd.sh
Executable file
4
terraria_cmd.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "$@" >/home/gameserver/terraria_cmd
|
Loading…
Reference in a new issue