This commit is contained in:
snxraven 2024-12-06 06:38:37 -05:00
parent c03877d469
commit b79c325086
9 changed files with 565 additions and 58 deletions

174
README.md
View File

@ -1 +1,173 @@
This is a test repo, you can igore it for now # Minecraft Cluster Deployment with Velocity Proxy and Holesail Integration
This master README consolidates all parts of the Minecraft Cluster setup using Docker. It includes deploying a Minecraft server cluster, configuring Velocity Proxy, and integrating Holesail for secure peer-to-peer connections.
---
## Overview
This project enables seamless deployment of a Minecraft server cluster with the following features:
- **Clustered Minecraft Servers:** Deployed using Docker Compose with FabricMC mod support.
- **Velocity Proxy:** Lightweight and flexible proxy for managing player connections.
- **Holesail Networking:** Secure peer-to-peer networking for connecting servers.
- **Mod Management:** Integrated mod management system for Minecraft servers.
- **PM2 Orchestration:** Manages processes and ensures stability.
---
## Prerequisites
- **Docker:** Version 20.10 or higher.
- **Docker Compose:** Version 1.29 or higher.
- **Node.js:** Version 18 or higher (for FabricMC version scripts and Holesail).
- **Basic Knowledge:** Understanding of Docker, Minecraft server administration, and basic Linux commands.
---
## Setup Instructions
### 1. Minecraft Host Node Setup
This step sets up the Minecraft cluster, consisting of multiple FabricMC servers.
1. **Clone the Repository:**
```bash
git clone https://git.ssh.surf/snxraven/mc-cluster.git
cd mc-cluster/mc-cluster-image
```
2. **Build the Minecraft Cluster Image:**
```bash
docker build . -t mc:cluster
```
3. **Navigate Back to the Main Directory:**
```bash
cd ..
```
4. **Start the Minecraft Cluster:**
```bash
docker-compose up -d
```
This will deploy a cluster of 4 Minecraft servers with unique Holesail connection strings.
---
### 2. JUMP Node Setup
The JUMP node hosts the Velocity proxy, managing player connections and routing traffic to the Minecraft cluster.
1. **Clone the Repository:**
```bash
git clone https://git.ssh.surf/snxraven/mc-cluster.git
cd mc-cluster/velocity-image
```
2. **Build the Velocity Proxy Image:**
```bash
docker build . -t velocity:proxy
```
3. **Start the Velocity Proxy:**
```bash
docker-compose up -d
```
---
## Configuration
### Holesail Connection Strings
To customize the Holesail connection strings:
1. **Edit the `pm2-setup.sh` File:**
```bash
cd mc-cluster/holesail-connector
nano pm2-setup.sh
```
Update the `connections` array with your desired connection strings and ports.
Example:
```bash
connections=(
["mc-server-1"]="5000"
["mc-server-2"]="5001"
)
```
2. **Modify the Docker Compose File:**
```bash
cd mc-cluster
nano docker-compose.yml
```
Update the `CONNECTION_STRING` and `PORT` environment variables for each Minecraft server.
---
## Managing the Cluster
### Logs and Debugging
- **View PM2 Logs for Minecraft Servers:**
```bash
docker exec -it mc-server-1 pm2 logs
```
- **View Velocity Proxy Logs:**
```bash
docker exec -it velocity-proxy pm2 logs
```
### Add or Remove Minecraft Servers
1. Edit the `docker-compose.yml` file in the root directory to add or remove server configurations.
2. Restart the cluster:
```bash
docker-compose down
docker-compose up -d
```
---
## Notes
1. **Ports and Connection Strings:** Ensure no conflicts with other services when configuring ports.
2. **Security:** Update `forwarding.secret` in the Velocity Proxy setup for secure player forwarding.
3. **Default Passwords:** Change the default root password (`noshallpass`) for better security.
---
## Directory Structure Overview
```plaintext
mc-cluster/
├── mc-cluster-image/
│ ├── Dockerfile
│ ├── pm2/
│ ├── scripts/
│ ├── server.properties
│ ├── get_latest_fabric_version.js
│ ├── mod-manager-installer.sh
│ └── start.sh
├── velocity-image/
│ ├── Dockerfile
│ ├── velocity.toml
│ ├── pm2/startServer.json
│ ├── start.sh
│ └── forwarding.secret
├── holesail-connector/
│ ├── Dockerfile
│ └── pm2-setup.sh
└── docker-compose.yml
```
---
## Future Extensions
- **Additional Nodes:** Add more Minecraft servers or JUMP nodes to scale the deployment.
- **Mod Automation:** Enhance the mod manager for auto-updating and downloading new mods.
- **Monitoring Tools:** Integrate monitoring tools like Netdata for better visibility into server performance.

