Skip to content

Commit 2b92564

Browse files
committed
refactor(build): Simplify Dockerfile and entrypoint.sh scripts for VNyanNet installation
Changes made in Dockerfile: - Removed winbind from dependencies - Added rsync to copy files into the correct directory Changes made in entrypoint.sh: - Simplified copying of files into the bin directory - Removed unnecessary mkdir commands for CONFIG_DIR - Changed the configuration file path to be within the bin directory These changes should help simplify the installation process, reducing potential errors and improving maintainability.
1 parent 705cc03 commit 2b92564

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV WINEDEBUG=-all
66
# Install required tools
77
RUN dpkg --add-architecture i386 && \
88
apt update && \
9-
apt install -y wget unzip xvfb wine64 wine32 winbind inotify-tools && \
9+
apt install -y wget unzip xvfb wine64 wine32 rsync winbind inotify-tools && \
1010
rm -rf /var/lib/apt/lists/*
1111

1212
WORKDIR /server

entrypoint.sh

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ set -euo pipefail
66
# -------------------------------------------------
77
SERVER_DIR="/server"
88
BIN_DIR="$SERVER_DIR/bin"
9-
CONFIG_DIR="$SERVER_DIR/config"
109

1110
EXE_FILE="$BIN_DIR/VNyanNet.exe"
12-
CONFIG_FILE="$CONFIG_DIR/VNyanNet.cfg"
11+
CONFIG_FILE="$BIN_DIR/VNyanNet.cfg"
1312
VERSION_FILE="$SERVER_DIR/VERSION.txt"
1413

1514
ZIP_FILE="$SERVER_DIR/VNyanNetServer.zip"
@@ -22,7 +21,7 @@ TMP_DIR="$SERVER_DIR/tmp_extract"
2221
: "${SERVER_PASSWORD:?SERVER_PASSWORD is required}"
2322
: "${MAX_LOBBY_AMOUNT:?MAX_LOBBY_AMOUNT is required}"
2423

25-
mkdir -p "$BIN_DIR" "$CONFIG_DIR"
24+
mkdir -p "$BIN_DIR"
2625

2726
# -------------------------------------------------
2827
# Read current version
@@ -44,10 +43,15 @@ if [[ "$CURRENT_VERSION" != "$VNYAN_VERSION" ]] || [[ ! -f "$EXE_FILE" ]]; then
4443
mkdir -p "$TMP_DIR"
4544
unzip -o "$ZIP_FILE" -d "$TMP_DIR"
4645

47-
echo "[VNyanNet] Installing binaries to /bin"
48-
rsync -av \
49-
--exclude='VNyanNet.cfg' \
50-
"$TMP_DIR"/ "$BIN_DIR"/
46+
echo "[VNyanNet] Installing binaries into /server/bin"
47+
48+
shopt -s dotglob
49+
for item in "$TMP_DIR"/*; do
50+
if [[ "$(basename "$item")" != "VNyanNet.cfg" ]]; then
51+
cp -a "$item" "$BIN_DIR/"
52+
fi
53+
done
54+
shopt -u dotglob
5155

5256
# Copy default config ONLY if missing
5357
if [[ ! -f "$CONFIG_FILE" ]] && [[ -f "$TMP_DIR/VNyanNet.cfg" ]]; then
@@ -69,14 +73,19 @@ if [[ ! -f "$CONFIG_FILE" ]]; then
6973
fi
7074

7175
# -------------------------------------------------
72-
# Apply ENV → config (ALWAYS)
76+
# Apply ENV → JSON config
7377
# -------------------------------------------------
7478
apply_env_to_config() {
7579
echo "[VNyanNet] Applying environment variables to config"
7680

77-
sed -i \
78-
-e "s/^ServerPassword=.*/ServerPassword=${SERVER_PASSWORD}/" \
79-
-e "s/^MaxLobbyAmount=.*/MaxLobbyAmount=${MAX_LOBBY_AMOUNT}/" \
81+
# ServerPassword
82+
sed -i -E \
83+
"s/(\"ServerPassword\"[[:space:]]*:[[:space:]]*\").*(\")/\1${SERVER_PASSWORD}\2/" \
84+
"$CONFIG_FILE"
85+
86+
# MaxLobbyAmount
87+
sed -i -E \
88+
"s/(\"MaxLobbyAmount\"[[:space:]]*:[[:space:]]*)[0-9]+/\1${MAX_LOBBY_AMOUNT}/" \
8089
"$CONFIG_FILE"
8190
}
8291

0 commit comments

Comments
 (0)