version : "3.7"

volumes:
  etherpad-db:
    name: etherpad-db-pg
  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
  proxy:
    external: true

services:
  etherpad-app:
    image: registry.picasoft.net/pica-etherpad:1.8.6
    build: .
    container_name: etherpad-app
    env_file: ./secrets/etherpad-app.secrets
    volumes:
      - ./settings.json:/opt/etherpad-lite/settings.json
      - deleted-pads-standard:/opt/etherpad-lite/deleted_pads
    labels:
      traefik.http.routers.etherpad-app.entrypoints: websecure
      traefik.http.routers.etherpad-app.rule: Host(`pad.picasoft.net`)
      traefik.http.services.etherpad-app.loadbalancer.server.port: 8080
      traefik.enable: true
    environment:
      DB_HOST: "etherpad-db"
      LOGLEVEL: "INFO"
      MINIFY: "true"
      PORT: 8080
      THEME: "colibris"
      TITLE: "Picapad"
      TRUST_PROXY: "true"
      ABIWORD: "/usr/bin/abiword"
    networks:
      - proxy
      - standard
    depends_on:
      - etherpad-db
    restart: unless-stopped

  etherpad-db:
    image: postgres:12
    container_name: etherpad-db
    volumes:
      - etherpad-db:/var/lib/postgresql/data
    env_file: ./secrets/etherpad-db.secrets
    networks:
      - standard
    restart: unless-stopped

  etherpad-week-app:
    image: registry.picasoft.net/pica-etherpad:1.8.6
    container_name: etherpad-week-app
    build: .
    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.http.routers.etherpad-week-app.entrypoints: websecure
      traefik.http.routers.etherpad-week-app.rule: Host(`week.pad.picasoft.net`)
      traefik.http.services.etherpad-week-app.loadbalancer.server.port: 8080
      traefik.enable: true
    environment:
      DB_HOST: "etherpad-week-db"
      LOGLEVEL: "INFO"
      MINIFY: "true"
      PORT: 8080
      THEME: "colibris"
      TITLE: "Picapad Hebdo"
      TRUST_PROXY: "true"
      ABIWORD: "/usr/bin/abiword"
    depends_on:
      - etherpad-week-db
    networks:
      - proxy
      - week
    restart: unless-stopped

  etherpad-week-db:
    image: postgres:12
    container_name: etherpad-week-db
    volumes:
      - weekpad-db:/var/lib/postgresql/data
    env_file: ./secrets/etherpad-week-db.secrets
    restart: unless-stopped
    networks:
      - week