version : "2.4"

volumes:
  etherpad-db:
    name: etherpad-db
  weekpad-db:
    name: weekpad-db
  deleted-pads-standard:
    name: deleted-pads-standard
  deleted-pads-week:
    name: deleted-pads-week

networks:
  standard:
    name: "etherpad_main"
  week:
    name: "etherpad_week"
  docker_default:
    external: true
    name: "docker_default"

services:
  etherpad-app:
    image: registry.picasoft.net/pica-etherpad:1.8.4
    container_name: etherpad-app
    depends_on:
      - etherpad-db
    security_opt:
      - no-new-privileges
    mem_limit: "2048m"
    cpus: 0.6
    pids_limit: 1024
    env_file: ./secrets/etherpad-app.secrets
    volumes:
      - ./settings.json:/opt/etherpad-lite/settings.json
      - deleted-pads-standard:/opt/etherpad-lite/deleted_pads
    labels:
      traefik.enable: true
      traefik.frontend.rule: "Host:pad.picasoft.net"
      traefik.port: 8080
    environment:
      DB_HOST: "etherpad-db"
      LOGLEVEL: "INFO"
      MINIFY: "true"
      PORT: 8080
      THEME: "colibris"
      TITLE: "Picapad"
      TRUST_PROXY: "true"
    restart: unless-stopped
    networks:
      - docker_default
      - standard

  etherpad-db:
    image: registry.picasoft.net/pica-etherpad-db:mysql8.picapatch2
    container_name: etherpad-db
    security_opt:
      - no-new-privileges
    mem_limit: "2048m"
    cpus: "0.40"
    pids_limit: 1024
    volumes:
      - etherpad-db:/var/lib/mysql
    env_file: ./secrets/etherpad-db.secrets
    restart: unless-stopped
    # See https://stackoverflow.com/questions/41134785/how-to-solve-mysql-warning-innodb-page-cleaner-1000ms-intended-loop-took-xxx
    command: --innodb_lru_scan_depth=128 --default-authentication-plugin=mysql_native_password
    networks:
      - standard

  etherpad-week-app:
    image: registry.picasoft.net/pica-etherpad:1.8.4
    container_name: etherpad-week-app
    depends_on:
      - etherpad-week-db
    security_opt:
      - no-new-privileges
    mem_limit: "2048m"
    cpus: 0.6
    pids_limit: 1024
    env_file: ./secrets/etherpad-week-app.secrets
    volumes:
      - ./settings_week.json:/opt/etherpad-lite/settings.json
      - deleted-pads-week:/opt/etherpad-lite/deleted_pads
    labels:
      traefik.enable: true
      traefik.frontend.rule: "Host:week.pad.picasoft.net"
      traefik.port: 8080
    environment:
      DB_HOST: "etherpad-week-db"
      LOGLEVEL: "INFO"
      MINIFY: "true"
      PORT: 8080
      THEME: "colibris"
      TITLE: "Picapad Hebdo"
      TRUST_PROXY: "true"
    restart: unless-stopped
    networks:
      - docker_default
      - week

  etherpad-week-db:
    image: postgres:12
    container_name: etherpad-week-db
    security_opt:
      - no-new-privileges
    mem_limit: "2048m"
    cpus: "0.40"
    pids_limit: 1024
    volumes:
      - weekpad-db:/var/lib/postgresql/data
    env_file: ./secrets/etherpad-week-db.secrets
    restart: unless-stopped
    networks:
      - week
