version: "3"
services:

  mysql:
    image: mariadb:10.5
    restart: unless-stopped
    cap_drop:
      - ALL
    cap_add:
      - dac_override
      - setuid
      - setgid
    environment:
      - MYSQL_DATABASE=piler
      - MYSQL_USER=piler
      - MYSQL_PASSWORD=piler123
      - MYSQL_RANDOM_ROOT_PASSWORD=yes
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    healthcheck:
      test: mysql --user=piler --password=piler123 piler --execute "show tables"
      interval: "60s"
      timeout: "5s"
      start_period: "15s"
      retries: 3
    volumes:
      - db_data:/var/lib/mysql

  memcached:
    image: memcached:latest
    restart: unless-stopped
    cap_drop:
      - ALL
    command: -m 64

  piler:
    image: sutoj/piler:1.3.10
    init: true
    environment:
      - MYSQL_DATABASE=piler
      - MYSQL_USER=piler
      - MYSQL_PASSWORD=piler123
      - MYSQL_HOSTNAME=mysql
      - PILER_HOSTNAME=archive.yourdomain.com
      - MEMCACHED_HOST=memcached
    ports:
      - "25:25"
      - "80:80"
      - "443:443"
    volumes:
      - piler_etc:/etc/piler
      - piler_var:/var/piler
    healthcheck:
      test: curl -s smtp://localhost/
      interval: "60s"
      timeout: "3s"
      start_period: "15s"
      retries: 3
    deploy:
      resources:
        reservations:
          memory: 512M
        limits:
          memory: 512M

    depends_on:
      - "memcached"
      - "mysql"

volumes:
  db_data: {}
  piler_etc: {}
  piler_var: {}
