From 3fc550debe7b848596274f2b45e21e000646569a Mon Sep 17 00:00:00 2001 From: jeirmeister Date: Sun, 14 Dec 2025 19:32:36 -0800 Subject: [PATCH] Initial commit --- .build | 1 + .env.example | 24 ++++++++ .gitignore | 1 + .gitmodules | 3 + docker-compose.yml | 139 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 168 insertions(+) create mode 160000 .build create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 .gitmodules diff --git a/.build b/.build new file mode 160000 index 0000000..b29909b --- /dev/null +++ b/.build @@ -0,0 +1 @@ +Subproject commit b29909bdbec03d1cb9566bc0b73e0026e908f427 diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..86698f2 --- /dev/null +++ b/.env.example @@ -0,0 +1,24 @@ +# Database Configuration +DB_NAME=servatrice +DB_USER=servatrice +DB_PASSWORD=changeme_secure_password +DB_ROOT_PASSWORD=changeme_root_password + +# Server Configuration +SERVER_NAME="Jeirs Cockatrice Server" +SERVER_VERSION=2.10.2 +SERVER_PORT=4747 +WEBSOCKET_PORT=4748 + +# Security & Limits +MAX_USERS=500 +MAX_USERS_PER_ADDRESS=4 +IDLE_TIMEOUT=3600 +ENABLE_REGISTRATION=true + +# Room Settings +DEFAULT_ROOM=Main +MAX_ROOMS=50 + +# Logging +LOG_LEVEL=info diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2bd7097 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".build"] + path = .build + url = https://github.com/Cockatrice/Cockatrice.git diff --git a/docker-compose.yml b/docker-compose.yml index e69de29..e2befa3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,139 @@ +name: cockatrice + +services: + servatrice: + build: + context: . + dockerfile: .build/Dockerfile + image: servatrice + ports: + - "${SERVER_PORT:-4747}:4747" + - "${WEBSOCKET_PORT:-4748}:4748" + environment: + - DATABASE_HOST=mariadb + - DATABASE_PORT=3306 + - DATABASE_NAME=${DB_NAME:-servatrice} + - DATABASE_USER=${DB_USER:-servatrice} + - DATABASE_PASSWORD=${DB_PASSWORD:-changeme} + configs: + - source: servatrice_config + target: /config/servatrice.ini + mode: 0444 + volumes: + - ./.data/logs:/var/log/servatrice + - ./.data/replays:/var/lib/servatrice/replays + depends_on: + mariadb: + condition: service_healthy + restart: unless-stopped + networks: + - servatrice-net + + mariadb: + image: mariadb:10.11 + container_name: servatrice-db + environment: + - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-rootchangeme} + - MYSQL_DATABASE=${DB_NAME:-servatrice} + - MYSQL_USER=${DB_USER:-servatrice} + - MYSQL_PASSWORD=${DB_PASSWORD:-changeme} + configs: + - source: db_init + target: /docker-entrypoint-initdb.d/init.sql + mode: 0444 + volumes: + - mariadb-data:/var/lib/mysql + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + interval: 10s + timeout: 5s + retries: 5 + restart: unless-stopped + networks: + - servatrice-net + +volumes: + mariadb-data: + driver: local + +networks: + servatrice-net: + driver: bridge + + +configs: + servatrice_config: + content: | + [server] + name=${SERVER_NAME:-My Cockatrice Server} + host=0.0.0.0 + port=4747 + serverversion=${SERVER_VERSION:-2.10.2} + websocket_port=4748 + + [database] + type=mysql + hostname=mariadb + port=3306 + database=${DB_NAME:-servatrice} + user=${DB_USER:-servatrice} + password=${DB_PASSWORD:-changeme} + + [security] + enable_registration=${ENABLE_REGISTRATION:-true} + enable_forgot_password=true + max_users_per_address=${MAX_USERS_PER_ADDRESS:-4} + max_users_total=${MAX_USERS:-500} + idle_client_timeout=${IDLE_TIMEOUT:-3600} + + [authentication] + method=sql + + [logging] + log_level=${LOG_LEVEL:-info} + log_file=/var/log/servatrice/servatrice.log + + [rooms] + default_room=${DEFAULT_ROOM:-Main} + allow_room_creation=true + max_rooms=${MAX_ROOMS:-50} + + db_init: + content: | + CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(64) NOT NULL UNIQUE, + password_hash VARCHAR(128) NOT NULL, + email VARCHAR(128), + realname VARCHAR(128), + country VARCHAR(3), + is_admin TINYINT(1) DEFAULT 0, + is_moderator TINYINT(1) DEFAULT 0, + active TINYINT(1) DEFAULT 1, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + last_login TIMESTAMP NULL, + INDEX idx_name (name) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + + CREATE TABLE IF NOT EXISTS bans ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT, + ip_address VARCHAR(45), + banned_by INT, + ban_reason TEXT, + banned_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + expires_at TIMESTAMP NULL, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + INDEX idx_user_id (user_id), + INDEX idx_ip (ip_address) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + + CREATE TABLE IF NOT EXISTS replays ( + id INT AUTO_INCREMENT PRIMARY KEY, + replay_name VARCHAR(128) NOT NULL, + creator_id INT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + game_length INT, + player_count INT, + FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE SET NULL + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;