Staticaliza commited on
Commit
81c7050
·
verified ·
1 Parent(s): a1aada8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +5 -3
Dockerfile CHANGED
@@ -28,17 +28,19 @@ RUN echo "eula=true" > eula.txt && \
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 --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
 
28
 
29
  EXPOSE 25565
30
 
31
+ # launcher
32
  RUN printf '%s\n' \
33
  '#!/bin/sh' \
34
  'set -e' \
35
+ 'touch /tmp/cf.log' \
36
+ 'cloudflared tunnel --url tcp://localhost:25565 --no-autoupdate > /tmp/cf.log 2>&1 &' \
37
  'echo "waiting for cloudflared…"' \
38
+ 'for i in $(seq 1 60); do' \
39
  ' MC_URL=$(grep -o "tcp://[A-Za-z0-9._-]*trycloudflare.com:[0-9]*" /tmp/cf.log | head -n1)' \
40
  ' [ -n "$MC_URL" ] && break' \
41
  ' sleep 1' \
42
  'done' \
43
+ '[ -z "$MC_URL" ] && { echo "cloudflared failed"; cat /tmp/cf.log; exit 1; }' \
44
  'echo "minecraft public endpoint: $MC_URL"' \
45
  'exec java -Xmx2G -Xms2G -jar /minecraft/server.jar --nogui' \
46
  > /start.sh && chmod +x /start.sh