makefuture / deploy / mp-relay.compose.yml
162 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# The nordschleife multiplayer relay.
#
#   docker compose -f /opt/web/apps/mp-relay/docker-compose.yml up -d --build
#
# Deployed to /opt/web/apps/mp-relay/ alongside an `app/` directory holding the
# relay source. Caddy proxies wss://makefuture.ro/ws here.

services:
  relay:
    build: ./app
    container_name: mp-relay
    restart: unless-stopped

    # No `ports:`. Publishing to the host would put a raw WebSocket server on
    # the public internet next to the one Caddy already terminates TLS for.
    # Caddy resolves `mp-relay` by container name over web-edge instead.

    environment:
      PORT: 8090
      LB_PATH: /data/leaderboard.json

    # The one piece of durable state: the global curve leaderboard. Room
    # state stays in memory as before.
    volumes:
      - ./data:/data

    security_opt:
      - no-new-privileges:true

    # In-memory room state only, so a crash costs a few seconds of gameplay and
    # nothing else. Restarting is always the right move.
    healthcheck:
      test:
        [
          'CMD',
          'node',
          '-e',
          "require('net').connect(8090,'127.0.0.1').on('connect',()=>process.exit(0)).on('error',()=>process.exit(1))",
        ]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 5s

    logging:
      driver: json-file
      options:
        max-size: '10m'
        max-file: '3'

    networks:
      - web-edge

networks:
  web-edge:
    external: true

static mirror of HEAD · about · clone: git clone https://git.makefuture.ro/makefuture.git