diff --git a/Dockerfile b/Dockerfile index 8436e53..744d50e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,15 @@ -FROM ubuntu:16.04 +FROM didstopia/base:nodejs-steamcmd-ubuntu-16.04 -MAINTAINER didstopia +MAINTAINER Didstopia # Fixes apt-get warnings ARG DEBIAN_FRONTEND=noninteractive -# Setup the locales -RUN apt-get clean && apt-get update && apt-get install -y apt-utils locales && locale-gen en_US.UTF-8 -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 - -# Run a quick apt-get update/upgrade -RUN apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get autoremove -y - -# Install dependencies, mainly for SteamCMD -RUN apt-get install -y \ - ca-certificates \ - software-properties-common \ - python-software-properties \ - lib32gcc1 \ - libstdc++6 \ - curl \ - wget \ - libvorbisfile3 - -# Run as root -USER root +# Install dependencies +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + net-tools && \ + rm -rf /var/lib/apt/lists/* # Create and set the steamcmd folder as a volume RUN mkdir -p /steamcmd/starbound @@ -38,6 +21,9 @@ ADD install.txt /install.txt # Copy the startup script ADD start_starbound.sh /start.sh +# Copy the default configuration file +ADD starbound_server.default.config /starbound_server.default.config + # Set the current working directory WORKDIR / diff --git a/docker_run.sh b/docker_run.sh index b95b9e2..5858748 100755 --- a/docker_run.sh +++ b/docker_run.sh @@ -1,8 +1,13 @@ #!/bin/bash +# Build changes (if necessary) ./docker_build.sh -# Run a vanilla server -docker run -p 0.0.0.0:21025:21025/tcp --env-file .env -v $(pwd)/starbound_data:/steamcmd/starbound --name starbound-server -d didstopia/starbound-server:latest +# Run a container +docker run -p 0.0.0.0:21025:21025/tcp --env-file .env -v "$(pwd)/starbound_data:/steamcmd/starbound" --name starbound-server -it --rm didstopia/starbound-server:latest -docker logs -f starbound-server +# Edit unit tests +#dgoss edit -p 0.0.0.0:21025:21025/tcp --env-file .env -v "$(pwd)/starbound_data:/steamcmd/starbound" --name starbound-server -d didstopia/starbound-server:latest + +# Run unit tests (production) +#GOSS_WAIT_OPTS="--retry-timeout 300s --sleep 1s > /dev/null" GOSS_SLEEP="15" dgoss run -p 0.0.0.0:21025:21025/tcp --env-file .env -v "$(pwd)/starbound_data:/steamcmd/starbound" --name starbound-server -d didstopia/starbound-server diff --git a/goss.yaml b/goss.yaml new file mode 100644 index 0000000..15206ef --- /dev/null +++ b/goss.yaml @@ -0,0 +1,13 @@ +command: + ps -eo comm | tee /tmp/what_do_i_see: + title: Starbound Server should be running + exit-status: 0 + stdout: + - starbound_serve + +port: + tcp:21025: + title: Starbound Server should be accepting TCP connections on port 21025 + listening: true + +## TODO: Test graceful shutdown diff --git a/goss_wait.yaml b/goss_wait.yaml new file mode 100644 index 0000000..fb00110 --- /dev/null +++ b/goss_wait.yaml @@ -0,0 +1,11 @@ +command: + ps -eo comm | tee /tmp/what_do_i_see: + title: Starbound Server should be running + exit-status: 0 + stdout: + - starbound_serve + +port: + tcp:21025: + title: Starbound Server should be accepting TCP connections on port 21025 + listening: true diff --git a/install.txt b/install.txt index 85729e9..db86968 100755 --- a/install.txt +++ b/install.txt @@ -2,5 +2,5 @@ login anonymous force_install_dir /steamcmd/starbound app_info_update 1 -app_update 211820 validate +app_update 533830 validate quit diff --git a/starbound_server.default.config b/starbound_server.default.config new file mode 100644 index 0000000..5cc9ac3 --- /dev/null +++ b/starbound_server.default.config @@ -0,0 +1,50 @@ +{ + "allowAdminCommands" : true, + "allowAdminCommandsFromAnyone" : false, + "allowAnonymousConnections" : true, + "allowAssetsMismatch" : true, + "anonymousConnectionsAreAdmin" : false, + "bannedIPs" : [], + "bannedUuids" : [], + "checkAssetsDigest" : false, + "clearPlayerFiles" : false, + "clearUniverseFiles" : false, + "clientIPJoinable" : false, + "clientP2PJoinable" : true, + "configurationVersion" : { + "basic" : 2, + "server" : 4 + }, + "crafting" : { + "filterHaveMaterials" : false + }, + "gameServerBind" : "0.0.0.0", + "gameServerPort" : 21025, + "interactiveHighlight" : true, + "inventory" : { + "pickupToActionBar" : true + }, + "maxPlayers" : 8, + "maxTeamSize" : 4, + "monochromeLighting" : false, + "playerBackupFileCount" : 3, + "queryServerBind" : "::", + "queryServerPort" : 21025, + "rconServerBind" : "::", + "rconServerPassword" : "", + "rconServerPort" : 21026, + "rconServerTimeout" : 1000, + "runQueryServer" : false, + "runRconServer" : false, + "safeScripts" : true, + "scriptInstructionLimit" : 10000000, + "scriptInstructionMeasureInterval" : 10000, + "scriptProfilingEnabled" : false, + "scriptRecursionLimit" : 100, + "serverFidelity" : "automatic", + "serverName" : "A Starbound Server", + "serverOverrideAssetsDigest" : null, + "serverUsers" : { + }, + "tutorialMessages" : true +} \ No newline at end of file diff --git a/start_starbound.sh b/start_starbound.sh index cff8502..44c0a54 100755 --- a/start_starbound.sh +++ b/start_starbound.sh @@ -3,8 +3,16 @@ # Define the exit handler exit_handler() { - echo "Shutdown signal received" + echo "" + echo "Waiting for server to shutdown.." + echo "" kill -SIGINT "$child" + sleep 5 + + echo "" + echo "Terminating.." + echo "" + exit } # Trap specific signals and forward to the exit handler @@ -17,7 +25,9 @@ if [ ! -d "/steamcmd/starbound/linux" ]; then fi # Install/update steamcmd +echo "" echo "Installing/updating steamcmd.." +echo "" curl -s http://media.steampowered.com/installer/steamcmd_linux.tar.gz | tar -v -C /steamcmd -zx # Check that username and password are both set @@ -34,7 +44,9 @@ if [ ! -f "/steamcmd/starbound/linux/starbound_server" ]; then exit 1 fi # Install Starbound from install.txt - echo "Installing/updating Starbound.." + echo "" + echo "Installing Starbound.." + echo "" bash /steamcmd/steamcmd.sh +runscript /install.txt else # Check that username and password are both set, otherwise skip update @@ -47,16 +59,29 @@ else fi else # Install Starbound from install.txt - echo "Installing Starbound.." + echo "" + echo "Updating Starbound.." + echo "" bash /steamcmd/steamcmd.sh +runscript /install.txt fi fi # Set the working directory -cd /steamcmd/starbound/linux +cd /steamcmd/starbound/linux || exit + +# Copy default configuration if necessary +if [ ! -f "/steamcmd/starbound/storage/starbound_server.config" ]; then + echo "" + echo "Copying default configuration.." + echo "" + mkdir -p /steamcmd/starbound/storage + cp -f /starbound_server.default.config /steamcmd/starbound/storage/starbound_server.config +fi # Run the server +echo "" echo "Starting Starbound.." +echo "" ./starbound_server 2>&1 & child=$!