Update Dockerfile
Browse files- Dockerfile +14 -3
Dockerfile
CHANGED
@@ -28,6 +28,17 @@ RUN echo "eula=true" > eula.txt && \
|
|
28 |
|
29 |
EXPOSE 25565
|
30 |
|
31 |
-
#
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
EXPOSE 25565
|
30 |
|
31 |
+
# launcher script: start tunnel, wait for tcp url, print it, then run server
|
32 |
+
RUN printf '%s\n' \
|
33 |
+
'#!/bin/sh' \
|
34 |
+
'set -e' \
|
35 |
+
'cloudflared tunnel --url tcp://localhost:25565 --no-autoupdate --logfile /tmp/cf.log &' \
|
36 |
+
'CF_PID=$!' \
|
37 |
+
'echo "waiting for cloudflared…"' \
|
38 |
+
'while ! grep -m1 "tcp://" /tmp/cf.log >/dev/null 2>&1; do sleep 1; done' \
|
39 |
+
'MC_URL=$(grep -m1 "tcp://" /tmp/cf.log | sed -n "s/.*\(tcp:\/\/[^ ]*\).*/\1/p")' \
|
40 |
+
'echo "minecraft public endpoint: $MC_URL"' \
|
41 |
+
'exec java -Xmx2G -Xms2G -jar /minecraft/server.jar --nogui' \
|
42 |
+
> /start.sh && chmod +x /start.sh
|
43 |
+
|
44 |
+
CMD ["/start.sh"]
|