push multi version for wow server

This commit is contained in:
2025-08-30 17:59:56 +02:00
parent ca8eb8b36e
commit ac84a68f69
28 changed files with 1066 additions and 4236 deletions
+223
View File
@@ -0,0 +1,223 @@
FROM ubuntu:24.04 AS builder
ENV DEBIAN_FRONTEND="noninteractive"
ARG TIMEZONE="Etc/UTC"
ENV TZ="${TIMEZONE}"
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
\
apt-get update \
&& apt-get install -y --no-install-recommends \
tzdata \
&& ln -snf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime \
&& echo "${TIMEZONE}" > /etc/timezone \
&& dpkg-reconfigure --frontend noninteractive tzdata \
\
&& apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
g++-14 \
git-core \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-regex-dev \
libboost-serialization-dev \
libboost-system-dev \
libboost-thread-dev \
libmariadb-dev-compat \
libssl-dev \
mariadb-client \
\
&& update-alternatives --install /usr/bin/gcc gcc \
/usr/bin/gcc-14 14 \
--slave /usr/bin/g++ g++ \
/usr/bin/g++-14 \
\
&& rm -rf /tmp/*
ARG EXPANSION
ARG MANGOS_SHA1="latest"
ARG DATABASE_SHA1="latest"
ENV HOME_DIR="/home/mangos"
ENV MANGOS_DIR="${HOME_DIR}/mangos"
ENV DATABASE_DIR="${HOME_DIR}/${EXPANSION}-db"
RUN mkdir -p "${MANGOS_DIR}" \
"${DATABASE_DIR}" \
\
&& cd /tmp \
&& if [ "${MANGOS_SHA1}" = "latest" ]; \
then \
git clone "https://github.com/cmangos/mangos-${EXPANSION}.git" \
--branch "master" \
--single-branch \
--depth 1 \
"${MANGOS_DIR}"; \
else \
git clone "https://github.com/cmangos/mangos-${EXPANSION}.git" \
--branch "master" \
--single-branch \
cmangos-mangos \
&& cd cmangos-mangos \
&& git archive "${MANGOS_SHA1}" | tar xC "${MANGOS_DIR}"; \
fi \
\
&& cd /tmp \
&& if [ "${DATABASE_SHA1}" = "latest" ]; \
then \
git clone "https://github.com/cmangos/${EXPANSION}-db.git" \
--branch "master" \
--single-branch \
--depth 1 \
"${DATABASE_DIR}"; \
else \
git clone "https://github.com/cmangos/${EXPANSION}-db.git" \
--branch "master" \
--single-branch \
cmangos-db \
&& cd cmangos-db \
&& git archive "${DATABASE_SHA1}" | tar xC "${DATABASE_DIR}"; \
fi \
\
&& rm -rf /tmp/*
# TODO: Add here as building arguments all `cmake` parameters.
# - CMAKE_INSTALL_PREFIX Path where the server should be installed to
# - PCH Use precompiled headers
# - DEBUG Include additional debug-code in core
# - WARNINGS Show all warnings during compile
# - POSTGRESQL Use PostgreSQL instead of mysql
# - BUILD_EXTRACTORS Build map/dbc/vmap/mmap extractor
# - BUILD_SCRIPTDEV Build scriptdev. (Disable it to speedup build in dev mode by not including scripts)
# - BUILD_PLAYERBOTS Build Playerbot mod
# - BUILD_AHBOT Build Auction House Bot mod
# - BUILD_METRICS Build Metrics, generate data for Grafana
# - BUILD_RECASTDEMOMOD Build map/vmap/mmap viewer
# - BUILD_GIT_ID Build git_id
# - BUILD_DOCS Build documentation with doxygen
#
ARG THREADS="1"
RUN mkdir -p "${HOME_DIR}/build" \
"${HOME_DIR}/run" \
\
&& cd "${HOME_DIR}/build" \
&& cmake ../mangos/ \
-D CMAKE_INSTALL_PREFIX=../run \
-D PCH=1 \
-D DEBUG=0 \
-D BUILD_EXTRACTORS=ON \
&& make -j "${THREADS}" \
&& make install \
\
&& cd "${HOME_DIR}/run/bin/tools" \
&& chmod +x ExtractResources.sh \
MoveMapGen.sh
RUN useradd --comment "MaNGOS" \
--home "${HOME_DIR}" \
--user-group mangos
WORKDIR "${HOME_DIR}"
ENV MYSQL_SUPERUSER="root"
ENV MYSQL_SUPERPASS=""
ENV MANGOS_DBHOST="host.docker.internal"
ENV MANGOS_DBPORT="3306"
ENV MANGOS_DBUSER="mangos"
ENV MANGOS_DBPASS=""
ENV MANGOS_WORLD_DBNAME="${EXPANSION}mangos"
ENV MANGOS_CHARACTERS_DBNAME="${EXPANSION}characters"
ENV MANGOS_LOGS_DBNAME="${EXPANSION}logs"
ENV MANGOS_REALMD_DBNAME="${EXPANSION}realmd"
COPY builder/entrypoint.sh /
COPY builder/InstallFullDB.config "${DATABASE_DIR}/"
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]
ENV VOLUME_DIR="/home/mangos/data"
ENV TMPDIR="${VOLUME_DIR}/tmp"
VOLUME ["${VOLUME_DIR}"]
FROM ubuntu:24.04 AS runner
ENV DEBIAN_FRONTEND="noninteractive"
ARG TIMEZONE="Etc/UTC"
ENV TZ="${TIMEZONE}"
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
\
apt-get update \
&& apt-get install -y --no-install-recommends \
tzdata \
&& ln -snf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime \
&& echo "${TIMEZONE}" > /etc/timezone \
&& dpkg-reconfigure --frontend noninteractive tzdata \
\
&& apt-get install -y --no-install-recommends \
gosu \
libmariadb-dev \
libssl3 \
wait-for-it \
\
&& rm -rf /tmp/*
ENV HOME_DIR="/home/mangos"
ENV MANGOS_DIR="/opt/mangos"
RUN useradd --home "${HOME_DIR}" --create-home \
--comment "MaNGOS" \
--user-group mangos
WORKDIR "${MANGOS_DIR}"
ARG EXPANSION
COPY --from=builder "${HOME_DIR}/run" "${MANGOS_DIR}"
COPY runner/entrypoint.sh /
ENV VOLUME_DIR="/var/lib/mangos"
ENV TMPDIR="${VOLUME_DIR}/tmp"
RUN mkdir "${VOLUME_DIR}" \
&& sed -i '/^DataDir/c\DataDir = "'"${VOLUME_DIR}"'"' etc/mangosd.conf.dist
ENV MANGOS_DBHOST="host.docker.internal"
ENV MANGOS_DBPORT="3306"
ENV MANGOS_DBUSER="mangos"
ENV MANGOS_DBPASS=""
ENV MANGOS_WORLD_DBNAME="${EXPANSION}mangos"
ENV MANGOS_CHARACTERS_DBNAME="${EXPANSION}characters"
ENV MANGOS_LOGS_DBNAME="${EXPANSION}logs"
ENV MANGOS_REALMD_DBNAME="${EXPANSION}realmd"
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]
EXPOSE 3443 3724 7878 8085 8086
VOLUME ["${VOLUME_DIR}"]
ARG COMMIT_SHA
ARG CREATE_DATE
ARG VERSION
LABEL org.opencontainers.image.title="CMaNGOS Runner \"${EXPANSION}\" version"
LABEL org.opencontainers.image.description="A CMaNGOS \"${EXPANSION}\" version Docker image ready-to-use to host your emulated private server for WoW wherever you want."
LABEL org.opencontainers.image.licenses="GPL-2.0"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.revision="${COMMIT_SHA}"
LABEL org.opencontainers.image.created="${CREATE_DATE}"
ARG MANGOS_SHA1
LABEL "net.cmangos.mangos-${EXPANSION}.revision"="${MANGOS_SHA1}"
LABEL "net.cmangos.mangos-${EXPANSION}.source"="https://github.com/cmangos/mangos-${EXPANSION}"
LABEL "net.cmangos.mangos-${EXPANSION}.url"="https://github.com/cmangos/mangos-${EXPANSION}"
ARG DATABASE_SHA1
LABEL "net.cmangos.${EXPANSION}-db.revision"="${DATABASE_SHA1}"
LABEL "net.cmangos.${EXPANSION}-db.source"="https://github.com/cmangos/${EXPANSION}-db"
LABEL "net.cmangos.${EXPANSION}-db.url"="https://github.com/cmangos/${EXPANSION}-db"
-85
View File
@@ -1,85 +0,0 @@
ARG DEBIAN_FRONTEND=noninteractive
ARG VMANGOS_REPOSITORY_URL=https://github.com/vmangos/core.git
ARG VMANGOS_REVISION=development
ARG VMANGOS_WORLD_DB_REPOSITORY_URL=https://github.com/brotalnia/database.git
ARG VMANGOS_WORLD_DB_DUMP_NAME=world_full_14_june_2021
ARG VMANGOS_WORLD_DB_DUMP_NEW_FILE=/sql/world-new.sql
FROM mariadb:11.8 AS setup
ARG DEBIAN_FRONTEND
ARG VMANGOS_REPOSITORY_URL
ARG VMANGOS_REVISION
ARG VMANGOS_WORLD_DB_REPOSITORY_URL
ARG VMANGOS_WORLD_DB_DUMP_NAME
RUN \
apt update -y && \
apt install -y \
git \
p7zip-full && \
git clone "${VMANGOS_REPOSITORY_URL}" /core && \
cd /core && \
git checkout "${VMANGOS_REVISION}" && \
git clone "${VMANGOS_WORLD_DB_REPOSITORY_URL}" /database && \
mkdir -p /sql/custom && \
mkdir -p /sql/migrations && \
cd /core/sql && \
mv characters.sql /sql && \
mv logon.sql /sql && \
mv logs.sql /sql && \
cd /core/sql/migrations && \
chmod +x merge.sh && \
./merge.sh && \
mv characters_db_updates.sql /sql/migrations && \
mv logon_db_updates.sql /sql/migrations && \
mv logs_db_updates.sql /sql/migrations && \
mv world_db_updates.sql /sql/migrations && \
cd /database && \
7z e ${VMANGOS_WORLD_DB_DUMP_NAME}.7z && \
mv ${VMANGOS_WORLD_DB_DUMP_NAME}.sql /sql/world.sql && \
rm -rf /core /database && \
apt remove -y \
git \
p7zip-full && \
apt autoremove -y && \
apt clean -y && \
rm -rf /var/lib/apt/lists/*
FROM mariadb:11.8
ARG VMANGOS_WORLD_DB_DUMP_NEW_FILE
ENV MARIADB_AUTO_UPGRADE=1
ENV MARIADB_USER=mangos
ENV MARIADB_PASSWORD=mangos
ENV MARIADB_ROOT_PASSWORD=password
ENV VMANGOS_REALMLIST_NAME=VMaNGOS
ENV VMANGOS_REALMLIST_ADDRESS=127.0.0.1
ENV VMANGOS_REALMLIST_PORT=8085
ENV VMANGOS_REALMLIST_ICON=1
ENV VMANGOS_REALMLIST_TIMEZONE=0
ENV VMANGOS_REALMLIST_ALLOWED_SECURITY_LEVEL=0
ENV VMANGOS_WORLD_DB_DUMP_NEW_FILE=${VMANGOS_WORLD_DB_DUMP_NEW_FILE}
ENV VMANGOS_ENABLE_AUTOMATIC_WORLD_DB_CORRECTIONS=1
ENV VMANGOS_PROCESS_CUSTOM_SQL=1
COPY --from=setup /sql /sql
RUN \
mkdir -p /opt/scripts && \
mkdir /always-initdb.d
COPY ./docker/database/db-functions.sh /opt/scripts
COPY ./docker/database/create-db.sh /docker-entrypoint-initdb.d
COPY ./docker/database/update-db.sh /always-initdb.d
COPY ./docker/database/docker-entrypoint.sh /entrypoint.sh
RUN \
chmod +x /docker-entrypoint-initdb.d/create-db.sh && \
chmod +x /always-initdb.d/update-db.sh && \
chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["mariadbd"]
-41
View File
@@ -1,41 +0,0 @@
#!/usr/bin/env bash
. "/opt/scripts/db-functions.sh"
if [ "${VMANGOS_ENABLE_AUTOMATIC_WORLD_DB_CORRECTIONS:-0}" = "1" ]; then
echo "[vmangos-deploy]: [x] Automatic world database corrections are enabled"
else
echo "[vmangos-deploy]: [ ] Automatic world database corrections are disabled"
fi
if [ "${VMANGOS_PROCESS_CUSTOM_SQL:-0}" = "1" ]; then
echo "[vmangos-deploy]: [x] Custom SQL processing is enabled"
else
echo "[vmangos-deploy]: [ ] Custom SQL processing is disabled"
fi
create_database "mangos"
create_database "characters"
create_database "realmd"
create_database "logs"
grant_permissions "mangos"
grant_permissions "characters"
grant_permissions "realmd"
grant_permissions "logs"
import_dump "mangos" "/sql/world.sql"
import_dump "characters" "/sql/characters.sql"
import_dump "realmd" "/sql/logon.sql"
import_dump "logs" "/sql/logs.sql"
import_updates "mangos" "/sql/migrations/world_db_updates.sql"
import_updates "characters" "/sql/migrations/characters_db_updates.sql"
import_updates "realmd" "/sql/migrations/logon_db_updates.sql"
import_updates "logs" "/sql/migrations/logs_db_updates.sql"
configure_realm
if [ "${VMANGOS_PROCESS_CUSTOM_SQL:-0}" = "1" ]; then
process_custom_sql "/sql/custom"
fi
-172
View File
@@ -1,172 +0,0 @@
#!/usr/bin/env bash
create_database() {
local db_name="$1"
local silent=${2:-false}
if [ "$silent" = false ]; then
echo "[vmangos-deploy]: Creating database '$db_name'"
fi
mariadb -u root -p"$MARIADB_ROOT_PASSWORD" -e \
"CREATE DATABASE IF NOT EXISTS \`$db_name\` DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
}
drop_database() {
local db_name="$1"
local silent=${2:-false}
if [ "$silent" = false ]; then
echo "[vmangos-deploy]: Dropping database '$db_name'"
fi
mariadb -u root -p"$MARIADB_ROOT_PASSWORD" -e \
"DROP DATABASE IF EXISTS \`$db_name\`;"
}
grant_permissions() {
local db_name="$1"
local silent=${2:-false}
if [ "$silent" = false ]; then
echo "[vmangos-deploy]: Granting permissions to database user '$MARIADB_USER' for database '$db_name'"
fi
mariadb -u root -p"$MARIADB_ROOT_PASSWORD" -e \
"GRANT ALL ON \`$db_name\`.* TO '$MARIADB_USER'@'%'; \
FLUSH PRIVILEGES;"
}
import_data() {
local db_name="$1"
local file="$2"
mariadb -u root -p"$MARIADB_ROOT_PASSWORD" "$db_name" < "$file"
return $?
}
import_dump() {
local db_name="$1"
local dump_file="$2"
echo "[vmangos-deploy]: Importing initial data for database '$db_name'"
import_data "$db_name" "$dump_file"
return $?
}
import_updates() {
local db_name="$1"
local update_file="$2"
if [ ! -e "$update_file" ]; then
# The update file not existing is not an error, so we return 0 (success)
# here
return 0
fi
echo "[vmangos-deploy]: Importing potential updates for database '$db_name'"
import_data "$db_name" "$update_file"
return $?
}
configure_realm() {
echo "[vmangos-deploy]: Configuring realm '$VMANGOS_REALMLIST_NAME'"
mariadb -u root -p"$MARIADB_ROOT_PASSWORD" "realmd" -e \
"INSERT INTO \`realmlist\` (\`name\`, \`address\`, \`port\`, \`icon\`, \`timezone\`, \`allowedSecurityLevel\`) VALUES ('$VMANGOS_REALMLIST_NAME', '$VMANGOS_REALMLIST_ADDRESS', '$VMANGOS_REALMLIST_PORT', '$VMANGOS_REALMLIST_ICON', '$VMANGOS_REALMLIST_TIMEZONE', '$VMANGOS_REALMLIST_ALLOWED_SECURITY_LEVEL');"
}
create_world_db_corrections_table() {
mariadb -u root -p"$MARIADB_ROOT_PASSWORD" "maintenance" -e \
"CREATE TABLE IF NOT EXISTS \`world_db_corrections\` ( \
\`id\` INT NOT NULL, \
\`reason\` VARCHAR(255) NOT NULL, \
\`date\` DATE NOT NULL, \
\`is_applied\` BOOLEAN NOT NULL DEFAULT FALSE, \
PRIMARY KEY (\`id\`) \
);"
}
populate_world_db_corrections_table() {
mariadb -u root -p"$MARIADB_ROOT_PASSWORD" "maintenance" -e \
"INSERT INTO \`world_db_corrections\` (\`id\`, \`reason\`, \`date\`) \
SELECT 1, 'migration edits in vmangos/core@fe6fcb4', '2025-02-22' \
WHERE NOT EXISTS ( \
SELECT 1 FROM \`world_db_corrections\` WHERE \`id\` = 1 \
); \
INSERT INTO \`world_db_corrections\` (\`id\`, \`reason\`, \`date\`) \
SELECT 2, 'migration edits in vmangos/core@9e6d4ac', '2025-02-23' \
WHERE NOT EXISTS ( \
SELECT 2 FROM \`world_db_corrections\` WHERE \`id\` = 2 \
); \
INSERT INTO \`world_db_corrections\` (\`id\`, \`reason\`, \`date\`) \
SELECT 3, 'migration edits in vmangos/core@07c7832', '2025-02-25' \
WHERE NOT EXISTS ( \
SELECT 3 FROM \`world_db_corrections\` WHERE \`id\` = 3 \
); \
INSERT INTO \`world_db_corrections\` (\`id\`, \`reason\`, \`date\`) \
SELECT 4, 'migration edits in vmangos/core@f485dfa', '2025-03-22' \
WHERE NOT EXISTS ( \
SELECT 4 FROM \`world_db_corrections\` WHERE \`id\` = 4 \
); \
INSERT INTO \`world_db_corrections\` (\`id\`, \`reason\`, \`date\`) \
SELECT 5, 'migration edits in vmangos/core@33fcf97', '2025-07-05' \
WHERE NOT EXISTS ( \
SELECT 5 FROM \`world_db_corrections\` WHERE \`id\` = 5 \
);"
}
check_if_world_db_correction_is_required() {
local result=$(mariadb -u root -p"$MARIADB_ROOT_PASSWORD" "maintenance" -N -s -e \
"WITH
db_creation AS (
SELECT DATE(CONVERT_TZ(MIN(\`CREATE_TIME\`), @@session.time_zone, '+00:00')) as world_db_created_at
FROM \`INFORMATION_SCHEMA\`.\`TABLES\`
WHERE \`TABLE_SCHEMA\` = 'mangos'
),
latest_correction AS (
SELECT DATE(\`date\`) as correction_date, \`reason\`, \`is_applied\`
FROM \`world_db_corrections\`
WHERE \`id\` = (SELECT MAX(\`id\`) FROM \`world_db_corrections\`)
)
SELECT CONCAT_WS('|',
IF(
NOT \`is_applied\` AND correction_date >= world_db_created_at,
'true',
'false'
),
\`reason\`
)
FROM latest_correction, db_creation;")
echo "$result"
}
mark_world_db_corrections_as_applied() {
mariadb -u root -p"$MARIADB_ROOT_PASSWORD" "maintenance" -e \
"UPDATE \`world_db_corrections\` SET \`is_applied\` = true;"
}
process_custom_sql() {
local file_directory="$1"
if [ ! -d "$file_directory" ]; then
echo "[vmangos-deploy]: WARNING: Custom SQL file directory '$file_directory' does not exist" >&2
return 0
fi
file_count=$(find "$file_directory" -name "*.sql" -type f | wc -l)
echo "[vmangos-deploy]: Found $file_count custom SQL file(s) to process"
if [ "$file_count" -gt 0 ]; then
find "$file_directory" -name "*.sql" -type f | sort | while read -r sql_file; do
echo "[vmangos-deploy]: Processing custom SQL file '$(basename "$sql_file")'"
import_data "mangos" "$sql_file"
if [ $? -ne 0 ]; then
echo "[vmangos-deploy]: ERROR: Failed to process custom SQL file '$(basename "$sql_file")'" >&2
fi
done
fi
}
-100
View File
@@ -1,100 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
source "$(which docker-entrypoint.sh)"
docker_mariadb_upgrade_including_user_tables() {
if [ -z "$MARIADB_AUTO_UPGRADE" ] \
|| [ "$MARIADB_AUTO_UPGRADE" = 0 ]; then
mysql_note "MariaDB upgrade (mariadb-upgrade or creating healthcheck users) required, but skipped due to \$MARIADB_AUTO_UPGRADE setting"
return
fi
mysql_note "Starting temporary server"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0
mysql_note "Temporary server started."
docker_mariadb_backup_system
if [ ! -f "$DATADIR"/.my-healthcheck.cnf ]; then
mysql_note "Creating healthcheck users"
local createHealthCheckUsers
createHealthCheckUsers=$(create_healthcheck_users)
docker_process_sql --dont-use-mysql-root-password --binary-mode <<-EOSQL
-- Healthcheck users shouldn't be replicated
SET @@SESSION.SQL_LOG_BIN=0;
-- we need the SQL_MODE NO_BACKSLASH_ESCAPES mode to be clear for the password to be set
SET @@SESSION.SQL_MODE=REPLACE(@@SESSION.SQL_MODE, 'NO_BACKSLASH_ESCAPES', '');
FLUSH PRIVILEGES;
$createHealthCheckUsers
EOSQL
mysql_note "Stopping temporary server"
docker_temp_server_stop
mysql_note "Temporary server stopped"
if _check_if_upgrade_is_needed; then
# need a restart as FLUSH PRIVILEGES isn't reversable
mysql_note "Restarting temporary server for upgrade"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0
else
return 0
fi
fi
mysql_note "Starting mariadb-upgrade"
mariadb-upgrade
mysql_note "Finished mariadb-upgrade"
mysql_note "Stopping temporary server"
docker_temp_server_stop
mysql_note "Temporary server stopped"
}
mysql_note "Custom entrypoint script for MariaDB Server ${MARIADB_VERSION} started."
mysql_check_config "$@"
# Load various environment variables
docker_setup_env "$@"
docker_create_db_directories
# If container is started as root user, restart as dedicated mysql user
if [ "$(id -u)" = "0" ]; then
mysql_note "Switching to dedicated user 'mysql'"
exec gosu mysql "${BASH_SOURCE[0]}" "$@"
fi
# there's no database, so it needs to be initialized
if [ -z "$DATABASE_ALREADY_EXISTS" ]; then
docker_verify_minimum_env
docker_mariadb_init "$@"
# run always-run hooks if they exist
elif test -n "$(shopt -s nullglob; echo /always-initdb.d/*)"; then
# MDEV-27636 mariadb_upgrade --check-if-upgrade-is-needed cannot be run offline
#if mariadb-upgrade --check-if-upgrade-is-needed; then
if _check_if_upgrade_is_needed; then
docker_mariadb_upgrade_including_user_tables "$@"
fi
mysql_note "Starting temporary server"
docker_temp_server_start "$@"
mysql_note "Temporary server started."
docker_process_init_files /always-initdb.d/*
mysql_note "Stopping temporary server"
docker_temp_server_stop
mysql_note "Temporary server stopped"
echo
mysql_note "MariaDB init process done. Ready for start up."
echo
# MDEV-27636 mariadb_upgrade --check-if-upgrade-is-needed cannot be run offline
#elif mariadb-upgrade --check-if-upgrade-is-needed; then
elif _check_if_upgrade_is_needed; then
docker_mariadb_upgrade_including_user_tables "$@"
fi
exec "$@"
-74
View File
@@ -1,74 +0,0 @@
#!/usr/bin/env bash
# vmangos-deploy
# Copyright (C) 2023-2025 Michael Serajnik https://github.com/mserajnik
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "/opt/scripts/db-functions.sh"
if [ "${VMANGOS_ENABLE_AUTOMATIC_WORLD_DB_CORRECTIONS:-0}" = "1" ]; then
echo "[vmangos-deploy]: [x] Automatic world database corrections are enabled"
else
echo "[vmangos-deploy]: [ ] Automatic world database corrections are disabled"
fi
if [ "${VMANGOS_PROCESS_CUSTOM_SQL:-0}" = "1" ]; then
echo "[vmangos-deploy]: [x] Custom SQL processing is enabled"
else
echo "[vmangos-deploy]: [ ] Custom SQL processing is disabled"
fi
if [ "${VMANGOS_ENABLE_AUTOMATIC_WORLD_DB_CORRECTIONS:-0}" = "1" ]; then
create_database "maintenance" true
grant_permissions "maintenance" true
create_world_db_corrections_table
populate_world_db_corrections_table
result=$(check_if_world_db_correction_is_required)
requires_correction=$(echo "$result" | cut -d'|' -f1)
reason=$(echo "$result" | cut -d'|' -f2)
if [ "$requires_correction" = "true" ]; then
echo "[vmangos-deploy]: World database correction required because of $reason, re-creating world database"
drop_database "mangos"
create_database "mangos"
grant_permissions "mangos"
import_dump "mangos" "/sql/world.sql"
mark_world_db_corrections_as_applied
fi
else
echo "[vmangos-deploy]: Automatic world database corrections are disabled"
drop_database "maintenance" true
fi
if [ -e "$VMANGOS_WORLD_DB_DUMP_NEW_FILE" ]; then
echo "[vmangos-deploy]: '$VMANGOS_WORLD_DB_DUMP_NEW_FILE' exists, re-creating world database"
drop_database "mangos"
create_database "mangos"
grant_permissions "mangos"
import_dump "mangos" "$VMANGOS_WORLD_DB_DUMP_NEW_FILE"
fi
import_updates "mangos" "/sql/migrations/world_db_updates.sql"
import_updates "characters" "/sql/migrations/characters_db_updates.sql"
import_updates "realmd" "/sql/migrations/logon_db_updates.sql"
import_updates "logs" "/sql/migrations/logs_db_updates.sql"
if [ "${VMANGOS_PROCESS_CUSTOM_SQL:-0}" = "1" ]; then
process_custom_sql "/sql/custom"
fi
+130
View File
@@ -0,0 +1,130 @@
#!/usr/bin/env bash
#
set -e
# Utils:
#
function _replace_conf()
{
local SEARCH_FOR="${1}"
local REPLACE_WITH="${2}"
local FILENAME="${3}"
sed -i "/^${SEARCH_FOR}/c\\${SEARCH_FOR} = ${REPLACE_WITH}" "${FILENAME}"
}
function _merge_confs()
{
local FILENAME="${1}"
local CONFIG_FILE="${2}"
while IFS='' read -r LINE || [[ -n "${LINE}" ]]
do
PROPERTY="$(echo "${LINE}" | cut -d '#' -f 1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
if [[ -n "${PROPERTY}" ]]
then
local SEARCH_FOR="$(echo "${PROPERTY}" | cut -d '=' -f 1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
local REPLACE_WITH="$(echo "${PROPERTY}" | cut -d '=' -f 2- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
_replace_conf "${SEARCH_FOR}" "${REPLACE_WITH}" "${FILENAME}"
fi
done < "${CONFIG_FILE}"
}
# Sub-functions:
#
function compose_mangosd_conf()
{
local MANGOS_DBCONN="${MANGOS_DBHOST};${MANGOS_DBPORT};${MANGOS_DBUSER};${MANGOS_DBPASS}"
cd "${MANGOS_DIR}/etc"
cp mangosd.conf.dist mangosd.conf
_replace_conf "LoginDatabaseInfo" "\"${MANGOS_DBCONN};${MANGOS_REALMD_DBNAME}\"" mangosd.conf
_replace_conf "WorldDatabaseInfo" "\"${MANGOS_DBCONN};${MANGOS_WORLD_DBNAME}\"" mangosd.conf
_replace_conf "CharacterDatabaseInfo" "\"${MANGOS_DBCONN};${MANGOS_CHARACTERS_DBNAME}\"" mangosd.conf
_replace_conf "LogsDatabaseInfo" "\"${MANGOS_DBCONN};${MANGOS_LOGS_DBNAME}\"" mangosd.conf
if [[ -f "/opt/mangos/conf/mangosd.conf" ]]
then
_merge_confs mangosd.conf "/opt/mangos/conf/mangosd.conf"
fi
}
function compose_realmd_conf()
{
local MANGOS_DBCONN="${MANGOS_DBHOST};${MANGOS_DBPORT};${MANGOS_DBUSER};${MANGOS_DBPASS}"
cd "${MANGOS_DIR}/etc"
cp realmd.conf.dist realmd.conf
_replace_conf "LoginDatabaseInfo" "\"${MANGOS_DBCONN};${MANGOS_REALMD_DBNAME}\"" realmd.conf
if [[ -f "/opt/mangos/conf/realmd.conf" ]]
then
_merge_confs realmd.conf "/opt/mangos/conf/realmd.conf"
fi
}
function set_timezone()
{
ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime
echo "${TZ}" > /etc/timezone
dpkg-reconfigure --frontend noninteractive tzdata &> /dev/null
}
function wait_for_database()
{
wait-for-it -h "${MANGOS_DBHOST}" -p "${MANGOS_DBPORT}"
}
# Main functions:
#
function init_runner()
{
set_timezone
compose_mangosd_conf
compose_realmd_conf
}
function run_mangosd()
{
cd "${MANGOS_DIR}/bin"
gosu mangos ./mangosd
}
function run_realmd()
{
cd "${MANGOS_DIR}/bin"
gosu mangos ./realmd
}
# Execution:
#
init_runner
case "${1}" in
mangosd)
shift
wait_for_database
run_mangosd ${@}
;;
realmd)
shift
wait_for_database
run_realmd ${@}
;;
*)
cd "${HOME_DIR}"
exec ${@}
;;
esac
exit 1
Executable
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
#
set -e
readonly BASE_DIR="$(realpath "$(dirname "${0}")/..")"
source "${BASE_DIR}/.env"
readonly NAME="cmangos-runner"
readonly IMAGE="ghcr.io/byloth/cmangos/${WOW_VERSION}"
readonly VERSION="latest"
readonly DATA_VOLUME="cmangos_mangosd_data"
readonly NETWORK="cmangos_default"
if [[ -t 0 ]] && [[ -t 1 ]]
then
readonly TTY="-it"
else
readonly TTY="-i"
fi
docker run ${TTY} \
--name "${NAME}" \
--network "${NETWORK}" \
--rm \
-e MANGOS_DBHOST="mariadb" \
-e MANGOS_DBUSER="${MANGOS_DBUSER}" \
-e MANGOS_DBPASS="${MANGOS_DBPASS}" \
-p 3443:3443 \
-p 3724:3724 \
-p 7878:7878 \
-p 8085:8085 \
-p 8086:8086 \
-v "${PWD}/config":/opt/mangos/conf:ro \
-v "${DATA_VOLUME}":/var/lib/mangos:ro \
\
"${IMAGE}:${VERSION}" ${@}
-142
View File
@@ -1,142 +0,0 @@
ARG DEBIAN_FRONTEND=noninteractive
ARG VMANGOS_CLIENT_VERSION=5875
ARG VMANGOS_REPOSITORY_URL=https://github.com/vmangos/core.git
ARG VMANGOS_REVISION=development
ARG VMANGOS_PATCHES_REPOSITORY_URL
ARG VMANGOS_USER_ID=1000
ARG VMANGOS_GROUP_ID=1000
ARG VMANGOS_USER_NAME=vmangos
ARG VMANGOS_GROUP_NAME=vmangos
FROM ubuntu:24.04 AS build
ARG DEBIAN_FRONTEND
ARG VMANGOS_CLIENT_VERSION
ARG VMANGOS_REPOSITORY_URL
ARG VMANGOS_REVISION
ARG VMANGOS_PATCHES_REPOSITORY_URL
RUN \
apt update -y && \
apt install -y \
build-essential \
cmake \
git \
libace-dev \
libcurl4-openssl-dev \
libmysqlclient-dev \
libssl-dev \
libtbb-dev \
zlib1g-dev && \
git clone "${VMANGOS_REPOSITORY_URL}" /core && \
cd /core && \
git checkout "${VMANGOS_REVISION}" && \
if [ -n "${VMANGOS_PATCHES_REPOSITORY_URL}" ]; then \
echo "Cloning and applying patches from ${VMANGOS_PATCHES_REPOSITORY_URL}"; \
git clone "${VMANGOS_PATCHES_REPOSITORY_URL}" /tmp/patches && \
for patch in /tmp/patches/*.patch; do \
if [ -f "${patch}" ]; then \
echo "Applying patch ${patch}"; \
git apply "${patch}"; \
fi; \
done; \
rm -rf /tmp/patches; \
else \
echo "No repository to apply patches from provided."; \
fi && \
mkdir -p \
/opt/vmangos/config \
/opt/vmangos/storage/data \
/opt/vmangos/storage/honor \
/opt/vmangos/storage/logs && \
mkdir /core/build && \
cd /core/build && \
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/vmangos ../ \
-DUSE_PCH=1 \
-DUSE_STD_MALLOC=0 \
-DBUILD_FOR_HOST_CPU=0 \
-DTBB_DEBUG=0 \
-DUSE_SCRIPTS=1 \
-DUSE_EXTRACTORS=1 \
-DUSE_REALMMERGE=0 \
-DENABLE_MAILSENDER=1 \
-DSUPPORTED_CLIENT_BUILD=${VMANGOS_CLIENT_VERSION} \
-DDEBUG_SYMBOLS=0 && \
make -j$(nproc) && \
make install && \
rm -rf /core && \
apt clean -y && \
rm -rf /var/lib/apt/lists/*
FROM ubuntu:24.04
ARG DEBIAN_FRONTEND
ARG TARGETARCH
ARG VMANGOS_CLIENT_VERSION
ARG VMANGOS_USER_ID
ARG VMANGOS_GROUP_ID
ARG VMANGOS_USER_NAME
ARG VMANGOS_GROUP_NAME
ENV PYTHONUNBUFFERED=1
ENV VMANGOS_CLIENT_VERSION=${VMANGOS_CLIENT_VERSION}
RUN \
apt update -y && \
apt install -y \
curl \
libace-7.1.2 \
libcurl4 \
libmysqlclient21 \
libssl3 \
libtbb12 \
netcat-openbsd \
python3 \
python-is-python3 \
zlib1g && \
existing_group=$(getent group "${VMANGOS_GROUP_ID}") || true && \
existing_user=$(getent passwd "${VMANGOS_USER_ID}") || true && \
if [ -n "${existing_group}" ]; then \
old_groupname=$(echo "${existing_group}" | cut -d: -f1) && \
groupmod -n "${VMANGOS_GROUP_NAME}" "${old_groupname}"; \
else \
groupadd -g "${VMANGOS_GROUP_ID}" "${VMANGOS_GROUP_NAME}"; \
fi && \
if [ -n "${existing_user}" ]; then \
old_username=$(echo "${existing_user}" | cut -d: -f1) && \
usermod -l "${VMANGOS_USER_NAME}" -d "/home/${VMANGOS_USER_NAME}" "${old_username}" && \
mv "/home/${old_username}" "/home/${VMANGOS_USER_NAME}"; \
else \
useradd -u "${VMANGOS_USER_ID}" -g "${VMANGOS_GROUP_NAME}" -d "/home/${VMANGOS_USER_NAME}" -s /bin/sh -m "${VMANGOS_USER_NAME}"; \
fi && \
# See https://github.com/boxboat/fixuid
curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-${TARGETARCH}.tar.gz | tar -C /usr/local/bin -xzf - && \
chown root:root /usr/local/bin/fixuid && \
chmod 4755 /usr/local/bin/fixuid && \
mkdir -p /etc/fixuid && \
printf "user: ${VMANGOS_USER_NAME}\ngroup: ${VMANGOS_GROUP_NAME}\n" > /etc/fixuid/config.yml && \
apt remove -y curl && \
apt autoremove -y && \
apt clean -y && \
rm -rf /var/lib/apt/lists/*
COPY --from=build --chown=${VMANGOS_USER_NAME}:${VMANGOS_GROUP_NAME} /opt /opt
# See https://github.com/ufoscout/docker-compose-wait
COPY --from=ghcr.io/ufoscout/docker-compose-wait:latest /wait /usr/local/bin/wait-for-db
COPY ./docker/server/docker-cmd-mangosd.sh /usr/local/bin/mangosd
COPY ./docker/server/docker-cmd-realmd.sh /usr/local/bin/realmd
COPY ./docker/server/docker-cmd-extract-client-data.sh /usr/local/bin/extract-client-data
RUN \
chmod +x /opt/vmangos/bin/* && \
find /opt/vmangos/bin/Extractors/ -type f ! -regex ".*\.\(json\|txt\)$" -exec chmod +x {} + && \
chmod +x /usr/local/bin/mangosd && \
chmod +x /usr/local/bin/realmd && \
chmod +x /usr/local/bin/extract-client-data
USER ${VMANGOS_USER_NAME}:${VMANGOS_GROUP_NAME}
CMD ["mangosd"]
@@ -1,73 +0,0 @@
#!/bin/sh
eval $(fixuid -q)
client_data_dir="/opt/vmangos/storage/client-data"
extracted_data_dir="/opt/vmangos/storage/extracted-data"
extractors_dir="/opt/vmangos/bin/Extractors"
client_version_dir="$extracted_data_dir/$VMANGOS_CLIENT_VERSION"
# The `--force` flag can be used to skip the confirmation prompt when
# previously extracted data is found. This is particularly useful for
# automation where the user is not able to interact with the prompt.
force=false
while [ "$#" -gt 0 ]; do
case "$1" in
-f|--force)
# If user passes `-f` or `--force`, set 'force' to true
force=true
shift
;;
*)
shift
;;
esac
done
if [ ! -d "$client_data_dir" ] || [ ! -d "$client_data_dir/Data" ]; then
echo "[vmangos-deploy]: ERROR: Client data not found in '$client_data_dir', aborting extraction" >&2
exit 1
fi
if [ ! -d "$extracted_data_dir" ]; then
echo "[vmangos-deploy]: ERROR: Extracted data target directory '$extracted_data_dir' doesn't exist, aborting extraction" >&2
exit 1
fi
cd "$client_data_dir"
if [ "$force" = false ]; then
if [ -d "$extracted_data_dir/maps" ] || [ -d "$extracted_data_dir/mmaps" ] || [ -d "$extracted_data_dir/vmaps" ] || [ -d "$client_version_dir" ]; then
echo "[vmangos-deploy]: Previously extracted data has been found in '$extracted_data_dir'; continue with the extraction (which will overwrite the old data)? [Y/n]"
read -r choice
choice=$(echo "${choice:-y}" | tr -d '[:space:]')
if [ "$choice" = "n" ] || [ "$choice" = "N" ]; then
echo "[vmangos-deploy]: Aborting extraction"
exit 1
fi
fi
fi
# Remove any potentially previously extracted data from the client directory
rm -rf ./Buildings ./Cameras ./dbc ./maps ./mmaps ./vmaps
"$extractors_dir/MapExtractor"
"$extractors_dir/VMapExtractor"
"$extractors_dir/VMapAssembler"
"$extractors_dir/mmap_extract.py" \
--configInputPath "$extractors_dir/config.json" \
--offMeshInput "$extractors_dir/offmesh.txt"
# Delete extracted data that is no longer needed after processing it to avoid
# confusion
rm -rf ./Buildings ./Cameras
# Remove any potentially already existing data from the extracted data
# directory before moving the new data there
rm -rf "$extracted_data_dir"/*
mkdir -p "$client_version_dir"
mv ./dbc "$client_version_dir/"
mv ./maps ./mmaps ./vmaps "$extracted_data_dir/"
-12
View File
@@ -1,12 +0,0 @@
#!/bin/sh
eval $(fixuid -q)
config_file="/opt/vmangos/config/mangosd.conf"
if [ ! -f "$config_file" ]; then
echo "[vmangos-deploy]: ERROR: Configuration file '$config_file' is missing, exiting" >&2
exit 1
fi
WAIT_LOGGER_LEVEL=error wait-for-db && exec /opt/vmangos/bin/mangosd -c $config_file
-12
View File
@@ -1,12 +0,0 @@
#!/bin/sh
eval $(fixuid -q)
config_file="/opt/vmangos/config/realmd.conf"
if [ ! -f "$config_file" ]; then
echo "[vmangos-deploy]: ERROR: Configuration file '$config_file' is missing, exiting" >&2
exit 1
fi
WAIT_LOGGER_LEVEL=error wait-for-db && exec /opt/vmangos/bin/realmd -c $config_file