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

Add dockerfile & docker-compose #49

Open
wants to merge 1 commit 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
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.6'

services:

spads:
image: spads
environment:
- "SPADS_LOBBY_LOGIN="
- "SPADS_LOBBY_PASSWORD="
- "SPADS_OWNER_LOBBY_LOGIN="
volumes:
- spads-config:/opt/spads/etc
- spads-data:/opt/spads/var
network_mode: host
restart: always

volumes:
spads-config: {}
spads-data: {}

38 changes: 38 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:rolling

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
curl \
perl \
swig \
g++ \
ca-certificates \
libcurl4 \
libsdl2-2.0-0 \
net-tools \
python \
python-pycurl \
&& apt-get autoremove \
&& rm -rf /var/run/apt \
&& useradd -m spads \
&& chown -R spads /opt


COPY scripts/*.sh /opt/
RUN mkdir -p /opt/spads \
&& cd /opt/spads \
&& curl -L -O http://planetspads.free.fr/spads/installer/spadsInstaller.tar \
&& tar -xvf spadsInstaller.tar \
&& chmod +x /opt/*.sh \
&& chown -R spads /opt/spads

USER spads
WORKDIR /opt/spads/

RUN /opt/install-spads.sh


ENTRYPOINT [ "/opt/spads-entrypoint.sh" ]
CMD [ "/opt/run-spads.sh" ]

47 changes: 47 additions & 0 deletions docker/scripts/install-spads.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# put build args in a file that will be fed to the installer which only accept values from STDIN

# Which SPADS release do you want to install (stable,testing,unstable,contrib) [testing]
# Please choose the directory where SPADS configuration files will be stored [etc]
# Please choose the directory where SPADS dynamic data will be stored [var] ?
# Please choose the directory where SPADS will write the logs [log] ?
# Do you want to use official Spring binary files (auto-managed by SPADS), or a custom Spring installation already existing on the system? (official,custom) [official] ?
# Which Spring version do you want to use (104.0,104.0.1-1463-g9b63660,stable,testing,unstable,...) [104.0]
#Please enter the absolute path of the Spring data directory containing the games and maps hosted by the autohost, or press enter to use a new directory instead [new] ?
# Which game do you want to download to initialize the autohost "games" directory (ba,bac,evo,jauria,metalfactions,nota,phoenix,s44,swiw,tard,tc,techa,xta,zk,none) [ba] ?
# Do you want to download a minimal set of 3 maps to initialize the autohost "maps" directory (yes,no) [yes] ?
#Which type of server do you want to use ("headless" requires much more CPU/memory and doesn't support "ghost maps", but it allows running AI bots and LUA scripts on server side)? (dedicated,headless) [dedicated] ?
#Do you want to enable new game auto-detection to always host the latest version of the game available in your "games" and "packages" folders? (yes,no) [yes] ?
# Please enter the autohost lobby login (the lobby account must already exist) ?
# Please enter the autohost lobby password ?
# Please enter the lobby login of the autohost owner ?

SPADS_RELEASE="${SPADS_RELEASE:-testing}"
SPADS_SPRING_FLAVOUR="${SPADS_SPRING_FLAVOUR:-official}"
SPADS_SPRING_VERSION="${SPADS_SPRING_VERSION:-maintenance}"

cat << EOF > /tmp/spads-installer-args
$SPADS_RELEASE
etc
var
log
$SPADS_SPRING_FLAVOUR
stable
new
none
no
dedicated
%SPADS_LOBBY_LOGIN%
%SPADS_LOBBY_PASSWORD%
%SPADS_OWNER_LOBBY_LOGIN%
EOF

perl ./spadsInstaller.pl < /tmp/spads-installer-args

# autoManagedSpringVersion supports maintenance, but not the installer
sed -i "s/^autoManagedSpringVersion.*/autoManagedSpringVersion:$SPADS_SPRING_VERSION/" etc/spads.conf




9 changes: 9 additions & 0 deletions docker/scripts/run-spads.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
pushd /opt/spads &>/dev/null
set -x
perl ./spads.pl etc/spads.conf \
"SPADS_LOBBY_LOGIN=$SPADS_LOBBY_LOGIN" \
"SPADS_LOBBY_PASSWORD=$SPADS_LOBBY_PASSWORD" \
"SPADS_OWNER_LOBBY_LOGIN=$SPADS_OWNER_LOBBY_LOGIN" \
$@
popd &>/dev/null
15 changes: 15 additions & 0 deletions docker/scripts/spads-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

SPADS_LOBBY_LOGIN="${SPADS_LOBBY_LOGIN:-}"
SPADS_LOBBY_PASSWORD="${SPADS_LOBBY_PASSWORD:-}"
SPADS_LOBBY_PASSWORD_FILE="${SPADS_LOBBY_PASSWORD_FILE:-}"
SPADS_OWNER_LOBBY_LOGIN="${SPADS_OWNER_LOBBY_LOGIN:-}"

[[ -z "$SPADS_LOBBY_PASSWORD" && -f "$SPADS_LOBBY_PASSWORD_FILE" ]] && SPADS_LOBBY_PASSWORD="$(head -n 1 $SPADS_LOBBY_PASSWORD_FILE)"

[ -z "$SPADS_LOBBY_LOGIN" ] && echo "WARN: SPADS_LOBBY_LOGIN missing"
[ -z "$SPADS_LOBBY_PASSWORD" ] && echo "WARN: SPADS_LOBBY_PÄSSWORD missing"
[ -z "$SPADS_OWNER_LOBBY_LOGIN" ] && echo "WARN: SPADS_OWNER_LOBBY_LOGIN missing"

exec $@