---

services:
  django:
    image: c3buttons-django:latest
    container_name: c3buttons-django
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:8000/auth/test/open || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 5
    ### DISABLE PORTS FOR PRODUCTION
    ports:
      - '8000:8000'
    # volumes:
    #   - ./django/data/db.sqlite3:/c3buttons/db.sqlite3
    environment:
      ###
      ### PLEASE CHANGE THIS
      ###
      - DEFAULT_TOKEN_REFRESH_DAYS=7
      - DEFAULT_TOKEN_EXPIRE_MIN=10080 # 10080 min --> 7 days
      - DEFAULT_DJANGO_DEBUG=true

  gpio:
    image: c3buttons-gpio:latest
    container_name: c3buttons-gpio
    restart: unless-stopped
    #########
    # healthcheck:
    #   test: ["CMD-SHELL", "curl -f http://localhost:8000/auth/test/open || exit 1"]
    #   interval: 30s
    #   timeout: 5s
    #   retries: 5
    #########
    # depends_on:
    #   django:
    #     condition: service_healthy
    links:
      - django
    privileged: true
    devices:
      - /dev/gpiomem:/dev/gpiomem
    # volumes:
    #   ### DEBUG
    #   - ../gpio_buttons:/c3buttons
    environment:
      ###
      ### PLEASE CHANGE THIS
      ###
      - 'DATABASE_API_TOKEN=<PLEASE_CHANGE_THIS>'
      - 'BOXES_USED="BUTTON_BOX_1, BUTTON_BOX_2, BUTTON_BOX_3"'
      # - 'BOXES_USED="BUTTON_BOX_1, BUTTON_BOX_2"'
      - 'BUTTON_BOX_1={"pin_button": 16, "pin_led": 14}'
      - 'BUTTON_BOX_2={"pin_button": 20, "pin_led": 19}'
      - 'BUTTON_BOX_3={"pin_button": 21, "pin_led": 13}'

  grafana:
    image: grafana/grafana:latest
    container_name: c3buttons-grafana
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:3000/api/health || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 5
    # depends_on:
    #   django:
    #     condition: service_healthy
    links:
      - django
    ### DISABLE PORTS FOR PRODUCTION
    ports:
      - '3000:3000'
    # volumes:
    #   - ./grafana/data:/var/lib/grafana
    environment:
      - FOO=BAR
      - GF_FEATURE_TOGGLES_PUBLICDASHBOARDS=true
      - TLS_SKIP_VERIFY_INSECURE=true

  proxy:
    image: 'jc21/nginx-proxy-manager:latest'
    container_name: c3buttons-proxy
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:81 || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 5
    # depends_on:
    #   django:
    #     condition: service_healthy
    #   grafana:
    #     condition: service_healthy
    links:
      - django
      - grafana
    ports:
      - '80:80'
      - '443:443'
      ### This is the admin port, disable for Production
      - '81:81'
    # volumes:
    #   - ./proxy/data:/data
    #   - ./proxy/letsencrypt:/etc/letsencrypt
