aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile84
-rw-r--r--README.docker.md62
-rw-r--r--s/icon32/dnf.pngbin0 -> 1405 bytes
3 files changed, 146 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..349f375
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,84 @@
+FROM debian:bullseye-slim
+
+RUN apt-get update \
+ && apt-get install -y apache2 perl build-essential \
+ libdbi-perl \
+ libdbd-sqlite3-perl \
+ libjson-perl \
+ libimage-size-perl \
+ libanyevent-perl \
+ libio-all-lwp-perl \
+ libfcgi-perl \
+ libgeography-countries-perl \
+ libapache2-mod-fcgid \
+ && cpan TUWF \
+ && cpan "LWP::Simple" \
+ && apt-get autoclean
+
+RUN a2enmod rewrite fcgid proxy_fcgi cgi
+
+COPY . /masterserver
+
+# Create Apache VirtualHost configuration on custom listen port
+RUN echo 'Listen 8080\n\
+ <VirtualHost *:8080>\n\
+ DocumentRoot "/masterserver/s"\n\
+ AddHandler cgi-script .pl\n\
+ \
+ RewriteEngine On\n\
+ RewriteCond "%{DOCUMENT_ROOT}/%{REQUEST_URI}" !-s\n\
+ RewriteRule ^/ /masterinterface.pl\n\
+ \
+ ErrorLog /masterserver/log/error.log\n\
+ CustomLog /masterserver/log/access.log combined\n\
+ \
+ <Directory "/masterserver/s">\n\
+ Options +FollowSymLinks +ExecCGI\n\
+ AllowOverride None\n\
+ Require all granted\n\
+ </Directory>\n\
+ </VirtualHost>' > /etc/apache2/sites-available/000-default.conf \
+ && echo "" > /etc/apache2/ports.conf
+
+# Create FastFGI configuration which works with our stand-alone Apache instance
+RUN echo '<IfModule mod_fcgid.c>\n\
+ FcgidIPCDir /run/mod_fcgid\n\
+ FcgidProcessTableFile /run/mod_fcgid/fcgid_shm\n\
+ FcgidMinProcessesPerClass 0\n\
+ FcgidMaxProcessesPerClass 8\n\
+ FcgidMaxProcesses 100\n\
+ FcgidConnectTimeout 20\n\
+ FcgidIdleTimeout 60\n\
+ FcgidProcessLifeTime 120\n\
+ FcgidIdleScanInterval 10\n\
+ \
+ <IfModule mod_mime.c>\n\
+ AddHandler fcgid-script .fcgi\n\
+ </IfModule>\n\
+ </IfModule>' > /etc/apache2/mods-enabled/fcgid.conf
+
+# Create a script which runns the IP to Country lookup in the background, and runs Apache in the foreground
+RUN echo '#!/bin/sh\n\
+ if [ ! $NO_IP_TO_COUNTRY ]; then\n\
+ echo "Running IP to Country lookup"\n\
+ cd /masterserver/util && ./listcountry.pl > /masterserver/log/listcountry.log &\n\
+ else\n\
+ echo "Not using IP to Country lookup"\n\
+ fi\n\
+ cd /masterserver && apache2 -DFOREGROUND' > /masterserver/launch.sh
+
+RUN mkdir -p /run/mod_fcgid \
+ && chown -R daemon:daemon /run/mod_fcgid /masterserver \
+ && chmod +x /masterserver/launch.sh
+
+USER daemon
+
+# Supply variables expected by Debian's Apache distribution
+ENV APACHE_RUN_USER=daemon\
+ APACHE_RUN_GROUP=daemon\
+ APACHE_RUN_DIR=/masterserver\
+ APACHE_PID_FILE=/masterserver/apache2.pid\
+ APACHE_LOG_DIR=/masterserver/log\
+ NO_IP_TO_COUNTRY=""
+
+CMD ["/masterserver/launch.sh"]
diff --git a/README.docker.md b/README.docker.md
new file mode 100644
index 0000000..ae5426b
--- /dev/null
+++ b/README.docker.md
@@ -0,0 +1,62 @@
+# Building and Running MasterServer Web UI in Docker
+
+Running the MasterServer Web UI in Docker may be useful on systems which don't
+have appropriate runtime environments available to run the web interface
+natively.
+
+## Build
+
+From the project root directory, run:
+
+```sh
+docker build -t 333masterserver-ui:latest .
+```
+
+This will build a Docker image containing all the required dependencies and
+configuration, named `333masterserver-ui`, tagged as `latest`.
+
+## Setup
+
+As with the stand-alone configuration described in [README.md](README.md), you
+need to also be running the MasterServer itself, since the Web UI shares access
+to the database.
+
+Importantly, the database must be readable _and writable_ by UID `1` (`daemon`)
+if the IP to Country lookup us used for displaying flags in the UI.
+
+The only other setup required is to customise `settings.pl` as desired.
+
+Specifically, `db_login` must be customised as follows:
+
+```perl
+db_login => ["dbi:SQLite:dbname=/masterserver/data/masterserver.db",'','']
+```
+
+## Run
+
+Once the image is build and configuration is in place, you can run the Web UI
+as follows.
+
+Note that the service listens on port `8080` internally, any host port can then
+be forwarded to this to expose it externally.
+
+```sh
+docker run --restart always --name masterserver-ui -d
+ -v /path/to/masterserver.db:/masterserver/data/masterserver.db
+ -v /path/to/settings.pl:/masterserver/data/settings.pl:ro
+ -p 8900:8080/tcp
+ 333masterserver-ui:latest
+```
+
+NOTE: If to disable the IP to Country lookup, pass set the `NO_IP_TO_COUNTRY`
+environment variable, which also allows read-only mounting of the database
+file, for example:
+
+```sh
+docker run --restart always --name masterserver-ui -d
+ -v /path/to/masterserver.db:/masterserver/data/masterserver.db:ro
+ -v /path/to/settings.pl:/masterserver/data/settings.pl:ro
+ -p 8900:8080/tcp
+ -e NO_IP_TO_COUNTRY=1
+ 333masterserver-ui:latest
+```
diff --git a/s/icon32/dnf.png b/s/icon32/dnf.png
new file mode 100644
index 0000000..114960e
--- /dev/null
+++ b/s/icon32/dnf.png
Binary files differ