push docker version
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
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"]
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,172 @@
|
||||
#!/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
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
#!/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 "$@"
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,142 @@
|
||||
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"]
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/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/"
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user