networks:
  database:
  caching:
  metrics:

volumes:
  mysql:
  influxdb:
  
services:
  app:
    image: wrestlingdev
    build:
      context: ../
      dockerfile: ./deploy/rails-prod-Dockerfile
    environment:
      - RAILS_ENV=production
      - WRESTLINGDEV_DB_NAME=wrestlingtourney
      - WRESTLINGDEV_DB_USR=root
      - WRESTLINGDEV_DB_PWD=password
      - WRESTLINGDEV_DB_HOST=db
      - WRESTLINGDEV_DB_PORT=3306
      - WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa
      - WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2
      - WRESTLINGDEV_INFLUXDB_DATABASE=wrestlingdev
      - WRESTLINGDEV_INFLUXDB_HOST=influxdb
      - WRESTLINGDEV_INFLUXDB_PORT=8086
      - SOLID_QUEUE_IN_PUMA=true
    networks:
      database:
      caching:
      metrics:
    restart: always
    ports:
      - "80:80"
      - "443:443"
    healthcheck: 
      test: curl http://127.0.0.1/
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro

  db:
    image: mariadb:10.10
    ports:
      - "3306:3306"
    volumes:
      - mysql:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    environment:
      - MYSQL_ROOT_PASSWORD=password
    restart: always
    networks:
      database:
    healthcheck:
      test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_PASSWORD
      start_period: 5s
      interval: 5s
      timeout: 5s
      retries: 10

  influxdb:
    image: influxdb:1.8-alpine
    environment:
      - INFLUXDB_DB=wrestlingdev
    ports:
      - "8086:8086"
    networks:
      metrics:
    volumes:
      - influxdb:/var/lib/influxdb
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
