Compare commits

..
10 Commits
5 changed files with 168 additions and 60 deletions

No files matched your search

+4 -4
View File
@@ -28,11 +28,11 @@ ARG APPS_REV=1
ARG GITHUB_BASEURL=https://github.com
# renovate: datasource=github-releases packageName=itzg/easy-add
ARG EASY_ADD_VERSION=0.8.17
ARG EASY_ADD_VERSION=0.8.19
ADD --chmod=755 ${GITHUB_BASEURL}/itzg/easy-add/releases/download/${EASY_ADD_VERSION}/easy-add_${TARGETOS}_${TARGETARCH}${TARGETVARIANT} /usr/bin/easy-add
# renovate: datasource=github-releases packageName=itzg/entrypoint-demoter
ARG ENTRYPOINT_DEMOTER_VERSION=0.5.1
ARG ENTRYPOINT_DEMOTER_VERSION=0.5.3
RUN easy-add --var version=${ENTRYPOINT_DEMOTER_VERSION} --var app=entrypoint-demoter --file {{.app}} --from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/v{{.version}}/{{.app}}_{{.version}}_linux_${TARGETARCH}.tar.gz
# renovate: datasource=github-releases packageName=itzg/set-property
@@ -40,13 +40,13 @@ ARG SET_PROPERTY_VERSION=0.1.6
RUN easy-add --var version=${SET_PROPERTY_VERSION} --var app=set-property --file {{.app}} --from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_linux_${TARGETARCH}.tar.gz
# renovate: datasource=github-releases packageName=itzg/mc-monitor
ARG MC_MONITOR_VERSION=1.18.2
ARG MC_MONITOR_VERSION=1.19.0
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=${MC_MONITOR_VERSION} --var app=mc-monitor --file {{.app}} \
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
# renovate: datasource=github-releases packageName=itzg/mc-server-runner
ARG MC_SERVER_RUNNER_VERSION=1.16.0
ARG MC_SERVER_RUNNER_VERSION=1.16.2
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=${MC_SERVER_RUNNER_VERSION} --var app=mc-server-runner --file {{.app}} \
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
+51 -9
View File
@@ -9,7 +9,8 @@
Bedrock Dedicated Server (BDS) version 1.26.50 and later uses the newer NetherNet transport by default.
Clients connect to TCP port 19132 first. Then each client uses a UDP port for gameplay.
The following starts a server on a LAN. Replace `192.168.1.10` with the IP address of the Docker host:
The following starts a server on a LAN. Replace `192.168.1.10` with the IP address of the Docker host.
Alternatively, you can use `<public_ip>` in place of an ip address to resolve to your public ip at startup.
```bash
docker run -d -it -e EULA=TRUE \
@@ -190,14 +191,43 @@ During the handshake, BDS sends the client a list of addresses and UDP ports. Th
- With `network_mode: host`, BDS sends the addresses of the host. Set only the port range, for example `SERVER_UDP_PORTS: "19140-19155"`.
- With a Docker bridge network, rootless networking or NAT, BDS can send addresses that the client cannot reach. Set the address that clients use, for example `SERVER_UDP_PORTS: "192.168.1.10:19140-19155:19140-19155"`.
- IMPORTANT: to access over the internet you need to use the public ip in the `SERVER_UDP_PORTS`, and forward all the ports.
Use an IPv4 or IPv6 literal, not a hostname.
To use the public IP address of the host, use the literal string `<public_ip>`. At startup, the image replaces it with the result of `curl ifconfig.me`.
Use a range with at least one port for each player (`max-players`, default 10).
Publish the TCP port and the full UDP range.
For an example, see [examples/nethernet/compose.yml](examples/nethernet/compose.yml).
### Using placeholder for public IP
Use one of the following placeholders in `SERVER_UDP_PORTS` to have the container resolve your public IP at startup using https://www.ipify.org/:
- `<public_ip>` : resolves to either IPv4 or IPv6, whichever is resolved by the universal lookup
- `<public_ipv4>` : resolves to IPv4 only
- `<public_ipv6>` : resolves to IPv6 only
### From Mojang's docs regarding SERVER_UDP_PORTS
```
Configures UDP client transport ports.
This property is ignored when `transport=raknet`.
If not set, UDP ports are allocated from the operating system's ephemeral port range.
Two modes are supported:
1. Single UDP port shared by all clients.
2. UDP port range, where client connections are distributed across a range of ports but will reuse ports if the range is exhausted.
Both modes support either the same local and public port values or a public:local mapping. Ranges on each side of `:` must be the same length.
Optionally, specify the public IP address using IP:public:local (IPv4) or [IPv6]:public:local (IPv6).
Both port values are required with an IP prefix, even when they are the same.
Examples:
server-udp-ports=19489 (Single UDP port shared by all clients, local and public values are the same)
server-udp-ports=29489:19489 (Single UDP port shared by all clients, public port:29489 must map to local port:19489)
server-udp-ports=19400-19500 (UDP port range, local and public values are the same)
server-udp-ports=21200-21300:19400-19500 (UDP port range, public port range: 21200-21300 must map to local port range: 19400-19500)
server-udp-ports=12.19.20.18:19489:19489 (Single UDP port with public IP, 12.19.20.18:19489 must map to the server's local UDP port 19489)
server-udp-ports=[2001:db8::2021:26:03]:21200-21300:19400-19500
(UDP port range with public IP, [2001:db8::2021:26:03]:21200-21300 must map to the server's local UDP ports 19400-19500)
```
### Firewall
On the host firewall and on all network firewalls between the clients and the server, allow these inbound connections:
@@ -235,9 +265,8 @@ BDS 1.26.51 logs an error that NetherNet is the only supported transport.
## IPv6 same-port fix
> **NOTE**: This fix applies only to `TRANSPORT=raknet`. Do not use it with NetherNet.
> The shim changes each IPv6 socket that binds to `SERVER_PORT_V6`, which includes the NetherNet TCP socket.
> If `SERVER_PORT_V6` is equal to `SERVER_PORT`, the TCP socket becomes IPv6-only, and IPv4 clients cannot connect.
> **NOTE**: This fix is only needed with the legacy `TRANSPORT=raknet`. With NetherNet the shim is inert:
> it acts on UDP sockets only and leaves the NetherNet TCP socket untouched, so it can stay enabled.
BDS binds IPv4 and IPv6 on separate ports by default (19132 and 19133).
Bedrock clients do not implement Happy Eyeballs, so a player whose device
@@ -456,10 +485,12 @@ When finished, detach from the server console using Ctrl-p, Ctrl-q
## Deploying with Docker Compose
The [examples](examples) directory contains [an example Docker compose file](examples/docker-compose.yml) that declares:
- a service running the bedrock server container and exposing TCP port 19132 and UDP ports 19140-19155 for NetherNet. In the example is named "bds", short for "Bedrock Dedicated Server", but you can name the service whatever you want
- a volume attached to the service at the container path `/data`
Replace `192.168.1.10` with the IP address of the Docker host. For more information, see [NetherNet](#nethernet).
- A service running the bedrock server container. In the example is named "bds", short for "Bedrock Dedicated Server", but you can name the service whatever you want.
- The service exposes TCP port 19132 and UDP ports 19140-19155 for NetherNet. For more information, see [NetherNet](#nethernet).
- For LAN only: Replace `192.168.1.10` with the IP address of the Docker host.
- For Internet: Replace `192.168.1.10` with a static public IP address, or `<public_ip>` to look up your current IP at startup.
- EULA must be true, other env variables can be defined to configure the server here as well.
- A volume attached to the service at the container path `/data`
```yaml
services:
@@ -468,6 +499,8 @@ services:
environment:
EULA: "TRUE"
# NetherNet: replace 192.168.1.10 with the IP address of the Docker host
# If this server is meant to be accessible over the internet, and has a dynamic you
# can use "<public_ip>" in place of an ip address to resolve your public ip on startup
SERVER_UDP_PORTS: "192.168.1.10:19140-19155:19140-19155"
ports:
# Note the newer NetherNet protocol uses different ports to RakNet
@@ -491,6 +524,15 @@ You can follow the logs at any time using:
docker compose logs -f
```
## Deploying with Easypanel
[Easypanel](https://easypanel.io) is a self-hosted Docker deployment platform, and this image has a one-click deployment template there (Minecraft Bedrock Server):
[![Deploy on Easypanel][easypanel-btn]][easypanel-deploy]
[easypanel-btn]: https://easypanel.io/img/deploy-on-easypanel-40.svg
[easypanel-deploy]: https://easypanel.io/templates/minecraft-server-bedrock
## Deploying with Kubernetes
The [examples](examples) directory contains [an example Kubernetes manifest file](examples/kubernetes.yml) that declares:
+104 -47
View File
@@ -21,13 +21,18 @@ function isTrue() {
return 1
}
function logInfo() {
msg="${1?}"
echo "INFO $msg"
}
function logWarn() {
msg=${1?}
msg="${1?}"
echo "WARN $msg" >&2
}
function logError() {
msg=${1?}
msg="${1?}"
echo "ERROR $msg" >&2
}
@@ -166,6 +171,102 @@ function extractVersionFromUrl() {
fi
}
function isIPv6() {
ip=${1:?}
if [[ $ip =~ ^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$ ]]; then
return 0
else
return 1
fi
}
function formatIpPart() {
ip=${1:?}
if isIPv6 "$ip"; then
echo "[$ip]"
else
echo "$ip"
fi
}
## @param placeholder The placeholder to replace (e.g., <public_ip>, <public_ipv4>, <public_ipv6>)
## @param publicIp The public IP address to replace the placeholder with. If empty, which will be the case if ipify is unable to resolve the requested address, the function will log an error and exit.
function replaceIpPlaceholder() {
local placeholder="${1:?}"
local publicIp="$2"
if [[ -z "$publicIp" ]]; then
logError "Unable to resolve public IP for ${placeholder}"
exit 1
fi
logInfo "Replacing ${placeholder} with ${publicIp} in SERVER_UDP_PORTS"
SERVER_UDP_PORTS="${SERVER_UDP_PORTS//${placeholder}/$(formatIpPart "$publicIp")}"
export SERVER_UDP_PORTS
}
## Evaluates the SERVER_UDP_PORTS environment variable and replaces the following placeholders:
## - <public_ip> with the public IP address (IPv4 or IPv6) of the server
## - <public_ipv4> with the public IPv4 address of the server
## - <public_ipv6> with the public IPv6 address of the server
## If one of the specific placeholders does not resolve, then the startup will exit
function manageServerUdpPorts() {
if [[ "$SERVER_UDP_PORTS" == *"<public_ip>"* ]]; then
replaceIpPlaceholder "<public_ip>" "$(curl -s https://api64.ipify.org)"
elif [[ "$SERVER_UDP_PORTS" == *"<public_ipv4>"* ]]; then
replaceIpPlaceholder "<public_ipv4>" "$(curl -s https://api.ipify.org)"
elif [[ "$SERVER_UDP_PORTS" == *"<public_ipv6>"* ]]; then
replaceIpPlaceholder "<public_ipv6>" "$(curl -s https://api6.ipify.org)"
fi
}
function manageProperties() {
manageServerUdpPorts
if [[ -n "$VARIABLES" ]]; then
echo "Setting variables"
mkdir -p config/default
# Try to parse VARIABLES as JSON
if echo "$VARIABLES" | jq empty >/dev/null 2>&1; then
# VARIABLES is valid JSON
echo "$VARIABLES" | jq '.' > "config/default/variables.json"
else
# VARIABLES is not valid JSON, attempt to parse as custom format
echo "VARIABLES is not valid JSON, attempting to parse as custom format"
# Parse the VARIABLES using custom format (key:value,key:value)
# Note: Values should not contain unescaped commas or colons
jq -n --arg vars "$VARIABLES" '
$vars
| split("[,\\n]+"; "")
| map(
select(length>0) |
split("=") as $kv |
{ ($kv[0]): ($kv[1] | fromjson? // $kv[1]) }
)
| add
' > "config/default/variables.json"
fi
fi
if [ -f server.properties ]; then
# prevent issue with bind mounted server.properties which can not be moved (sed tries to move the file when '-i' is used)
_SERVER_PROPERTIES=$(sed '/^white-list=.*/d' server.properties) #Removes white-list= line from server.properties
echo "${_SERVER_PROPERTIES}" > server.properties
fi
export ALLOW_LIST
# update server.properties with environment settings
set-property --file server.properties --bulk /etc/bds-property-definitions.json
}
#######################################################################################################################
# MAIN
#######################################################################################################################
echo "Image info: $(paste -d, -s /etc/image.properties)"
debugCurlArgs=()
@@ -445,51 +546,7 @@ if [[ -n "$ALLOW_LIST_USERS" || -n "$WHITE_LIST_USERS" ]]; then
fi
fi
if [[ "$SERVER_UDP_PORTS" == *"<public_ip>"* ]]; then
echo "Replacing <public_ip> in $SERVER_UDP_PORTS"
public_ip=$(curl -s ifconfig.me)
echo "Public IP resolved to: $public_ip"
SERVER_UDP_PORTS="${SERVER_UDP_PORTS//<public_ip>/$public_ip}"
export SERVER_UDP_PORTS
fi
if [[ -n "$VARIABLES" ]]; then
echo "Setting variables"
mkdir -p config/default
# Try to parse VARIABLES as JSON
if echo "$VARIABLES" | jq empty >/dev/null 2>&1; then
# VARIABLES is valid JSON
echo "$VARIABLES" | jq '.' > "config/default/variables.json"
else
# VARIABLES is not valid JSON, attempt to parse as custom format
echo "VARIABLES is not valid JSON, attempting to parse as custom format"
# Parse the VARIABLES using custom format (key:value,key:value)
# Note: Values should not contain unescaped commas or colons
jq -n --arg vars "$VARIABLES" '
$vars
| split("[,\\n]+"; "")
| map(
select(length>0) |
split("=") as $kv |
{ ($kv[0]): ($kv[1] | fromjson? // $kv[1]) }
)
| add
' > "config/default/variables.json"
fi
fi
if [ -f server.properties ]; then
# prevent issue with bind mounted server.properties which can not be moved (sed tries to move the file when '-i' is used)
_SERVER_PROPERTIES=$(sed '/^white-list=.*/d' server.properties) #Removes white-list= line from server.properties
echo "${_SERVER_PROPERTIES}" > server.properties
fi
export ALLOW_LIST
# update server.properties with environment settings
set-property --file server.properties --bulk /etc/bds-property-definitions.json
manageProperties
export LD_LIBRARY_PATH=.
+2
View File
@@ -4,6 +4,8 @@ services:
environment:
EULA: "TRUE"
# NetherNet: replace 192.168.1.10 with the IP address of the Docker host
# If this server is meant to be accessible over the internet, and has a dynamic you
# can use "<public_ip>" in place of an ip address to resolve your public ip on startup
SERVER_UDP_PORTS: "192.168.1.10:19140-19155:19140-19155"
ports:
# Note the newer NetherNet protocol uses different ports to RakNet
+7
View File
@@ -12,5 +12,12 @@
]
}
],
"packageRules": [
{
"matchManagers": ["custom.regex"],
"matchUpdateTypes": ["patch"],
"groupName": "Dockerfile patch updates"
}
],
"labels": ["dependencies"]
}