Skip to content

Commit 703fb0d

Browse files
Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/19601207222
2 parents 373f059 + 9333a87 commit 703fb0d

File tree

11 files changed

+303
-21
lines changed

11 files changed

+303
-21
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Docker image CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-22.04
10+
11+
steps:
12+
- uses: actions/checkout@v5
13+
with:
14+
submodules: true #needed for build/php submodule
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Create data directories
20+
run: |
21+
mkdir ./docker/test_data
22+
sudo chown -R 1000:1000 ./docker/testsuite ./docker/test_data
23+
24+
- name: Build image for tag
25+
uses: docker/[email protected]
26+
with:
27+
context: ${{ github.workspace }}
28+
push: false
29+
load: true
30+
file: ${{ github.workspace }}/docker/Dockerfile
31+
tags: local-pocketmine-mp
32+
build-args: |
33+
GIT_HASH=${{ github.sha }}
34+
cache-from: type=gha
35+
cache-to: type=gha,mode=max
36+
37+
- name: Test if it runs the normal server properly
38+
run: echo stop | docker run --rm -i -e POCKETMINE_ARGS="--settings.enable-dev-builds=1" local-pocketmine-mp
39+
40+
- name: Test if it loads plugins
41+
run: |
42+
echo stop | docker run --rm -i -v ./docker/test_data:/data -v ./docker/testsuite/create-data:/plugins -e POCKETMINE_ARGS="--settings.enable-dev-builds=1" local-pocketmine-mp
43+
test -f ./docker/test_data/plugin_data/data-test/create-data
44+
test "$(cat ./docker/test_data/plugin_data/data-test/create-data)" = "successful"
45+
46+
- name: Test if it persists plugin data
47+
run: echo stop | docker run --rm -i -v ./docker/test_data:/data -v ./docker/testsuite/verify-data:/plugins -e POCKETMINE_ARGS="--settings.enable-dev-builds=1" local-pocketmine-mp

.github/workflows/build-docker-image.yml renamed to .github/workflows/docker-image-publish.yml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ jobs:
1616
runs-on: ubuntu-22.04
1717

1818
steps:
19+
- uses: actions/checkout@v5
20+
with:
21+
submodules: true #needed for build/php submodule
22+
1923
- name: Set up Docker Buildx
2024
uses: docker/setup-buildx-action@v3
2125

@@ -32,13 +36,6 @@ jobs:
3236
username: ${{ github.actor }}
3337
password: ${{ secrets.GITHUB_TOKEN }}
3438

