diff --git a/Dockerfile b/Dockerfile index fd16251..4276d87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,14 @@ LABEL maintainer="sparklyballs" # environment variables ENV HOME="/config" \ -MINETEST_SUBGAME_PATH="/config/.minetest/games" +MINETEST_SUBGAME_PATH="/config/.minetest/games" \ +WORLD_NAME="world" \ +BACKEND="postgresql" \ +PG_HOST="" \ +PG_DB="minetest" \ +PG_USER="minetest" \ +PG_PASS="minetest" \ +PG_PORT=5432 # build variables ARG LDFLAGS="-lintl" @@ -39,6 +46,7 @@ RUN \ make \ mesa-dev \ openal-soft-dev \ + postgresql-dev \ python-dev \ sqlite-dev && \ apk add --no-cache --virtual=build-dependencies-2 \ @@ -51,6 +59,7 @@ RUN \ hiredis \ libgcc \ libintl \ + libpq \ libstdc++ \ luajit \ lua-socket \ @@ -96,6 +105,9 @@ RUN \ -DENABLE_REDIS=1 \ -DENABLE_SOUND=0 \ -DENABLE_SYSTEM_GMP=1 \ + -DENABLE_POSTGRESQL=1 \ + -DPOSTGRESQL_CONFIG_EXECUTABLE=/usr/bin/pg_config \ + -DPOSTGRESQL_LIBRARY=/usr/lib/libpq.so \ -DRUN_IN_PLACE=0 && \ make -j 2 && \ make install && \ diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config index bef8dab..2296e77 100644 --- a/root/etc/cont-init.d/30-config +++ b/root/etc/cont-init.d/30-config @@ -14,6 +14,22 @@ if [ ! -d "/config/.minetest/games/minimal" ]; then cp -pr /defaults/games/* /config/.minetest/games/ fi +# postgres +if [ "$BACKEND" = "postgresql" ] + then + WORLD_MT="/config/.minetest/worlds/$WORLD_NAME/world.mt" + if [ -f $WORLD_MT ] + then + TMP_WORLD_MT=$(mktemp) + egrep -v '^(backend|pgsql_connection)\s*=' $WORLD_MT > $TMP_WORLD_MT + echo -e "backend = $BACKEND\npgsql_connection = host=$PG_HOST port=$PG_PORT dbname=$PG_DB user=$PG_USER password=$PG_PASS" > $WORLD_MT + cat $TMP_WORLD_MT >> $WORLD_MT && rm $TMP_WORLD_MT + else + mkdir -p "/config/.minetest/worlds/$WORLD_NAME" + echo -e "gameid = minetest\nbackend = $BACKEND\npgsql_connection = host=$PG_HOST port=$PG_PORT dbname=$PG_DB user=$PG_USER password=$PG_PASS" >> $WORLD_MT + fi +fi + # permissions chown -R abc:abc \ /config