version: '2'

services:
  pleroma:
    build: ./pleroma
    hostname: pleroma
    container_name: pleroma
    restart: always
    command: mix phx.server
    volumes:
      - ./pleroma/config:/pleroma/config
      - ./pleroma/uploads:/pleroma/uploads
      - ./pleroma/vm.args.eex:/pleroma/rel/vm.args.eex
      - ./pleroma/terms-of-service.html:/pleroma/priv/static/static/terms-of-service.html:ro
#      - ./pleroma/emojis:/pleroma/priv/static/emoji/custom/images:ro
#      - ./pleroma/images:/pleroma/priv/static/static/images:ro
#      - ./pleroma/custom_emoji.txt:/pleroma/config/custom_emoji.txt:ro
#      - ./pleroma/index.html:/pleroma/priv/static/index.html:ro
    expose:
      - 4000
    ports:
      - "9999:9999/tcp"
    networks:
      mynet:
        ipv4_address: 172.2.0.101

  postgres:
    image: postgres
    hostname: postgres-pleroma
    container_name: postgres-pleroma
    restart: always
    shm_size: '1gb'
    command: >
      -c 'max_connections=150'
      -c 'shared_buffers=512MB'
      -c 'effective_cache_size=1536MB'
      -c 'maintenance_work_mem=128MB'
      -c 'checkpoint_completion_target=0.7'
      -c 'wal_buffers=16MB'
      -c 'default_statistics_target=100'
      -c 'random_page_cost=1.1'
      -c 'effective_io_concurrency=200'
      -c 'work_mem=1747kB'
      -c 'min_wal_size=1GB'
      -c 'max_wal_size=2GB'
      -c 'max_worker_processes=4'
      -c 'max_parallel_workers_per_gather=2'
      -c 'max_parallel_workers=4'
      -c 'autovacuum_max_workers=1'
      -c 'autovacuum_work_mem=128MB'
      -h '*'
#      -c 'statement_timeout=60000'
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_DB=pleroma
      - POSTGRES_PASSWORD=pl3r0m4.
    volumes:
      - ./data:/var/lib/postgresql/data
    expose:
      - 5432
    networks:
      mynet:
        ipv4_address: 172.2.0.102

networks:
  mynet:
    driver: bridge
    ipam:
      config:
      - subnet: 172.2.0.0/24
