Skip to content

Commit

Permalink
Added support for the postgresql backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
pickardjoe committed Jul 26, 2019
1 parent ab4be83 commit a9d6c18
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Dockerfile
Expand Up @@ -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"
Expand Down Expand Up @@ -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 \
Expand All @@ -51,6 +59,7 @@ RUN \
hiredis \
libgcc \
libintl \
libpq \
libstdc++ \
luajit \
lua-socket \
Expand Down Expand Up @@ -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 && \
Expand Down
16 changes: 16 additions & 0 deletions root/etc/cont-init.d/30-config
Expand Up @@ -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

0 comments on commit a9d6c18

Please sign in to comment.