mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-19 09:40:59 +00:00
Adds Docker support for TravianZ
Introduces Docker Compose configuration for simplified deployment. Includes a Dockerfile to build the application image and necessary configurations for running TravianZ in a containerized environment. Provides documentation for setup and usage in `DOCKER_README.md`.
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
# Git files
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.gitattributes
|
||||||
|
|
||||||
|
# Docker files
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
.dockerignore
|
||||||
|
.env
|
||||||
|
.env.example
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
README.md
|
||||||
|
DOCKER_README.md
|
||||||
|
CODE_OF_CONDUCT.md
|
||||||
|
CONTRIBUTING.md
|
||||||
|
ISSUE_TEMPLATE.md
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
# IDE and editor files
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# OS files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Temporary files
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# MySQL Database Configuration
|
||||||
|
MYSQL_ROOT_PASSWORD=rootpassword
|
||||||
|
MYSQL_DATABASE=travian
|
||||||
|
MYSQL_USER=travianz
|
||||||
|
MYSQL_PASSWORD=travianzpass
|
||||||
|
|
||||||
|
# Application Configuration
|
||||||
|
# These values will be used during the installation wizard
|
||||||
|
# Hostname for database connection (use 'db' when running in Docker)
|
||||||
|
DB_HOST=db
|
||||||
|
DB_PORT=3306
|
||||||
@@ -39,3 +39,6 @@ GameEngine/Admin/Mods/constant_format.tpl
|
|||||||
# These 2 files change frequently on the server but not in the repository code.
|
# These 2 files change frequently on the server but not in the repository code.
|
||||||
Templates/text.tpl
|
Templates/text.tpl
|
||||||
var/log/access.log
|
var/log/access.log
|
||||||
|
|
||||||
|
# Docker environment file with sensitive credentials
|
||||||
|
.env
|
||||||
|
|||||||
@@ -0,0 +1,314 @@
|
|||||||
|
# TravianZ Docker Setup
|
||||||
|
|
||||||
|
This guide will help you set up TravianZ using Docker and Docker Compose for easy deployment.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- Docker Engine 20.10 or higher
|
||||||
|
- Docker Compose 1.29 or higher
|
||||||
|
- At least 2GB of free RAM
|
||||||
|
- At least 5GB of free disk space
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### 1. Clone the Repository
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/Shadowss/TravianZ.git
|
||||||
|
cd TravianZ
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Configure Environment Variables
|
||||||
|
|
||||||
|
Copy the example environment file and customize it if needed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit `.env` file to set your database credentials:
|
||||||
|
|
||||||
|
```env
|
||||||
|
MYSQL_ROOT_PASSWORD=yourStrongRootPassword
|
||||||
|
MYSQL_DATABASE=travian
|
||||||
|
MYSQL_USER=travianz
|
||||||
|
MYSQL_PASSWORD=yourStrongPassword
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Start the Containers
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
This command will:
|
||||||
|
- Build the TravianZ web application container
|
||||||
|
- Start a MySQL 5.7 database container
|
||||||
|
- Start a phpMyAdmin container for database management
|
||||||
|
- Set up a network for all containers to communicate
|
||||||
|
|
||||||
|
### 4. Access the Installation Wizard
|
||||||
|
|
||||||
|
Once the containers are running, open your browser and navigate to:
|
||||||
|
|
||||||
|
```
|
||||||
|
http://localhost:8080/install
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Complete the Installation
|
||||||
|
|
||||||
|
During the installation wizard, use these database settings:
|
||||||
|
|
||||||
|
- **SQL Hostname:** `db` (this is the Docker container name)
|
||||||
|
- **Port:** `3306`
|
||||||
|
- **Username:** `travianz` (or the value from your `.env` file)
|
||||||
|
- **Password:** `travianzpass` (or the value from your `.env` file)
|
||||||
|
- **DB name:** `travian` (or the value from your `.env` file)
|
||||||
|
- **Prefix:** `s1_` (or customize as needed)
|
||||||
|
- **Type:** `MYSQLi`
|
||||||
|
|
||||||
|
Complete the rest of the installation wizard with your preferred server settings.
|
||||||
|
|
||||||
|
## Services and Ports
|
||||||
|
|
||||||
|
After starting the containers, the following services will be available:
|
||||||
|
|
||||||
|
- **TravianZ Web Application:** http://localhost:8080
|
||||||
|
- **phpMyAdmin:** http://localhost:8081
|
||||||
|
- **MySQL Database:** localhost:3306 (for external connections)
|
||||||
|
|
||||||
|
## Container Management
|
||||||
|
|
||||||
|
### View Running Containers
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose ps
|
||||||
|
```
|
||||||
|
|
||||||
|
### View Logs
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# All containers
|
||||||
|
docker-compose logs
|
||||||
|
|
||||||
|
# Specific container
|
||||||
|
docker-compose logs web
|
||||||
|
docker-compose logs db
|
||||||
|
docker-compose logs phpmyadmin
|
||||||
|
|
||||||
|
# Follow logs in real-time
|
||||||
|
docker-compose logs -f web
|
||||||
|
```
|
||||||
|
|
||||||
|
### Stop Containers
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
### Stop and Remove All Data
|
||||||
|
|
||||||
|
**WARNING:** This will delete all database data!
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose down -v
|
||||||
|
```
|
||||||
|
|
||||||
|
### Restart Containers
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose restart
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rebuild Containers
|
||||||
|
|
||||||
|
If you make changes to the Dockerfile or application code:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
## Accessing the Containers
|
||||||
|
|
||||||
|
### Access Web Container Shell
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it travianz-web bash
|
||||||
|
```
|
||||||
|
|
||||||
|
### Access MySQL Container
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it travianz-db mysql -u root -p
|
||||||
|
```
|
||||||
|
|
||||||
|
Enter the root password from your `.env` file.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Installation Files Not Writable
|
||||||
|
|
||||||
|
If you get permission errors during installation:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it travianz-web chown -R www-data:www-data /var/www/html
|
||||||
|
docker exec -it travianz-web chmod -R 777 /var/www/html/var
|
||||||
|
```
|
||||||
|
|
||||||
|
### Database Connection Failed
|
||||||
|
|
||||||
|
1. Make sure the database container is running:
|
||||||
|
```bash
|
||||||
|
docker-compose ps
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Check database logs:
|
||||||
|
```bash
|
||||||
|
docker-compose logs db
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Verify the hostname is set to `db` (not `localhost` or `127.0.0.1`)
|
||||||
|
|
||||||
|
### Reset Installation
|
||||||
|
|
||||||
|
If you need to start the installation over:
|
||||||
|
|
||||||
|
1. Stop containers:
|
||||||
|
```bash
|
||||||
|
docker-compose down -v
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Remove the installed flag:
|
||||||
|
```bash
|
||||||
|
rm -f var/installed
|
||||||
|
rm -f GameEngine/config.php
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Start containers again:
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Access the installation wizard again at http://localhost:8080/install
|
||||||
|
|
||||||
|
### Port Already in Use
|
||||||
|
|
||||||
|
If port 8080 or 8081 is already in use, edit `docker-compose.yml` and change the ports:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
ports:
|
||||||
|
- "9080:80" # Change 8080 to any available port
|
||||||
|
phpmyadmin:
|
||||||
|
ports:
|
||||||
|
- "9081:80" # Change 8081 to any available port
|
||||||
|
```
|
||||||
|
|
||||||
|
## Backup and Restore
|
||||||
|
|
||||||
|
### Backup Database
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec travianz-db mysqldump -u root -p travian > backup_$(date +%Y%m%d).sql
|
||||||
|
```
|
||||||
|
|
||||||
|
### Restore Database
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -i travianz-db mysql -u root -p travian < backup_20231125.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
### Backup Application Files
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tar -czf travianz_backup_$(date +%Y%m%d).tar.gz \
|
||||||
|
--exclude='./var/db' \
|
||||||
|
--exclude='./.git' \
|
||||||
|
.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Production Deployment
|
||||||
|
|
||||||
|
For production environments, consider the following:
|
||||||
|
|
||||||
|
1. **Use Strong Passwords:** Change all default passwords in `.env`
|
||||||
|
|
||||||
|
2. **Use SSL/TLS:** Set up a reverse proxy (nginx/traefik) with Let's Encrypt
|
||||||
|
|
||||||
|
3. **Limit Database Access:** Remove the database port exposure in `docker-compose.yml`
|
||||||
|
|
||||||
|
4. **Regular Backups:** Set up automated backup scripts
|
||||||
|
|
||||||
|
5. **Resource Limits:** Add resource constraints to containers:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: '1.0'
|
||||||
|
memory: 1G
|
||||||
|
```
|
||||||
|
|
||||||
|
6. **Monitoring:** Consider adding monitoring tools like Prometheus and Grafana
|
||||||
|
|
||||||
|
## Performance Optimization
|
||||||
|
|
||||||
|
### MySQL Tuning
|
||||||
|
|
||||||
|
Edit `docker-compose.yml` to add MySQL configuration:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
command: >
|
||||||
|
--default-authentication-plugin=mysql_native_password
|
||||||
|
--sql_mode=""
|
||||||
|
--max_connections=200
|
||||||
|
--innodb_buffer_pool_size=512M
|
||||||
|
--query_cache_size=32M
|
||||||
|
--query_cache_limit=2M
|
||||||
|
```
|
||||||
|
|
||||||
|
### PHP Tuning
|
||||||
|
|
||||||
|
Create a custom PHP configuration file `php-custom.ini`:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
memory_limit = 256M
|
||||||
|
upload_max_filesize = 20M
|
||||||
|
post_max_size = 20M
|
||||||
|
max_execution_time = 300
|
||||||
|
```
|
||||||
|
|
||||||
|
Then mount it in `docker-compose.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
volumes:
|
||||||
|
- ./php-custom.ini:/usr/local/etc/php/conf.d/custom.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
## Updates
|
||||||
|
|
||||||
|
To update TravianZ to the latest version:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git pull origin main
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
For issues and questions:
|
||||||
|
- GitHub Issues: https://github.com/Shadowss/TravianZ/issues
|
||||||
|
- Gitter Chat: https://gitter.im/TravianZ-V8/Lobby
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
TravianZ Project - See LICENSE file for details
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
FROM php:7.4-apache
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
libpng-dev \
|
||||||
|
libjpeg-dev \
|
||||||
|
libfreetype6-dev \
|
||||||
|
libzip-dev \
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
git \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Configure and install PHP extensions
|
||||||
|
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||||
|
&& docker-php-ext-install -j$(nproc) \
|
||||||
|
gd \
|
||||||
|
mysqli \
|
||||||
|
pdo \
|
||||||
|
pdo_mysql \
|
||||||
|
zip
|
||||||
|
|
||||||
|
# Enable Apache modules
|
||||||
|
RUN a2enmod rewrite headers
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Copy application files
|
||||||
|
COPY . /var/www/html/
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
RUN chown -R www-data:www-data /var/www/html \
|
||||||
|
&& chmod -R 755 /var/www/html \
|
||||||
|
&& chmod -R 777 /var/www/html/var
|
||||||
|
|
||||||
|
# Configure Apache to use /var/www/html as DocumentRoot
|
||||||
|
RUN sed -i 's!/var/www/html!/var/www/html!g' /etc/apache2/sites-available/000-default.conf
|
||||||
|
|
||||||
|
# Expose port 80
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Start Apache
|
||||||
|
CMD ["apache2-foreground"]
|
||||||
@@ -20,9 +20,29 @@ TravianZ Version **v.8.3.5** - BETA 1
|
|||||||
======
|
======
|
||||||
**Note:** this game is still in a pre-release state, although at this point it is very playable, tested and found to be fairly stable
|
**Note:** this game is still in a pre-release state, although at this point it is very playable, tested and found to be fairly stable
|
||||||
|
|
||||||
**WARNING:** please note that ***this is in no way an upgrade*** from the old 8.3.2 version, so please ***do not try to just copy your files over***,
|
**WARNING:** please note that ***this is in no way an upgrade*** from the old 8.3.2 version, so please ***do not try to just copy your files over***,
|
||||||
since the installer logic has changed and you would just crash your old version
|
since the installer logic has changed and you would just crash your old version
|
||||||
|
|
||||||
|
**Docker Quick Start:**
|
||||||
|
|
||||||
|
Get up and running quickly with Docker:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Clone the repository
|
||||||
|
git clone https://github.com/Shadowss/TravianZ.git
|
||||||
|
cd TravianZ
|
||||||
|
|
||||||
|
# Copy environment file
|
||||||
|
cp .env.example .env
|
||||||
|
|
||||||
|
# Start containers
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# Open browser to http://localhost:8080/install
|
||||||
|
```
|
||||||
|
|
||||||
|
For detailed Docker setup instructions, see [DOCKER_README.md](DOCKER_README.md)
|
||||||
|
|
||||||
**Quick links:**
|
**Quick links:**
|
||||||
* [Download and Updates](https://github.com/Shadowss/TravianZ) »» https://github.com/Shadowss/TravianZ
|
* [Download and Updates](https://github.com/Shadowss/TravianZ) »» https://github.com/Shadowss/TravianZ
|
||||||
* [Wiki](https://github.com/Shadowss/TravianZ/wiki)
|
* [Wiki](https://github.com/Shadowss/TravianZ/wiki)
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: travianz-web
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www/html
|
||||||
|
- ./var:/var/www/html/var
|
||||||
|
environment:
|
||||||
|
- APACHE_DOCUMENT_ROOT=/var/www/html
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
networks:
|
||||||
|
- travianz-network
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mysql:5.7
|
||||||
|
container_name: travianz-db
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpassword}
|
||||||
|
MYSQL_DATABASE: ${MYSQL_DATABASE:-travian}
|
||||||
|
MYSQL_USER: ${MYSQL_USER:-travianz}
|
||||||
|
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-travianzpass}
|
||||||
|
volumes:
|
||||||
|
- db-data:/var/lib/mysql
|
||||||
|
- ./var/db:/docker-entrypoint-initdb.d:ro
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
networks:
|
||||||
|
- travianz-network
|
||||||
|
restart: unless-stopped
|
||||||
|
command: --default-authentication-plugin=mysql_native_password --sql_mode=""
|
||||||
|
|
||||||
|
phpmyadmin:
|
||||||
|
image: phpmyadmin/phpmyadmin:latest
|
||||||
|
container_name: travianz-phpmyadmin
|
||||||
|
environment:
|
||||||
|
PMA_HOST: db
|
||||||
|
PMA_PORT: 3306
|
||||||
|
PMA_USER: root
|
||||||
|
PMA_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpassword}
|
||||||
|
ports:
|
||||||
|
- "8081:80"
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
networks:
|
||||||
|
- travianz-network
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db-data:
|
||||||
|
driver: local
|
||||||
|
|
||||||
|
networks:
|
||||||
|
travianz-network:
|
||||||
|
driver: bridge
|
||||||
Reference in New Issue
Block a user