View File

@ -0,0 +1,112 @@
# Dockerized Holesail with PM2 Orchestration
This project provides a pre-configured Docker container for running multiple Holesail processes orchestrated using PM2. Each process is assigned a specific connection string and port.
---
## Features
- **Ubuntu-based container**: Uses the latest `ubuntu` image as the base.
- **Node.js v20**: Includes the latest Node.js for running Holesail.
- **PM2 process management**: Manages multiple Holesail processes with ease.
- **Multi-port configuration**: Runs Holesail on multiple ports with predefined connection strings.
---
## Getting Started
### Prerequisites
- Docker installed on your system.
- Basic knowledge of Docker and PM2.
---
### Build the Docker Image
1. Clone this repository:
```bash
git clone <repository_url>
cd <repository_directory>
```
2. Build the Docker image:
```bash
docker build -t holesail-pm2 .
```
---
### Run the Container
Start the container:
```bash
docker run -d --name holesail-pm2-container holesail-pm2
```
This will:
- Install required dependencies.
- Start multiple Holesail processes using PM2 based on predefined connection strings and ports.
---
## Configuration
The `pm2-setup.sh` script defines the connection strings and ports. You can modify the `connections` array to suit your needs:
```bash
declare -A connections
connections=(
["<connection_string_1>"]=<port_1>
["<connection_string_2>"]=<port_2>
...
)
```
---
### Logs and Debugging
To view PM2 logs from the container:
```bash
docker exec -it holesail-pm2-container pm2 logs
```
To inspect the container:
```bash
docker exec -it holesail-pm2-container bash
```
---
## File Structure
```
.
├── Dockerfile # Docker configuration for building the image
├── pm2-setup.sh # PM2 setup script for launching Holesail processes
```
---
## Extending
To add more features:
1. Update the `pm2-setup.sh` file with additional PM2 configurations or commands.
2. Rebuild the Docker image:
```bash
docker build -t holesail-pm2 .
```
---
## Notes
- The `pm2-runtime` command ensures the container remains active as long as PM2 processes are running.
- Ports and connection strings must not conflict with existing services.

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# Define connection strings and ports # Define connection strings and ports
# MAKE SURE TO CHANGE THESE TO YOUR OWN CUSTOM STRINGS!
declare -A connections declare -A connections
connections=( connections=(
["8d4637169e8c7a86fd6cbfe5447af3c36746acf8f30e6c0717e7c04df8d4e1a3cf5e36dac34304f278aaed127169fa291075758aca7ddd001cbed444cd2b0f697a"]=8001 ["8d4637169e8c7a86fd6cbfe5447af3c36746acf8f30e6c0717e7c04df8d4e1a3cf5e36dac34304f278aaed127169fa291075758aca7ddd001cbed444cd2b0f697a"]=8001

114
mc-cluster-image/README.md Normal file
View File

@ -0,0 +1,114 @@
# 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 <mod_name>
```
## 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 <new_version>
```
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`.

View File

@ -1,62 +1,65 @@
# Use the latest Ubuntu image as base
FROM ubuntu:latest FROM ubuntu:latest
# Update OS and install deps # Set environment variables
RUN apt update && apt clean && apt upgrade -y
RUN apt install -y curl apt-utils sudo curl python3 python-is-python3 git wget nano openssh-server apt-transport-https zip
# Get JDK Ready
RUN wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /usr/share/keyrings/adoptium.asc
RUN echo "deb [signed-by=/usr/share/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
RUN cat /etc/apt/sources.list.d/adoptium.list
RUN sudo apt-get update
RUN apt update
# Install memory safe JDK
RUN DEBIAN_FRONTEND=noninteractive apt install temurin-21-jdk -y
# Download fabric server
# This needs to be changed to the version you wish to support.
RUN mkdir -vp /home/mc
RUN mkdir -vp /home/mc/minecraft
# Add a user
RUN useradd mc
# Let user use Bash
RUN usermod --shell /bin/bash mc
# Provide users ownership
RUN chown -R mc:mc /home/mc
ENV PATH="/usr/bin:$PATH" ENV PATH="/usr/bin:$PATH"
RUN apt-get install -y ca-certificates curl gnupg
RUN sudo mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
ENV NODE_MAJOR=18 ENV NODE_MAJOR=18
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update # Update OS and install essential dependencies
RUN apt-get install nodejs -y RUN apt-get update -y && apt-get upgrade -y && apt-get install -y \
curl \
apt-utils \
sudo \
python3 \
python-is-python3 \
git \
wget \
nano \
openssh-server \
apt-transport-https \
zip \
ca-certificates \
gnupg
# Add Adoptium GPG key and repository for JDK
RUN wget -qO- https://packages.adoptium.net/artifactory/api/gpg/key/public | tee /usr/share/keyrings/adoptium.asc && \
echo "deb [signed-by=/usr/share/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print $2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list && \
apt-get update -y
# Install memory-safe JDK
RUN apt-get install -y temurin-21-jdk
# Create directories for the Minecraft server
RUN mkdir -p /home/mc/minecraft
# Add and configure a new user for the server
RUN useradd -m -s /bin/bash mc && chown -R mc:mc /home/mc
# Add NodeSource repository and install Node.js
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update -y && apt-get install -y nodejs
# Install Holesail globally
RUN npm install -g holesail RUN npm install -g holesail
COPY pm2 /var/tools/pm2 # Download the Velocity server JAR
RUN wget -O /home/mc/minecraft/server.jar https://api.papermc.io/v2/projects/velocity/versions/3.4.0-SNAPSHOT/builds/454/downloads/velocity-3.4.0-SNAPSHOT-454.jar RUN wget -O /home/mc/minecraft/server.jar https://api.papermc.io/v2/projects/velocity/versions/3.4.0-SNAPSHOT/builds/454/downloads/velocity-3.4.0-SNAPSHOT-454.jar
# Set up tools, configurations, and permissions
RUN chmod +x -R /var/tools COPY pm2 /var/tools/pm2
RUN chmod +x -R /var/tools && npm install -g pm2
# Install PM2
RUN npm install pm2 -g
COPY velocity.toml /home/mc/minecraft COPY velocity.toml /home/mc/minecraft
COPY forwarding.secret /home/mc/minecraft
# Copy over start.sh to allow for backround run # Add and prepare the startup script
COPY start.sh /start.sh COPY start.sh /start.sh
RUN chmod +x /start.sh RUN chmod +x /start.sh
# Set root pass # Set the root password
RUN echo 'root:noshallpass' | chpasswd RUN echo 'root:noshallpass' | chpasswd
# Set the default command to start the server
ENTRYPOINT ["/bin/bash", "/start.sh"] ENTRYPOINT ["/bin/bash", "/start.sh"]

109
velocity-image/README.md Normal file
View File

@ -0,0 +1,109 @@
# Velocity Minecraft Proxy with Holesail Integration
This repository contains a Docker-based setup for running a Velocity Minecraft Proxy integrated with Holesail for peer-to-peer connections. The setup uses Velocity for managing Minecraft server connections and Holesail for managing secure connections to backend servers.
---
## Features
- **Velocity Proxy**: Lightweight and flexible proxy for Minecraft servers.
- **Holesail Integration**: Seamlessly integrates Holesail for peer-to-peer connections.
- **Node.js and PM2**: Manages the Minecraft proxy process with ease.
- **Ubuntu Base**: Secure and updated environment using the latest Ubuntu image.
- **Modular Setup**: Easily configurable Docker setup for various services.
---
## Prerequisites
- Docker and Docker Compose installed on the host system.
- Basic understanding of Docker and Minecraft server administration.
---
## Folder Structure
```
.
├── Dockerfile # Sets up the environment and configures the Velocity proxy.
├── pm2/startServer.json # PM2 configuration to manage the Minecraft server process.
├── start.sh # Shell script to start the Velocity proxy.
├── velocity.toml # Configuration file for the Velocity proxy.
├── forwarding.secret # Secret file for secure communication (currently empty).
├── docker-compose.yml # Docker Compose file for service orchestration.
```
---
## Getting Started
### Clone the Repository
```bash
git clone https://github.com/your-repo/velocity-image.git
cd velocity-image
```
### Build and Run the Docker Containers
1. **Build the Holesail connector image**:
```bash
cd ../holesail-connector
docker build -t holesail-connector .
```
2. **Navigate back to the Velocity directory**:
```bash
cd ../velocity-image
```
3. **Run the services with Docker Compose**:
```bash
docker-compose up -d
```
---
## Configuration
- **`velocity.toml`**:
- Modify the `bind` setting to change the proxy's listening address and port.
- Update the `motd` to customize the server's display message.
- Add or update server configurations under `[servers]` and `[forced-hosts]`.
- **PM2 Configuration (`pm2/startServer.json`)**:
- Modify the JVM options in the `script` field to adjust memory or garbage collection settings.
- **Holesail**:
- The Holesail connector is pre-configured. For custom configurations, refer to the [Holesail documentation](https://your-holesail-docs-url).
---
## Usage
- **Access Logs**:
View the PM2 logs:
```bash
docker exec -it volicy-proxy su - mc -c "pm2 log"
```
- **Restart the Proxy**:
```bash
docker restart volicy-proxy
```
- **Stop All Services**:
```bash
docker-compose down
```
---
## Notes
- Ensure `forwarding.secret` is configured for secure player forwarding if needed.
- Default root password is `noshallpass`. Change it for better security.
- Modify the `max_restarts` in the `pm2/startServer.json` file if you need more restart attempts.
---

View File

@ -6,15 +6,11 @@ services:
context: ../holesail-connector context: ../holesail-connector
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: holesail-connections container_name: holesail-connections
ports: network_mode: host
- "8001:8001"
- "8002:8002"
- "8003:8003"
- "8004:8004"
volicy-proxy: volicy-proxy:
image: velocity:proxy image: velocity:proxy
container_name: volicy-proxy container_name: volicy-proxy
ports: ports:
- "25565" - "25565:25565"

View File

@ -13,7 +13,7 @@ motd = "<#09add3>A Velocity Server"
show-max-players = 500 show-max-players = 500
# Should we authenticate players with Mojang? By default, this is on. # Should we authenticate players with Mojang? By default, this is on.
online-mode = true online-mode = false
# Should the proxy enforce the new public key security standard? By default, this is on. # Should the proxy enforce the new public key security standard? By default, this is on.
force-key-authentication = true force-key-authentication = true
@ -38,7 +38,7 @@ player-info-forwarding-mode = "NONE"
# If you are using modern or BungeeGuard IP forwarding, configure a file that contains a unique secret here. # If you are using modern or BungeeGuard IP forwarding, configure a file that contains a unique secret here.
# The file is expected to be UTF-8 encoded and not empty. # The file is expected to be UTF-8 encoded and not empty.
forwarding-secret-file = "forwarding.secret" #forwarding-secret-file = "forwarding.secret"
# Announce whether or not your server supports Forge. If you run a modded server, we # Announce whether or not your server supports Forge. If you run a modded server, we
# suggest turning this on. # suggest turning this on.
@ -72,10 +72,10 @@ enable-player-address-logging = true
[servers] [servers]
# Configure your servers here. Each key represents the server's name, and the value # Configure your servers here. Each key represents the server's name, and the value
# represents the IP address of the server to connect to. # represents the IP address of the server to connect to.
lobby = "127.0.0.1:8001" lobby = "ssh.surf:8001"
factions = "127.0.0.1:8002" factions = "ssh.surf:8002"
minigames = "127.0.0.1:8003" minigames = "ssh.surf:8003"
idk = "127.0.0.1:8004" idk = "ssh.surf:8004"
# In what order we should try servers when a player logs in or is kicked from a server. # In what order we should try servers when a player logs in or is kicked from a server.
try = [ try = [