services:
  traefik:
    image: traefik:v2.0
    container_name: "traefik"
    command:
      - "--api.insecure=true"
      - "--providers.docker"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.http.address=:80"
      - "--entrypoints.https.address=:443"
      - "--serverstransport.insecureskipverify=true"
      - "--certificatesresolvers.myresolver.acme.httpchallenge=true"
      - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=http"
      - "--certificatesresolvers.myresolver.acme.email=acme@example.com"
      - "--certificatesresolvers.myresolver.acme.storage=/acme.json"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:[a-z-.]+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=http"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
    ports:
      - "80:80"
      - "443:443"
      - "127.0.0.1:8088:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/docker/traefik/acme.json:/acme.json
      - /etc/resolv.conf:/etc/resolv.conf
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"

  later42:
    container_name: later42
    image: dntskdev/later42:master
    restart: always
    environment:
      SECRET: "ahth3chaquodahh6que8thie1EThe5Iephich8eikei2Uojaemae6gee0kaet4aush2aoqu0ruL9oGhaiR9luu7cohreH6lebo0v"
      DB_TYPE: postgres
      DB_HOST: later42db
      DB_NAME: later42
      DB_USER: later42
      DB_PASS: later42
      DOMAIN: later42.com
      READABILITY_HOST: http://ureadability:8080/
      REDIS_URL: redis://redis:6379
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.later42-opt.rule=Host(`later42.com`)"
      - "traefik.http.routers.later42-opt.entrypoints=https"
      - "traefik.http.routers.later42-opt.tls.certresolver=myresolver"
      - "extdns.cf.later42.hostname=later42.com"

  later42db:
    container_name: later42db
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: later42
      POSTGRES_PASSWORD: later42
      POSTGRES_DB: later42
      POSTGRES_HOST_AUTH_METHOD: trust
    volumes:
      - /opt/docker/later42/db:/var/lib/postgresql/data
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"

  ureadability:
    image: umputun/ukeeper-readability:latest
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"
    hostname: ureadability
    restart: always
    container_name: ureadability
    links:
      - mongo
    ports:
      - "8080:8080"
    environment:
      - MONGO_URI=mongodb://root:aldbhvaygvavASDVSDFVQFQgfwvsav@mongo:27017
      - MONGO_DELAY=10s
      - CREDS=test:l4!AzQVW1dSN0T^7IJGn&Kr!kwRSF2P1

  mongo:
    image: mongo:5.0
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"
    hostname: mongo
    restart: always
    container_name: ureadability-mongo
    environment:
      - MONGO_INITDB_DATABASE=admin
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=aldbhvaygvavASDVSDFVQFQgfwvsav
    ports:
      - "27017:27017"
    volumes:
      - /opt/docker/mongodb:/data/db

  redis:
    image: "redis:alpine"
    hostname: redis
    container_name: redis
    ports:
      - "6379:6379"
    volumes:
      - /opt/docker/redis-data:/var/lib/redis
    environment:
      - REDIS_REPLICATION_MODE=master
