# Minecraft Cluster Deployment Using Docker Compose This project sets up a cluster of Minecraft servers using Docker Compose. Each server is configured with FabricMC for mod support and uses the Holesail network for secure, peer-to-peer connections. ## Features - **Cluster Deployment:** Easily deploy multiple Minecraft servers. - **FabricMC Support:** Automatically fetches and installs the latest FabricMC server version. - **Holesail Networking:** Secure P2P connections with unique connection strings for each server. - **Mod Manager:** Integrated mod manager for managing Minecraft mods. - **PM2 Management:** Servers are monitored and managed using PM2 for stability and logging. ## Directory Structure ```plaintext . ├── docker-compose.yml # Docker Compose file for cluster deployment ├── mc-cluster-image/ # Minecraft cluster Docker image source │ ├── pm2/ # PM2 configuration files │ │ └── startServer.json # PM2 configuration for starting Minecraft server │ ├── connection_manager.js # Handles Holesail connection initialization │ ├── Dockerfile # Dockerfile for building the Minecraft server image │ ├── get_latest_fabric_version.js # Script to fetch the latest FabricMC version │ ├── mod-manager-installer.sh # Script to install the mod manager │ ├── start.sh # Startup script for the container │ ├── scripts/ # Additional utility scripts │ │ └── init-mod-manager.sh # Script to initialize the mod manager │ └── server.properties # Minecraft server configuration └── README.md # Project documentation ``` ## Prerequisites - **Docker**: Version 20.10 or higher - **Docker Compose**: Version 1.29 or higher - **Node.js**: Version 18 or higher (for FabricMC version scripts) ## Setup Instructions 1. **Clone the Repository:** ```bash git clone https://github.com/your-repo/minecraft-cluster.git cd minecraft-cluster ``` 2. **Build the Docker Image:** ```bash docker-compose build ``` 3. **Start the Cluster:** ```bash docker-compose up -d ``` 4. **Access Logs:** View logs for all servers using PM2: ```bash docker exec -it mc-server-1 pm2 log ``` 5. **Manage Mods:** The mod manager initializes automatically. To manage mods: ```bash docker exec -it mc-server-1 mod-manager add ``` ## Configuration ### `docker-compose.yml` Defines the cluster with unique **CONNECTION_STRING** environment variables for Holesail connections. ### `mc-cluster-image/Dockerfile` Builds the Minecraft server image with: - FabricMC installation - Mod manager setup - PM2 for process management ### `connection_manager.js` Initializes Holesail P2P connections for secure server communication. ## Scripts Overview - **`get_latest_fabric_version.js`**: Fetches the latest FabricMC server version. - **`mod-manager-installer.sh`**: Installs and compiles the mod manager from the source. - **`init-mod-manager.sh`**: Ensures the mod manager is initialized and restarts the servers. ## Managing the Cluster ### Add/Remove Servers To add or remove servers, edit `docker-compose.yml` and modify the `services` section. After making changes, restart the cluster: ```bash docker-compose down docker-compose up -d ``` ### Update FabricMC Version Edit the `RUN` command in the Dockerfile under `get_latest_fabric_version.js`: ```bash node /var/tools/scripts/get_latest_fabric_version.js ``` Rebuild the Docker image: ```bash docker-compose build ``` Restart the cluster: ```bash docker-compose up -d ``` ## Troubleshooting - **Holesail Connection Error**: Ensure `CONNECTION_STRING` is set and valid in `docker-compose.yml`. - **Mod Manager Issues**: Check the initialization logs in `mod-manager.init` and rerun `init-mod-manager.sh`.