Address Docker issues and remove need to extract cdclient.fdb (#895)

* Implement a server res directory

* Only convert if neither exist

* Remove unzip, Update RegEx

* readme updates

Run setup after setting working dir

Address several docker issues

Revert "Run setup after setting working dir"

This reverts commit fd2fb9228e82a350204c1ef61f7ba059479bb12f.

Fix docker

* Remove extra submodules

* Rework logic

* Switch if block

* Remove need to extract fdb from client

* Change log name

* Update FdbToSqlite.cpp
This commit is contained in:
David Markowitz
2023-01-06 21:04:20 -08:00
committed by GitHub
parent 7fcc8a6e84
commit bad3845d83
14 changed files with 109 additions and 243 deletions

View File

@@ -6,7 +6,7 @@ RUN --mount=type=cache,id=build-apt-cache,target=/var/cache/apt \
echo "Install build dependencies" && \
apt update && \
apt remove -y libmysqlcppconn7v5 libmysqlcppconn-dev && \
apt install cmake zlib1g zlib1g-dev unzip -yqq --no-install-recommends && \
apt install cmake zlib1g zlib1g-dev -yqq --no-install-recommends && \
rm -rf /var/lib/apt/lists/*
COPY dAuthServer/ /build/dAuthServer
@@ -35,12 +35,11 @@ ARG BUILD_VERSION=171022
RUN echo "Build server" && \
mkdir -p cmake_build && \
cd cmake_build && \
sed -i -e "s/171022/${BUILD_VERSION}/g" ../CMakeVariables.txt && \
sed -i -e "s/NET_VERSION=.*/NET_VERSION=${BUILD_VERSION}/g" ../CMakeVariables.txt && \
sed -i -e "s/__maria_db_connector_compile_jobs__=.*/__maria_db_connector_compile_jobs__=${BUILD_THREADS}/g" ../CMakeVariables.txt && \
cmake .. -DCMAKE_BUILD_RPATH_USE_ORIGIN=TRUE && \
make -j $BUILD_THREADS
RUN unzip /build/resources/navmeshes.zip -d /build/cmake_build/res/maps
FROM gcc:11 as runtime
RUN --mount=type=cache,id=runtime-apt-cache,target=/var/cache/apt \

View File

@@ -1,23 +1,12 @@
FROM rust:alpine3.14 as LUnpack
WORKDIR /build_LUnpack
COPY ./thirdparty/LUnpack .
RUN apk add musl-dev --no-cache && cargo build --release
FROM python:3.10-alpine3.14 as prep
RUN apk add sqlite bash --no-cache
RUN apk add bash --no-cache
WORKDIR /setup
# copy needed files from repo
COPY resources/ resources/
COPY migrations/cdserver/ migrations/cdserver
COPY --from=LUnpack /build_LUnpack/target/release/lunpack /usr/local/bin/lunpack
ADD thirdparty/docker-utils/utils/*.py utils/
COPY docker/setup.sh /setup.sh
CMD [ "/setup.sh" ]
CMD [ "/setup.sh" ]

View File

@@ -7,7 +7,7 @@ function update_ini() {
FILE="/docker/configs/$1"
KEY=$2
NEW_VALUE=$3
sed -i "/^$KEY=/s/=.*/=$NEW_VALUE/" $FILE
sed -i "s~$2=.*~$2=$3~" $FILE
}
function update_database_ini_values_for() {
@@ -32,62 +32,11 @@ function update_ini_values() {
cp resources/worldconfig.ini /docker/configs/
cp resources/sharedconfig.ini /docker/configs/
update_ini worldconfig.ini chat_server_port $CHAT_SERVER_PORT
update_ini worldconfig.ini max_clients $MAX_CLIENTS
# always use the internal docker hostname
update_ini masterconfig.ini master_ip "darkflame"
update_ini sharedconfig.ini client_location "/client"
update_database_ini_values_for sharedconfig.ini
}
function fdb_to_sqlite() {
echo "Run fdb_to_sqlite"
python3 utils/fdb_to_sqlite.py /client/client/res/cdclient.fdb --sqlite_path /client/client/res/CDServer.sqlite
(
cd migrations/cdserver
readarray -d '' entries < <(printf '%s\0' *.sql | sort -zV)
for entry in "${entries[@]}"; do
echo "Execute $entry"
sqlite3 /client/client/res/CDServer.sqlite < $entry
done
)
}
update_ini_values
if [[ ! -d "/client" ]]; then
echo "Client not found."
echo "Did you forget to mount the client into the \"/client\" directory?"
exit 1
fi
if [[ ! -f "/client/extracted" ]]; then
echo "Start client resource extraction"
touch globs.txt
echo "client/res/macros/**" >> globs.txt
echo "client/res/BrickModels/**" >> globs.txt
echo "client/res/maps/**" >> globs.txt
echo "*.fdb" >> globs.txt
lunpack -g ./globs.txt /client/
touch /client/extracted
else
echo "Client already extracted. Skip this step..."
echo "If you want to force a re-extract, just delete the file called \"extracted\" in the client directory"
fi
if [[ ! -f "/client/migrated" ]]; then
echo "Start client db migration"
fdb_to_sqlite
touch /client/migrated
else
echo "Client db already migrated. Skip this step..."
echo "If you want to force a re-migrate, just delete the file called \"migrated\" in the client directory"
fi

29
docker/start_server.sh Normal file → Executable file
View File

@@ -1,25 +1,5 @@
#!/bin/bash
function symlink_client_files() {
echo "Creating symlinks for client files"
ln -s /client/client/res/macros/ /app/res/macros
ln -s /client/client/res/BrickModels/ /app/res/BrickModels
ln -s /client/client/res/chatplus_en_us.txt /app/res/chatplus_en_us.txt
ln -s /client/client/res/names/ /app/res/names
ln -s /client/client/res/CDServer.sqlite /app/res/CDServer.sqlite
# need to create this file so the server knows the client is unpacked (see `dCommon/dClient/AssetManager.cpp`)
touch /app/res/cdclient.fdb
# need to iterate over entries in maps due to maps already being a directory with navmeshes/ in it
(
cd /client/client/res/maps
readarray -d '' entries < <(printf '%s\0' * | sort -zV)
for entry in "${entries[@]}"; do
ln -s /client/client/res/maps/$entry /app/res/maps/
done
)
}
function symlink_config_files() {
echo "Creating symlinks for config files"
rm /app/*.ini
@@ -30,15 +10,8 @@ function symlink_config_files() {
ln -s /shared_configs/configs/sharedconfig.ini /app/sharedconfig.ini
}
# check to make sure the setup has completed
while [ ! -f "/client/extracted" ] || [ ! -f "/client/migrated" ]; do
echo "Client setup not finished. Waiting for setup container to complete..."
sleep 5
done
if [[ ! -f "/app/initialized" ]]; then
# setup symlinks for volume files
symlink_client_files
symlink_config_files
# do not run symlinks more than once
touch /app/initialized
@@ -49,4 +22,4 @@ fi
# start the server
echo "Starting MasterServer"
./MasterServer
tail -f /dev/null
tail -f /dev/null