Skip to content
Hunter Wu edited this page Sep 11, 2021 · 1 revision

Running Nakama

  • docker-compose.yml
version: '3'
services:
  cockroachdb:
    image: cockroachdb/cockroach:v21.1.6
    command: start-single-node --insecure --store=attrs=ssd,path=/var/lib/cockroach/
    restart: "no"
    volumes:
      - data:/var/lib/cockroach
    expose:
      - "8080"
      - "26257"
    ports:
      - "26257:26257"
      - "8080:8080"
  nakama:
    image: heroiclabs/nakama:3.4.0
    entrypoint:
      - "/bin/sh"
      - "-ecx"
      - >
        /nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
        exec /nakama/nakama --name nakama1 --database.address root@cockroachdb:26257 --logger.level DEBUG --session.token_expiry_sec 7200 --metrics.prometheus_port 9100
    restart: "no"
    links:
      - "cockroachdb:db"
    depends_on:
      - cockroachdb
      - prometheus
    volumes:
      - ./:/nakama/data
    expose:
      - "7349"
      - "7350"
      - "7351"
      - "9100"
    ports:
      - "7349:7349"
      - "7350:7350"
      - "7351:7351"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7350/"]
      interval: 10s
      timeout: 5s
      retries: 5
  prometheus:
    image: prom/prometheus
    entrypoint: /bin/sh -c
    command: |
      'sh -s <<EOF
        cat > ./prometheus.yml <<EON
      global:
        scrape_interval:     15s
        evaluation_interval: 15s
      scrape_configs:
        - job_name: prometheus
          static_configs:
          - targets: ['localhost:9090']
        - job_name: nakama
          metrics_path: /
          static_configs:
          - targets: ['nakama:9100']
      EON
      prometheus --config.file=./prometheus.yml
      EOF'
    ports:
      - '9090:9090'
volumes:
  data:
  • command
sudo docker-compose up

Auth

Reg by email/password

curl "http://127.0.0.1:7350/v2/account/authenticate/email?create=true&username=test" \
  --user 'defaultkey:' \
  --data '{"email":"[email protected]", "password": "00000000"}'
{"created":true, "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJhNjlhYzZjMi1jZTZiLTQzNjgtYTkyZC1iNmE1ODcxMDI5ZGQiLCJ1c24iOiJ0ZXN0IiwiZXhwIjoxNjI3ODMyNjIwfQ.PHgQ944QC2lvuBkXxUcP26hrVmp6CsEL4Tc12fJB3LE", "refresh_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJhNjlhYzZjMi1jZTZiLTQzNjgtYTkyZC1iNmE1ODcxMDI5ZGQiLCJ1c24iOiJ0ZXN0IiwiZXhwIjoxNjI3ODI5MDIwfQ.4IOTY3DY7vcONWgLstgMMi7pKptO8fWATgm0a5TyCMg"}
Clone this wiki locally