35-
- name: Clone pmmp/PocketMine-Docker repository
36-
uses: actions/checkout@v5
37-
with:
38-
repository: pmmp/PocketMine-Docker
39-
fetch-depth: 1
40-
41-
4239
- name: Get tag name
4340
id: tag-name
4441
run: |
@@ -73,49 +70,45 @@ jobs:
7370
uses: docker/[email protected]
7471
with:
7572
push: true
76-
context: ./pocketmine-mp
73+
file: ./docker/Dockerfile
7774
tags: |
7875
${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.tag-name.outputs.TAG_NAME }}
7976
ghcr.io/${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.tag-name.outputs.TAG_NAME }}
8077
build-args: |
81-
PMMP_TAG=${{ steps.tag-name.outputs.TAG_NAME }}
82-
PMMP_REPO=${{ github.repository }}
78+
GIT_HASH=${{ github.sha }}
8379
8480
- name: Build image for major tag
8581
if: steps.channel.outputs.CHANNEL == 'stable'
8682
uses: docker/[email protected]
8783
with:
8884
push: true
89-
context: ./pocketmine-mp
85+
file: ./docker/Dockerfile
9086
tags: |
9187
${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.version.outputs.MAJOR }}
9288
ghcr.io/${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.version.outputs.MAJOR }}
9389
build-args: |
94-
PMMP_TAG=${{ steps.tag-name.outputs.TAG_NAME }}
95-
PMMP_REPO=${{ github.repository }}
90+
GIT_HASH=${{ github.sha }}
9691
9792
- name: Build image for minor tag
9893
if: steps.channel.outputs.CHANNEL == 'stable'
9994
uses: docker/[email protected]
10095
with:
10196
push: true
102-
context: ./pocketmine-mp
97+
file: ./docker/Dockerfile
10398
tags: |
10499
${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.version.outputs.MINOR }}
105100
ghcr.io/${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.version.outputs.MINOR }}
106101
build-args: |
107-
PMMP_TAG=${{ steps.tag-name.outputs.TAG_NAME }}
108-
PMMP_REPO=${{ github.repository }}
102+
GIT_HASH=${{ github.sha }}
109103
110104
- name: Build image for latest tag
111105
if: steps.channel.outputs.CHANNEL == 'stable'
112106
uses: docker/[email protected]
113107
with:
114108
push: true
115-
context: ./pocketmine-mp
109+
file: ./docker/Dockerfile
116110
tags: |
117111
${{ steps.docker-repo-name.outputs.NAME }}:latest
118112
ghcr.io/${{ steps.docker-repo-name.outputs.NAME }}:latest
119113
build-args: |
120-
PMMP_TAG=${{ steps.tag-name.outputs.TAG_NAME }}
121-
PMMP_REPO=${{ github.repository }}
114+
GIT_HASH=${{ github.sha }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ memory_dumps/*
1717
resource_packs/
1818
server.lock
1919
/phpstan.neon
20+
/docker/test_data/
2021

2122
# Common IDEs
2223
.idea/*

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
url = https://github.com/pmmp/php-build-scripts.git
44
[submodule "examples/plugins/ExamplePlugin"]
55
path = examples/plugins/ExamplePlugin
6-
url = git@github.com:pmmp/ExamplePlugin.git
6+
url = https://github.com/pmmp/ExamplePlugin.git

changelogs/5.37.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@ Released 21st November 2025.
3535
## Documentation
3636
- Added folder and script plugin examples in the `examples/plugins` folder. (@dktapps)
3737
- Fixed missing mention of removal of `@softDepend` event handler tag in 4.0.0 changelog. (@dktapps)
38+
39+
# 5.37.3
40+
Released 21st November 2025.
41+
42+
## Fixes
43+
- Fixed Docker image build due to bad submodule reference.

docker/Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#PHP is built in a separate image from PM, so that we don't need to rebuild the entire Dockerfile whenever one src file changes
2+
FROM ubuntu:22.04 AS build-php
3+
ARG COMPILE_SH_ARGS="-f -g -P5"
4+
5+
RUN apt-get update && apt-get install --no-install-recommends -y curl ca-certificates build-essential m4 gzip bzip2 bison git cmake autoconf automake pkg-config libtool libtool-bin re2c
6+
7+
RUN mkdir /pocketmine
8+
COPY ./build/php/compile.sh /pocketmine
9+
WORKDIR /pocketmine
10+
RUN ./compile.sh -t linux64 -j ${THREADS:-$(grep -E ^processor /proc/cpuinfo | wc -l)} ${COMPILE_SH_ARGS}
11+
12+
FROM ubuntu:22.04 AS build-pocketmine
13+
ARG GIT_HASH=""
14+
RUN test ! -z ${GIT_HASH} || (echo "Missing build-arg GIT_HASH" && false)
15+
16+
RUN apt-get update && apt-get install --no-install-recommends -y curl ca-certificates 7zip
17+
RUN mkdir /pocketmine
18+
COPY --from=build-php /pocketmine/bin /pocketmine/bin
19+
RUN ln -s /pocketmine/bin/php7/bin/php /usr/bin/php
20+
RUN curl -L https://getcomposer.org/installer | php
21+
RUN mv composer.phar /usr/bin/composer
22+
23+
COPY ./build/server-phar.php ./build/server-phar-stub.php /pocketmine/repo/build/
24+
COPY ./resources /pocketmine/repo/resources
25+
COPY ./src /pocketmine/repo/src
26+
COPY ./composer.json ./composer.lock /pocketmine/repo/
27+
28+
WORKDIR /pocketmine/repo
29+
RUN composer install --classmap-authoritative --no-dev --prefer-dist
30+
RUN php vendor/pocketmine/bedrock-data/.minify_json.php
31+
RUN php -dphar.readonly=0 ./build/server-phar.php --git ${GIT_HASH}
32+
# Just to make sure the build script didn't false-positive-exit
33+
RUN test -f /pocketmine/repo/PocketMine-MP.phar
34+
35+
FROM ubuntu:22.04
36+
LABEL maintainer="PMMP Team <[email protected]>"
37+
38+
RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates wget
39+
40+
RUN groupadd -g 1000 pocketmine
41+
RUN useradd -r -d /pocketmine -p "" -u 1000 -m -g pocketmine pocketmine
42+
43+
WORKDIR /pocketmine
44+
COPY --from=build-php /pocketmine/bin /pocketmine/bin
45+
RUN ln -s /pocketmine/bin/php7/bin/php /usr/bin/php
46+
COPY --from=build-pocketmine /pocketmine/repo/PocketMine-MP.phar PocketMine-MP.phar
47+
ADD ./docker/start.sh /usr/bin/start-pocketmine
48+
49+
RUN mkdir /plugins /data
50+
RUN chown 1000:1000 /plugins /data . -R
51+
RUN chmod o+x /usr/bin/php
52+
53+
USER pocketmine
54+
55+
ENV TERM=xterm
56+
57+
EXPOSE 19132/tcp
58+
EXPOSE 19132/udp
59+
EXPOSE 19133/udp
60+
61+
VOLUME ["/data", "/plugins"]
62+
63+
CMD ["start-pocketmine"]

docker/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# PocketMine-MP Docker image
2+
This folder contains the files used to build and test the `pmmp/pocketmine-mp` Docker image.
3+
4+
Docker is an easy, safe way to run software in a container where it can't affect anything else on your machine.
5+
You don't need to build any dependencies, and updating is as simple as changing the version number of the image you're using.
6+
7+
## Pre-requisites
8+
To install Docker, refer to the [official Docker docs](https://docs.docker.com/engine/install/).
9+
10+
## Running PocketMine-MP from Docker (using Docker Hub)
11+
This is really easy once you have `docker` installed.
12+
13+
```
14+
mkdir wherever-you-want
15+
cd wherever-you-want
16+
mkdir data plugins
17+
sudo chown -R 1000:1000 data plugins
18+
docker run -it -p 19132:19132/udp -v $PWD/data:/data -v $PWD/plugins:/plugins ghcr.io/pmmp/pocketmine-mp
19+
```
20+
21+
To run a specific version, just add it to the end of the command, like this:
22+
```
23+
docker run -it -p 19132:19132/udp -v $PWD/data:/data -v $PWD/plugins:/plugins ghcr.io/pmmp/pocketmine-mp:4.0.0
24+
```
25+
26+
## Changing the server port
27+
Docker allows you to map ports, so you don't need to edit `server.properties`.
28+
29+
In the run command shown above, change `19132:19132/udp` to `<port number you want>:19132/udp`. **Note: Do not change the second number.**
30+
31+
> [!WARNING]
32+
> Do not change the port in `server.properties`. This is unnecessary when using Docker and will make things more complicated.
33+
34+
## Editing the server data
35+
The server data (e.g. worlds, `server.properties`, etc.) will be stored in the `data` folder you created above.
36+
37+
**Note: If you add new files (e.g. a world), don't forget to change the ownership of the file/folder to `1000:1000`**:
38+
```
39+
sudo chown -R 1000:1000 <file/folder you added>
40+
```
41+
This is needed to make the server able to access the file/folder.
42+
43+
## Adding plugins
44+
Plugins can be added by putting them in `plugins` folder you created earlier.
45+
46+
47+
**Note: If you add new files, don't forget to change the ownership of the file/folder to `1000:1000`:
48+
```
49+
sudo chown -R 1000:1000 <file/folder you added>
50+
```
51+
This is needed to make the server able to access the file/folder.
52+
53+
## Run the server in the background
54+
To run the server in the background, simply change `-it` to `-itd` in the last command above.
55+
This will run the server in the background even if you closed console. (No need to `screen`/`tmux` anymore!)
56+
57+
### Opening the console of the server
58+
Use `docker ps` to see a list of running containers. It will look like this:
59+
```
60+
user@DYLANS-PC:~/pm-docker-test$ docker ps
61+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62+
dc20edd3dd62 pmmp/pocketmine-mp:4.0.0 "start-pocketmine" 7 seconds ago Up 6 seconds 19132/tcp, 0.0.0.0:19132-19133->19132-19133/udp, :::19132-19133->19132-19133/udp brave_dijkstra
63+
```
64+
In this case, the container name is `brave_dijkstra`, but it might be something else in your case.
65+
66+
To open the console, run the following command:
67+
68+
```
69+
docker attach <container name you saw in docker ps>
70+
```
71+
72+
To leave the console, just press `Ctrl p` `Ctrl q`.
73+
74+
### Viewing the logs
75+
To see the logs, run the following command:
76+
```
77+
docker logs --tail=100 <container name you saw in docker ps>
78+
```
79+
Change `--tail=100` to the number of recent lines in the log you want to see.
80+
81+
## Adding plugins from Poggit
82+
If the `$POCKETMINE_PLUGINS` is set, the container will auto-download the plugins specified from https://poggit.pmmp.io
83+
before starting PocketMine-MP.
84+
85+
The list of plugins should be given in the format `PluginOne:1.2.3 PluginTwo:4.5.6`. The version part (`:4.5.6`) is optional.
86+
87+
> [!CAUTION]
88+
> Plugins won't be redownloaded if they're already in the `plugins` volume, even if the version is different.
89+
> If you need to update a plugin, you'll need to delete the old plugin `.phar` first.
90+
91+
## Volumes
92+
- `/data` is a read-write data directory where PocketMine stores all data in.
93+
This includes PocketMine config files, player data, worlds and plugin config files/data.
94+
- `/plugins` is a read-only data directory where PocketMine loads plugins from.
95+
96+
## Advanced usage: Passing args to PocketMine-MP.phar inside the container
97+
The `POCKETMINE_ARGS` environment variable will be passed to `PocketMine-MP.phar` when run.
98+
99+
## Building this image
100+
The Dockerfile requires a build-arg `GIT_HASH` to fill the git hash metadata when building `PocketMine-MP.phar`.
101+
This ensures that `/version`, crash reports, logs etc. report the correct server version.

docker/start.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Detect unowned files (this is a common docker issue)
6+
BAD_COUNT=$(find /data /plugins ! -user pocketmine | wc -l)
7+
if [ "$BAD_COUNT" -gt 0 ]; then
8+
echo "=== WARNING ==="
9+
echo "Detected $BAD_COUNT files in /data or /plugins not owned by the user \"pocketmine\"!"
10+
echo "For example:"
11+
find /data /plugins ! -user pocketmine | head
12+
echo "This may cause problems when running the server."
13+
echo "If you mount /data and /plugins from a local directory, consider running \`chown -R 1000:1000 \$MOUNT\` (replace \$MOUNT with your local directory) (you may need sudo to run this)"
14+
echo "==============="
15+
# Continue running the server since this is not necessarily fatal
16+
fi
17+
18+
# Install plugins from separated-separated env var $POCKETMINE_PLUGINS
19+
# Versions can be appended to plugin name separated by a colon
20+
# Example: POCKETMINE_PLUGINS="EconomyAPI:5.7.2 PurePerms PureChat:1.4.11"
21+
if [ ! -z "$POCKETMINE_PLUGINS" ]; then
22+
for PLUGIN in $(echo "$POCKETMINE_PLUGINS" | tr " " "\n"); do
23+
PLUGIN_NAME=$(echo "$PLUGIN::" | cut -d: -f1)
24+
PLUGIN_VERSION=$(echo "$PLUGIN::" | cut -d: -f2) # The trailing :: ensures that `cut` won't take the first field as the second field
25+
26+
if [ ! -f "/plugins/$PLUGIN_NAME.phar" ]; then
27+
echo "Installing $PLUGIN_NAME:$VERSION from Poggit"
28+
wget -O "/plugins/$PLUGIN_NAME.phar" "https://poggit.pmmp.io/get/$PLUGIN_NAME/$PLUGIN_VERSION"
29+
fi
30+
done
31+
fi
32+
33+
# Run the server
34+
cd /pocketmine
35+
read -ra pm_args <<<"$POCKETMINE_ARGS"
36+
exec php PocketMine-MP.phar --no-wizard --enable-ansi --data=/data --plugins=/plugins "${pm_args[@]}"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
/**
4+
* @name data-test
5+
* @version 1.0.0
6+
* @api 5.0.0
7+
* @main DataTest
8+
* @author PMMP Team
9+
*/
10+
11+
class DataTest extends \pocketmine\plugin\PluginBase {
12+
public function onEnable() : void {
13+
file_put_contents($this->getDataFolder() . "/create-data", "successful");
14+
}
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/**
4+
* @name data-test
5+
* @version 1.0.0
6+
* @api 5.0.0
7+
* @main DataTest
8+
* @author PMMP Team
9+
*/
10+
11+
class DataTest extends \pocketmine\plugin\PluginBase {
12+
public function onEnable() : void {
13+
$data = file_get_contents($this->getDataFolder() . "/create-data");
14+
if($data !== "successful") {
15+
$this->getLogger()->critical("create-data is not successful");
16+
exit(1);
17+
}
18+
$this->getLogger()->notice("Test passed: create-data is successful");
19+
}
20+
}

0 commit comments

Comments
 (0)