Initial commit

master
Pauli Jokela 2016-08-01 11:09:50 +03:00
commit e419cabe09
10 changed files with 211 additions and 0 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
.env
*.log
starbound_data
.DS_Store
docker_*.sh
.git/
.git*

42
.gitignore vendored Normal file
View File

@ -0,0 +1,42 @@
.env
starbound_data/
# Docker project generated files to ignore
# if you want to ignore files created by your editor/tools,
# please consider a global .gitignore https://help.github.com/articles/ignoring-files
*.exe
*.exe~
*.orig
*.rej
*.test
.*.swp
.DS_Store
.bashrc
.dotcloud
.flymake*
.git/
.gopath/
.hg/
.vagrant*
Vagrantfile
a.out
autogen/
bin
build_src
bundles/
docker/docker
dockerversion/version_autogen.go
docs/AWS_S3_BUCKET
docs/GITCOMMIT
docs/GIT_BRANCH
docs/VERSION
docs/_build
docs/_static
docs/_templates
docs/changed-files
# generated by man/md2man-all.sh
man/man1
man/man5
man/man8
pyenv
vendor/pkg/

55
Dockerfile Normal file
View File

@ -0,0 +1,55 @@
FROM ubuntu:16.04
MAINTAINER didstopia
# Setup the locales
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Fixes apt-get warnings
ENV DEBIAN_FRONTEND noninteractive
# 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
# Create and set the steamcmd folder as a volume
RUN mkdir -p /steamcmd/starbound
VOLUME ["/steamcmd/starbound"]
# Add the steamcmd installation script
ADD install.txt /install.txt
# Copy the startup script
ADD start_starbound.sh /start.sh
# Set the current working directory
WORKDIR /
# Expose necessary ports
EXPOSE 21025/tcp
# Setup default environment variables for the server
ENV STEAM_USERNAME ""
ENV STEAM_PASSWORD ""
# Cleanup
ENV DEBIAN_FRONTEND newt
# Start the server
ENTRYPOINT ["./start.sh"]

24
README.md Normal file
View File

@ -0,0 +1,24 @@
# Starbound server that runs inside a Docker container
**NOTE**: This image will install/update on startup. The path ```/steamcmd/starbound``` can be mounted on the host for data persistence.
# How to run the server
1. Set the environment variables you wish to modify from below (note the Steam credentials)
2. Optionally mount ```/steamcmd/starbound``` somewhere on the host or inside another container to keep your data safe
3. Enjoy!
*Be sure to edit `starbound_server.config` to further customize your installation.*
The following environment variables are available:
```
STEAM_USERNAME (DEFAULT: "" - Required for installing/updating Starbound)
STEAM_PASSWORD (DEFAULT: "" - Required for installing/updating Starbound)
```
# Updating the server
As long as you have both your `STEAM_USERNAME` and `STEAM_PASSWORD` set, simply restarting the container should trigger the update procedure.
# Anything else
If you need help, have questions or bug submissions, feel free to contact me **@Dids** on Twitter.

3
docker_build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker build -t didstopia/starbound-server:latest .

3
docker_build_force.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker build --no-cache -t didstopia/starbound-server:latest .

4
docker_push.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
docker tag didstopia/starbound-server:latest didstopia/starbound-server:latest
docker push didstopia/starbound-server:latest

8
docker_run.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
./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
docker logs -f starbound-server

6
install.txt Executable file
View File

@ -0,0 +1,6 @@
@sSteamCmdForcePlatformType linux
login anonymous
force_install_dir /steamcmd/starbound
app_info_update 1
app_update 211820 validate
quit

59
start_starbound.sh Executable file
View File

@ -0,0 +1,59 @@
#!/usr/bin/env bash
# Define the exit handler
exit_handler()
{
echo "Shutdown signal received"
kill -SIGINT "$child"
}
# Trap specific signals and forward to the exit handler
trap 'exit_handler' SIGHUP SIGINT SIGQUIT SIGTERM
# Create the necessary folder structure
if [ ! -d "/steamcmd/starbound/linux" ]; then
echo "Creating folder structure.."
mkdir -p /steamcmd/starbound/linux
fi
# Install/update steamcmd
echo "Installing/updating steamcmd.."
curl -s http://media.steampowered.com/installer/steamcmd_linux.tar.gz | tar -v -C /steamcmd -zx
# Check that username and password are both set
if [ ! -z "$STEAM_USERNAME" ] || [ ! -z "$STEAM_PASSWORD" ]; then
# Setup username/password for Steam
sed -i "s/login anonymous/login $STEAM_USERNAME $STEAM_PASSWORD/g" /install.txt
fi
# Check that Starbound exists in the first place
if [ ! -f "/steamcmd/starbound/linux/starbound_server" ]; then
# Check that username and password are both set, otherwise quit with error
if [ -z "$STEAM_USERNAME" ] || [ -z "$STEAM_PASSWORD" ]; then
echo "Error: you must set both your Steam username and password to install the server"
exit 1
fi
# Install Starbound from install.txt
echo "Installing/updating Starbound.."
bash /steamcmd/steamcmd.sh +runscript /install.txt
else
# Check that username and password are both set, otherwise skip update
if [ -z "$STEAM_USERNAME" ] || [ -z "$STEAM_PASSWORD" ]; then
echo "Steam username or password not set, skipping update.."
exit 1
else
# Install Starbound from install.txt
echo "Installing Starbound.."
bash /steamcmd/steamcmd.sh +runscript /install.txt
fi
fi
# Set the working directory
cd /steamcmd/starbound/linux
# Run the server
echo "Starting Starbound.."
./starbound_server 2>&1 &
child=$!
wait "$child"