version: '2.3'

services:

  postgres:
    container_name: postgres
    image: postgres
    environment:
      POSTGRES_PASSWORD: password123
      POSTGRES_DB: statping
      POSTGRES_USER: root
    ports:
      - 5432:5432
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U root"]
      interval: 15s
      timeout: 10s
      retries: 20

  mysql:
    container_name: mysql
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password123
      MYSQL_DATABASE: statping
      MYSQL_USER: root
      MYSQL_PASSWORD: password123
    ports:
      - 3306:3306
    healthcheck:
      test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
      timeout: 20s
      interval: 15s
      retries: 30

  phpmyadmin:
    container_name: phpmyadmin
    image: phpmyadmin/phpmyadmin
    restart: on-failure
    depends_on:
      mysql:
        condition: service_healthy
    ports:
      - "127.0.0.1:5050:80"
    links:
      - mysql:db
    environment:
      MYSQL_ROOT_PASSWORD: password123
      PMA_HOST: mysql
      PMA_USER: root
      PMA_PASSWORD: password123
      PMA_PORT: 3306

  sqlite-web:
    container_name: sqlite-web
    image: coleifer/sqlite-web
    restart: on-failure
    command: sqlite_web -H 0.0.0.0 -r -x /data/statping.db
    ports:
      - "127.0.0.1:6050:8080"
    volumes:
      - ../docker/statping/sqlite/statping.db:/data/statping.db:ro
    environment:
      SQLITE_DATABASE: /data/statping.db

  pgadmin4:
    container_name: pgadmin4
    image: fenglc/pgadmin4
    restart: on-failure
    environment:
      DEFAULT_USER: admin@admin.com
      DEFAULT_PASSWORD: admin
    ports:
      - "127.0.0.1:7000:5050"
    links:
      - postgres:postgres

  prometheus:
    container_name: prometheus
    image: prom/prometheus:v2.0.0
    restart: on-failure
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - ../docker/databases/prometheus:/prometheus
    ports:
      - "127.0.0.1:7050:9090"
    healthcheck:
      test: "/bin/wget -q -Y off http://localhost:9090/status -O /dev/null > /dev/null 2>&1"
      interval: 10s
      timeout: 3s
