From fee9d60da4a5360724b8239d908118e80e250092 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 16 Sep 2023 14:40:55 +0200 Subject: [PATCH 1/9] Create docker-compose.yml --- docker-compose.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..b3299c4a32 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +version: "1.1" +services: + apache: + image: php:8.2-apache + ports: + - 8001:80 + build: + args: + user: myaac + uid: 1000 + context: . + dockerfile: Dockerfile + restart: unless-stopped + working_dir: /var/www/html + depends_on: + - db + volumes: + - ./:/var/www/html + networks: + - default + + db: + image: mysql:8.0 + restart: unless-stopped # always? + environment: + MYSQL_DATABASE: myaac + MYSQL_ROOT_PASSWORD: root + #MYSQL_RANDOM_ROOT_PASSWORD: '1' #doesnt work + MYSQL_PASSWORD: myaac + MYSQL_USER: myaac + ports: + - 8003:3306 + volumes: + - db:/var/lib/mysql + networks: + - default + + phpmyadmin: + image: phpmyadmin + restart: always + ports: + - 8002:80 + +volumes: + db: From e9b561774893632412dc0458b34e753df734c87d Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 16 Sep 2023 14:40:58 +0200 Subject: [PATCH 2/9] Create Dockerfile --- Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..9d1b9cb6b8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM php:8.2-apache + +# Arguments defined in docker-compose.yml +ARG user +ARG uid + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ + libpng-dev \ + libonig-dev \ + libxml2-dev \ + libzip-dev \ + zip \ + unzip + +# Clear cache +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install PHP extensions +RUN docker-php-ext-install pdo pdo_mysql bcmath gd zip + +# Get latest Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Create system user to run Composer Commands +RUN useradd -G www-data,root -u $uid -d /home/$user $user +RUN mkdir -p /home/$user/.composer && \ + chown -R $user:$user /home/$user + +RUN cd /home/$user +RUN git clone https://github.com/otland/forgottenserver.git + +USER $user + +# Set working directory +WORKDIR /var/www/html + +#RUN composer install + + From 03b2d715722d750c4f85b89990f834118b1f778a Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 16 Sep 2023 18:20:08 +0200 Subject: [PATCH 3/9] [wip] docker setup It's working now --- docker-compose.yml | 22 +- Dockerfile => docker/Dockerfile | 16 +- docker/config.lua | 12 + docker/tfs_schema.sql | 384 ++++++++++++++++++++++++++++++++ 4 files changed, 415 insertions(+), 19 deletions(-) rename Dockerfile => docker/Dockerfile (75%) create mode 100644 docker/config.lua create mode 100644 docker/tfs_schema.sql diff --git a/docker-compose.yml b/docker-compose.yml index b3299c4a32..33d79fed47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,39 +1,35 @@ -version: "1.1" +version: "1.0" services: - apache: - image: php:8.2-apache + web: ports: - 8001:80 build: args: - user: myaac - uid: 1000 - context: . - dockerfile: Dockerfile + user: www-data + uid: 33 + context: ./ + dockerfile: ./docker/Dockerfile restart: unless-stopped working_dir: /var/www/html depends_on: - db volumes: - ./:/var/www/html - networks: - - default db: image: mysql:8.0 restart: unless-stopped # always? environment: + MYSQL_RANDOM_ROOT_PASSWORD: "yes" MYSQL_DATABASE: myaac - MYSQL_ROOT_PASSWORD: root - #MYSQL_RANDOM_ROOT_PASSWORD: '1' #doesnt work + #MYSQL_ROOT_PASSWORD: root MYSQL_PASSWORD: myaac MYSQL_USER: myaac ports: - 8003:3306 volumes: + - ./docker/tfs_schema.sql:/docker-entrypoint-initdb.d/tfs_schema.sql - db:/var/lib/mysql - networks: - - default phpmyadmin: image: phpmyadmin diff --git a/Dockerfile b/docker/Dockerfile similarity index 75% rename from Dockerfile rename to docker/Dockerfile index 9d1b9cb6b8..245a5496f6 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -25,18 +25,22 @@ RUN docker-php-ext-install pdo pdo_mysql bcmath gd zip COPY --from=composer:latest /usr/bin/composer /usr/bin/composer # Create system user to run Composer Commands -RUN useradd -G www-data,root -u $uid -d /home/$user $user +#RUN useradd -G www-data,root -u $uid -d /home/$user $user RUN mkdir -p /home/$user/.composer && \ chown -R $user:$user /home/$user -RUN cd /home/$user -RUN git clone https://github.com/otland/forgottenserver.git +RUN chown -R www-data:www-data /var/www USER $user -# Set working directory -WORKDIR /var/www/html +WORKDIR /home/$user +RUN git clone https://github.com/otland/forgottenserver.git -#RUN composer install +COPY docker/config.lua /home/$user/forgottenserver +#WORKDIR /home/$user/forgottenserver + +WORKDIR /var/www/html +COPY . . +RUN composer install diff --git a/docker/config.lua b/docker/config.lua new file mode 100644 index 0000000000..79f30e1e7e --- /dev/null +++ b/docker/config.lua @@ -0,0 +1,12 @@ +serverName = "Forgotten" +mysqlHost = "db" +mysqlUser = "myaac" +mysqlPass = "myaac" +mysqlDatabase = "myaac" +mysqlPort = 3306 +mysqlSock = "" + +ip = 192.168.176.1 +statusPort = 7171 +statusTimeout = 2000 + diff --git a/docker/tfs_schema.sql b/docker/tfs_schema.sql new file mode 100644 index 0000000000..0020eb58ea --- /dev/null +++ b/docker/tfs_schema.sql @@ -0,0 +1,384 @@ +CREATE TABLE IF NOT EXISTS `accounts` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(32) NOT NULL, + `password` char(40) NOT NULL, + `secret` char(16) DEFAULT NULL, + `type` int NOT NULL DEFAULT '1', + `premium_ends_at` int unsigned NOT NULL DEFAULT '0', + `email` varchar(255) NOT NULL DEFAULT '', + `creation` int NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `players` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `group_id` int NOT NULL DEFAULT '1', + `account_id` int NOT NULL DEFAULT '0', + `level` int NOT NULL DEFAULT '1', + `vocation` int NOT NULL DEFAULT '0', + `health` int NOT NULL DEFAULT '150', + `healthmax` int NOT NULL DEFAULT '150', + `experience` bigint unsigned NOT NULL DEFAULT '0', + `lookbody` int NOT NULL DEFAULT '0', + `lookfeet` int NOT NULL DEFAULT '0', + `lookhead` int NOT NULL DEFAULT '0', + `looklegs` int NOT NULL DEFAULT '0', + `looktype` int NOT NULL DEFAULT '136', + `lookaddons` int NOT NULL DEFAULT '0', + `lookmount` int NOT NULL DEFAULT '0', + `lookmounthead` int NOT NULL DEFAULT '0', + `lookmountbody` int NOT NULL DEFAULT '0', + `lookmountlegs` int NOT NULL DEFAULT '0', + `lookmountfeet` int NOT NULL DEFAULT '0', + `randomizemount` tinyint NOT NULL DEFAULT '0', + `direction` tinyint unsigned NOT NULL DEFAULT '2', + `maglevel` int NOT NULL DEFAULT '0', + `mana` int NOT NULL DEFAULT '0', + `manamax` int NOT NULL DEFAULT '0', + `manaspent` bigint unsigned NOT NULL DEFAULT '0', + `soul` int unsigned NOT NULL DEFAULT '0', + `town_id` int NOT NULL DEFAULT '1', + `posx` int NOT NULL DEFAULT '0', + `posy` int NOT NULL DEFAULT '0', + `posz` int NOT NULL DEFAULT '0', + `conditions` blob DEFAULT NULL, + `cap` int NOT NULL DEFAULT '400', + `sex` int NOT NULL DEFAULT '0', + `lastlogin` bigint unsigned NOT NULL DEFAULT '0', + `lastip` varbinary(16) NOT NULL DEFAULT '0', + `save` tinyint NOT NULL DEFAULT '1', + `skull` tinyint NOT NULL DEFAULT '0', + `skulltime` bigint NOT NULL DEFAULT '0', + `lastlogout` bigint unsigned NOT NULL DEFAULT '0', + `blessings` tinyint NOT NULL DEFAULT '0', + `onlinetime` bigint NOT NULL DEFAULT '0', + `deletion` bigint NOT NULL DEFAULT '0', + `balance` bigint unsigned NOT NULL DEFAULT '0', + `offlinetraining_time` smallint unsigned NOT NULL DEFAULT '43200', + `offlinetraining_skill` int NOT NULL DEFAULT '-1', + `stamina` smallint unsigned NOT NULL DEFAULT '2520', + `skill_fist` int unsigned NOT NULL DEFAULT 10, + `skill_fist_tries` bigint unsigned NOT NULL DEFAULT 0, + `skill_club` int unsigned NOT NULL DEFAULT 10, + `skill_club_tries` bigint unsigned NOT NULL DEFAULT 0, + `skill_sword` int unsigned NOT NULL DEFAULT 10, + `skill_sword_tries` bigint unsigned NOT NULL DEFAULT 0, + `skill_axe` int unsigned NOT NULL DEFAULT 10, + `skill_axe_tries` bigint unsigned NOT NULL DEFAULT 0, + `skill_dist` int unsigned NOT NULL DEFAULT 10, + `skill_dist_tries` bigint unsigned NOT NULL DEFAULT 0, + `skill_shielding` int unsigned NOT NULL DEFAULT 10, + `skill_shielding_tries` bigint unsigned NOT NULL DEFAULT 0, + `skill_fishing` int unsigned NOT NULL DEFAULT 10, + `skill_fishing_tries` bigint unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`), + FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE, + KEY `vocation` (`vocation`) +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `account_bans` ( + `account_id` int NOT NULL, + `reason` varchar(255) NOT NULL, + `banned_at` bigint NOT NULL, + `expires_at` bigint NOT NULL, + `banned_by` int NOT NULL, + PRIMARY KEY (`account_id`), + FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `account_ban_history` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `account_id` int NOT NULL, + `reason` varchar(255) NOT NULL, + `banned_at` bigint NOT NULL, + `expired_at` bigint NOT NULL, + `banned_by` int NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `account_storage` ( + `account_id` int NOT NULL, + `key` int unsigned NOT NULL, + `value` int NOT NULL, + PRIMARY KEY (`account_id`, `key`), + FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `ip_bans` ( + `ip` varbinary(16) NOT NULL, + `reason` varchar(255) NOT NULL, + `banned_at` bigint NOT NULL, + `expires_at` bigint NOT NULL, + `banned_by` int NOT NULL, + PRIMARY KEY (`ip`), + FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `player_namelocks` ( + `player_id` int NOT NULL, + `reason` varchar(255) NOT NULL, + `namelocked_at` bigint NOT NULL, + `namelocked_by` int NOT NULL, + PRIMARY KEY (`player_id`), + FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`namelocked_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `account_viplist` ( + `account_id` int NOT NULL COMMENT 'id of account whose viplist entry it is', + `player_id` int NOT NULL COMMENT 'id of target player of viplist entry', + `description` varchar(128) NOT NULL DEFAULT '', + `icon` tinyint unsigned NOT NULL DEFAULT '0', + `notify` tinyint NOT NULL DEFAULT '0', + UNIQUE KEY `account_player_index` (`account_id`,`player_id`), + FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE, + FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `guilds` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `ownerid` int NOT NULL, + `creationdata` int NOT NULL, + `motd` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY (`name`), + UNIQUE KEY (`ownerid`), + FOREIGN KEY (`ownerid`) REFERENCES `players`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `guild_invites` ( + `player_id` int NOT NULL DEFAULT '0', + `guild_id` int NOT NULL DEFAULT '0', + PRIMARY KEY (`player_id`,`guild_id`), + FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE, + FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `guild_ranks` ( + `id` int NOT NULL AUTO_INCREMENT, + `guild_id` int NOT NULL COMMENT 'guild', + `name` varchar(255) NOT NULL COMMENT 'rank name', + `level` int NOT NULL COMMENT 'rank level - leader, vice, member, maybe something else', + PRIMARY KEY (`id`), + FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `guild_membership` ( + `player_id` int NOT NULL, + `guild_id` int NOT NULL, + `rank_id` int NOT NULL, + `nick` varchar(15) NOT NULL DEFAULT '', + PRIMARY KEY (`player_id`), + FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`rank_id`) REFERENCES `guild_ranks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `guild_wars` ( + `id` int NOT NULL AUTO_INCREMENT, + `guild1` int NOT NULL DEFAULT '0', + `guild2` int NOT NULL DEFAULT '0', + `name1` varchar(255) NOT NULL, + `name2` varchar(255) NOT NULL, + `status` tinyint NOT NULL DEFAULT '0', + `started` bigint NOT NULL DEFAULT '0', + `ended` bigint NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `guild1` (`guild1`), + KEY `guild2` (`guild2`) +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `guildwar_kills` ( + `id` int NOT NULL AUTO_INCREMENT, + `killer` varchar(50) NOT NULL, + `target` varchar(50) NOT NULL, + `killerguild` int NOT NULL DEFAULT '0', + `targetguild` int NOT NULL DEFAULT '0', + `warid` int NOT NULL DEFAULT '0', + `time` bigint NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`warid`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `houses` ( + `id` int NOT NULL AUTO_INCREMENT, + `owner` int NOT NULL, + `paid` int unsigned NOT NULL DEFAULT '0', + `warnings` int NOT NULL DEFAULT '0', + `name` varchar(255) NOT NULL, + `rent` int NOT NULL DEFAULT '0', + `town_id` int NOT NULL DEFAULT '0', + `bid` int NOT NULL DEFAULT '0', + `bid_end` int NOT NULL DEFAULT '0', + `last_bid` int NOT NULL DEFAULT '0', + `highest_bidder` int NOT NULL DEFAULT '0', + `size` int NOT NULL DEFAULT '0', + `beds` int NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `owner` (`owner`), + KEY `town_id` (`town_id`) +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `house_lists` ( + `house_id` int NOT NULL, + `listid` int NOT NULL, + `list` text NOT NULL, + FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `market_history` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `player_id` int NOT NULL, + `sale` tinyint NOT NULL DEFAULT '0', + `itemtype` smallint unsigned NOT NULL, + `amount` smallint unsigned NOT NULL, + `price` bigint unsigned NOT NULL DEFAULT '0', + `expires_at` bigint unsigned NOT NULL, + `inserted` bigint unsigned NOT NULL, + `state` tinyint unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `player_id` (`player_id`, `sale`), + FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `market_offers` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `player_id` int NOT NULL, + `sale` tinyint NOT NULL DEFAULT '0', + `itemtype` smallint unsigned NOT NULL, + `amount` smallint unsigned NOT NULL, + `created` bigint unsigned NOT NULL, + `anonymous` tinyint NOT NULL DEFAULT '0', + `price` bigint unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `sale` (`sale`,`itemtype`), + KEY `created` (`created`), + FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `players_online` ( + `player_id` int NOT NULL, + PRIMARY KEY (`player_id`) +) ENGINE=MEMORY DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `player_deaths` ( + `player_id` int NOT NULL, + `time` bigint unsigned NOT NULL DEFAULT '0', + `level` int NOT NULL DEFAULT '1', + `killed_by` varchar(255) NOT NULL, + `is_player` tinyint NOT NULL DEFAULT '1', + `mostdamage_by` varchar(100) NOT NULL, + `mostdamage_is_player` tinyint NOT NULL DEFAULT '0', + `unjustified` tinyint NOT NULL DEFAULT '0', + `mostdamage_unjustified` tinyint NOT NULL DEFAULT '0', + FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE, + KEY `killed_by` (`killed_by`), + KEY `mostdamage_by` (`mostdamage_by`) +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `player_depotitems` ( + `player_id` int NOT NULL, + `sid` int NOT NULL COMMENT 'any given range eg 0-100 will be reserved for depot lockers and all > 100 will be then normal items inside depots', + `pid` int NOT NULL DEFAULT '0', + `itemtype` smallint unsigned NOT NULL, + `count` smallint NOT NULL DEFAULT '0', + `attributes` blob NOT NULL, + UNIQUE KEY `player_id_2` (`player_id`, `sid`), + FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `player_inboxitems` ( + `player_id` int NOT NULL, + `sid` int NOT NULL, + `pid` int NOT NULL DEFAULT '0', + `itemtype` smallint unsigned NOT NULL, + `count` smallint NOT NULL DEFAULT '0', + `attributes` blob NOT NULL, + UNIQUE KEY `player_id_2` (`player_id`, `sid`), + FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `player_storeinboxitems` ( + `player_id` int NOT NULL, + `sid` int NOT NULL, + `pid` int NOT NULL DEFAULT '0', + `itemtype` smallint unsigned NOT NULL, + `count` smallint NOT NULL DEFAULT '0', + `attributes` blob NOT NULL, + UNIQUE KEY `player_id_2` (`player_id`, `sid`), + FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `player_items` ( + `player_id` int NOT NULL DEFAULT '0', + `pid` int NOT NULL DEFAULT '0', + `sid` int NOT NULL DEFAULT '0', + `itemtype` smallint unsigned NOT NULL DEFAULT '0', + `count` smallint NOT NULL DEFAULT '0', + `attributes` blob NOT NULL, + FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE, + KEY `sid` (`sid`) +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `player_spells` ( + `player_id` int NOT NULL, + `name` varchar(255) NOT NULL, + FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `player_storage` ( + `player_id` int NOT NULL DEFAULT '0', + `key` int unsigned NOT NULL DEFAULT '0', + `value` int NOT NULL DEFAULT '0', + PRIMARY KEY (`player_id`,`key`), + FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `server_config` ( + `config` varchar(50) NOT NULL, + `value` varchar(256) NOT NULL DEFAULT '', + PRIMARY KEY `config` (`config`) +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `tile_store` ( + `house_id` int NOT NULL, + `data` longblob NOT NULL, + FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +CREATE TABLE IF NOT EXISTS `towns` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `posx` int NOT NULL DEFAULT '0', + `posy` int NOT NULL DEFAULT '0', + `posz` int NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8; + +INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '35'), ('players_record', '0'); + +DROP TRIGGER IF EXISTS `ondelete_players`; +DROP TRIGGER IF EXISTS `oncreate_guilds`; + +DELIMITER // +CREATE TRIGGER `ondelete_players` BEFORE DELETE ON `players` + FOR EACH ROW BEGIN + UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`; +END +// +CREATE TRIGGER `oncreate_guilds` AFTER INSERT ON `guilds` + FOR EACH ROW BEGIN + INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('the Leader', 3, NEW.`id`); + INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Vice-Leader', 2, NEW.`id`); + INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('a Member', 1, NEW.`id`); +END +// +DELIMITER ; From c503f5e0a537149e7222a346e86a73d2cbf854c6 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 16 Sep 2023 19:10:56 +0200 Subject: [PATCH 4/9] enable apcu & opcache --- docker/Dockerfile | 17 ++++++++++++++++- docker/config.lua | 2 +- docker/opcache.ini | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 docker/opcache.ini diff --git a/docker/Dockerfile b/docker/Dockerfile index 245a5496f6..7e2d518aea 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,7 @@ FROM php:8.2-apache +ARG APCU_VERSION=5.1.22 + # Arguments defined in docker-compose.yml ARG user ARG uid @@ -19,11 +21,24 @@ RUN apt-get update && apt-get install -y \ RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install PHP extensions -RUN docker-php-ext-install pdo pdo_mysql bcmath gd zip +RUN docker-php-ext-install pdo pdo_mysql gd zip opcache + +RUN docker-php-ext-configure opcache --enable-opcache + +#INSTALL APCU +RUN pecl install apcu-${APCU_VERSION} && docker-php-ext-enable apcu +RUN echo "extension=apcu.so" >> /usr/local/etc/php/php.ini +RUN echo "apc.enable_cli=1" >> /usr/local/etc/php/php.ini +RUN echo "apc.enable=1" >> /usr/local/etc/php/php.ini +#APCU # Get latest Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer +RUN ls + +COPY docker/opcache.ini /usr/local/etc/php/conf.d/opcache.ini + # Create system user to run Composer Commands #RUN useradd -G www-data,root -u $uid -d /home/$user $user RUN mkdir -p /home/$user/.composer && \ diff --git a/docker/config.lua b/docker/config.lua index 79f30e1e7e..e06cd04873 100644 --- a/docker/config.lua +++ b/docker/config.lua @@ -6,7 +6,7 @@ mysqlDatabase = "myaac" mysqlPort = 3306 mysqlSock = "" -ip = 192.168.176.1 +ip = "192.168.176.1" statusPort = 7171 statusTimeout = 2000 diff --git a/docker/opcache.ini b/docker/opcache.ini new file mode 100644 index 0000000000..9314967872 --- /dev/null +++ b/docker/opcache.ini @@ -0,0 +1,2 @@ +[opcache] +opcache.enable=1 From 72d7ee8bf25312d90a8263c60d351caa9ad8abde Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 16 Sep 2023 21:49:11 +0200 Subject: [PATCH 5/9] Speed up 20x? By removing volume --- docker-compose.yml | 4 ++-- docker/Dockerfile | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 33d79fed47..f2525fbc53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,8 +13,8 @@ services: working_dir: /var/www/html depends_on: - db - volumes: - - ./:/var/www/html + #volumes: + # - ./:/var/www/html db: image: mysql:8.0 diff --git a/docker/Dockerfile b/docker/Dockerfile index 7e2d518aea..89c9ac709c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -35,8 +35,6 @@ RUN echo "apc.enable=1" >> /usr/local/etc/php/php.ini # Get latest Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer -RUN ls - COPY docker/opcache.ini /usr/local/etc/php/conf.d/opcache.ini # Create system user to run Composer Commands @@ -44,7 +42,7 @@ COPY docker/opcache.ini /usr/local/etc/php/conf.d/opcache.ini RUN mkdir -p /home/$user/.composer && \ chown -R $user:$user /home/$user -RUN chown -R www-data:www-data /var/www +RUN chown -R www-data.www-data /var/www USER $user @@ -57,5 +55,5 @@ COPY docker/config.lua /home/$user/forgottenserver WORKDIR /var/www/html -COPY . . +COPY --chown=www-data:www-data . . RUN composer install From 49af260c2e19cff0b226a101dd060ca13f1dd16c Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 17 Sep 2023 14:39:02 +0200 Subject: [PATCH 6/9] Some features for docker users Disable IP Check on install automatically fill out server_path --- docker/Dockerfile | 16 +++++----------- docker/opcache.ini | 2 -- install/index.php | 2 +- install/steps/4-config.php | 1 + install/steps/5-database.php | 5 ++++- system/templates/install.config.html.twig | 6 +++++- 6 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 docker/opcache.ini diff --git a/docker/Dockerfile b/docker/Dockerfile index 89c9ac709c..b5f3a99d18 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -15,28 +15,21 @@ RUN apt-get update && apt-get install -y \ libxml2-dev \ libzip-dev \ zip \ - unzip + unzip \ + nano \ + vim # Clear cache RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install PHP extensions RUN docker-php-ext-install pdo pdo_mysql gd zip opcache - RUN docker-php-ext-configure opcache --enable-opcache - -#INSTALL APCU RUN pecl install apcu-${APCU_VERSION} && docker-php-ext-enable apcu -RUN echo "extension=apcu.so" >> /usr/local/etc/php/php.ini -RUN echo "apc.enable_cli=1" >> /usr/local/etc/php/php.ini -RUN echo "apc.enable=1" >> /usr/local/etc/php/php.ini -#APCU # Get latest Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer -COPY docker/opcache.ini /usr/local/etc/php/conf.d/opcache.ini - # Create system user to run Composer Commands #RUN useradd -G www-data,root -u $uid -d /home/$user $user RUN mkdir -p /home/$user/.composer && \ @@ -49,7 +42,8 @@ USER $user WORKDIR /home/$user RUN git clone https://github.com/otland/forgottenserver.git -COPY docker/config.lua /home/$user/forgottenserver +COPY --chown=www-data:www-data docker/config.lua /home/$user/forgottenserver +COPY --chown=www-data:www-data docker/config.local.php /var/www/html #WORKDIR /home/$user/forgottenserver diff --git a/docker/opcache.ini b/docker/opcache.ini deleted file mode 100644 index 9314967872..0000000000 --- a/docker/opcache.ini +++ /dev/null @@ -1,2 +0,0 @@ -[opcache] -opcache.enable=1 diff --git a/install/index.php b/install/index.php index 9c2e50481e..6100b85301 100644 --- a/install/index.php +++ b/install/index.php @@ -195,7 +195,7 @@ } } - if(!$allow) + if(!$allow && !config('install_ignore_ip_check')) { $content = warning('In file install/ip.txt must be your IP!
In file is:
' . nl2br($file_content) . '
diff --git a/install/steps/4-config.php b/install/steps/4-config.php index 325b97f1b4..731538c362 100644 --- a/install/steps/4-config.php +++ b/install/steps/4-config.php @@ -11,6 +11,7 @@ } $twig->display('install.config.html.twig', array( + 'config' => $config, 'clients' => $clients, 'timezones' => DateTimeZone::listIdentifiers(), 'locale' => $locale, diff --git a/install/steps/5-database.php b/install/steps/5-database.php index b75608fc05..41517c311b 100644 --- a/install/steps/5-database.php +++ b/install/steps/5-database.php @@ -37,6 +37,9 @@ $configToSave['gzip_output'] = false; $configToSave['cache_engine'] = 'auto'; $configToSave['cache_prefix'] = 'myaac_' . generateRandomString(8, true, false, true); + if (isset($config['install_ignore_ip_check'])) { + $configToSave['install_ignore_ip_check'] = $config['install_ignore_ip_check']; + } require BASE . 'install/includes/config.php'; @@ -84,7 +87,7 @@ $_SESSION['config_content'] = $content; unset($_SESSION['saved']); - $locale['step_database_error_file'] = str_replace('$FILE$', '' . BASE . 'config.php', $locale['step_database_error_file']); + $locale['step_database_error_file'] = str_replace('$FILE$', '' . BASE . 'config.local.php', $locale['step_database_error_file']); error($locale['step_database_error_file'] . '
'); } diff --git a/system/templates/install.config.html.twig b/system/templates/install.config.html.twig index ab4fc36195..afb91a7064 100644 --- a/system/templates/install.config.html.twig +++ b/system/templates/install.config.html.twig @@ -10,9 +10,13 @@ {% for value in ['server_path'] %} + {% if value == 'server_path' and config.server_path is not null %} + {% set server_path = { 'var_server_path': config.server_path } %} + {% set session = session | merge (server_path) %} + {% endif %}
- + {{ locale['step_config_' ~ value ~ '_desc'] }}
{% endfor %} From a4b1631f6d86eff6a692c17a8babd42a6852e691 Mon Sep 17 00:00:00 2001 From: slawkens Date: Wed, 20 Sep 2023 15:54:44 +0200 Subject: [PATCH 7/9] Add missing file --- .gitignore | 2 +- docker/config.local.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 docker/config.local.php diff --git a/.gitignore b/.gitignore index b4d564e956..26d9a96e4c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ cypress/e2e/2-advanced-examples releases tmp -config.local.php +./config.local.php # all custom templates templates/* diff --git a/docker/config.local.php b/docker/config.local.php new file mode 100644 index 0000000000..8a0cc6524c --- /dev/null +++ b/docker/config.local.php @@ -0,0 +1,4 @@ + Date: Wed, 20 Sep 2023 15:55:06 +0200 Subject: [PATCH 8/9] Update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 26d9a96e4c..7a0569b3af 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,8 @@ cypress/e2e/2-advanced-examples releases tmp -./config.local.php +config.local.php +!docker/config.local.php # all custom templates templates/* From 42e40e5d776f63ac15d11167ad9efc6cff4d1ff7 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 22 Sep 2023 16:18:05 +0200 Subject: [PATCH 9/9] Twig_SimpleFilter is deprecated --- system/twig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/twig.php b/system/twig.php index f82717a558..49c0cce6ee 100644 --- a/system/twig.php +++ b/system/twig.php @@ -30,7 +30,7 @@ } unset($dev_mode); -$filter = new Twig_SimpleFilter('timeago', function ($datetime) { +$filter = new TwigFilter('timeago', function ($datetime) { $time = time() - strtotime($datetime);