Staticaliza commited on
Commit
a1aada8
·
verified ·
1 Parent(s): 0bb597a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -10
Dockerfile CHANGED
@@ -30,15 +30,17 @@ 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"]
 
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 --logformat json &' \
36
+ 'echo "waiting for cloudflared…"' \
37
+ 'while true; do' \
38
+ ' MC_URL=$(grep -o "tcp://[A-Za-z0-9._-]*trycloudflare.com:[0-9]*" /tmp/cf.log | head -n1)' \
39
+ ' [ -n "$MC_URL" ] && break' \
40
+ ' sleep 1' \
41
+ 'done' \
42
+ 'echo "minecraft public endpoint: $MC_URL"' \
43
+ 'exec java -Xmx2G -Xms2G -jar /minecraft/server.jar --nogui' \
44
+ > /start.sh && chmod +x /start.sh
45
 
46
  CMD ["/start.sh"]