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

View File

@ -1,62 +1,65 @@
# Use the latest Ubuntu image as base
FROM ubuntu:latest
# Update OS and install deps
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
# Set environment variables
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
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
RUN apt-get install nodejs -y
# Update OS and install essential dependencies
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
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 chmod +x -R /var/tools
# Install PM2
RUN npm install pm2 -g
# Set up tools, configurations, and permissions
COPY pm2 /var/tools/pm2
RUN chmod +x -R /var/tools && npm install -g pm2
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
RUN chmod +x /start.sh
# Set root pass
# Set the root password
RUN echo 'root:noshallpass' | chpasswd
# Set the default command to start the server
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
dockerfile: Dockerfile
container_name: holesail-connections
ports:
- "8001:8001"
- "8002:8002"
- "8003:8003"
- "8004:8004"
network_mode: host
volicy-proxy:
image: velocity:proxy
container_name: volicy-proxy
ports:
- "25565"
- "25565:25565"

View File

View File

@ -13,7 +13,7 @@ motd = "<#09add3>A Velocity Server"
show-max-players = 500
# 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.
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.
# 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
# suggest turning this on.
@ -72,10 +72,10 @@ enable-player-address-logging = true
[servers]
# Configure your servers here. Each key represents the server's name, and the value
# represents the IP address of the server to connect to.
lobby = "127.0.0.1:8001"
factions = "127.0.0.1:8002"
minigames = "127.0.0.1:8003"
idk = "127.0.0.1:8004"
lobby = "ssh.surf:8001"
factions = "ssh.surf:8002"
minigames = "ssh.surf:8003"
idk = "ssh.surf:8004"
# In what order we should try servers when a player logs in or is kicked from a server.
try = [