version: '2'

services:
    database:
        build: ./postgresql
        container_name: mx-postgresql
        networks:
            mx.internal.docker:
                aliases:
                    - postgresql.mx.internal.docker
        volumes:
            - ./data/postgresql/data:/var/lib/postgresql/data
        ports:
            - "34000:5432"
        env_file:
            - env

    postfixadmin:
        build: ./postfixadmin
        container_name: mx-postfixadmin
        networks:
            mx.internal.docker:
                aliases:
                    - postfixadmin.mx.internal.docker
        ports:
            - "34001:80"
        env_file:
            - env

    postfix:
        build: ./postfix
        container_name: mx-postfix
        networks:
            mx.internal.docker:
                aliases:
                    - postfix.mx.internal.docker
            mx-local.internal.docker:
                aliases:
                    - smtp.mx-local.internal.docker
        ports:
            - "0.0.0.0:25:25"
            - "0.0.0.0:587:587"
        env_file:
            - env

    dovecot:
        build: ./dovecot
        container_name: mx-dovecot
        networks:
            mx.internal.docker:
                aliases:
                    - dovecot.mx.internal.docker
            mx-local.internal.docker:
                aliases:
                    - imap.mx-local.internal.docker
        volumes:
            - ./data/dovecot/email:/var/email
            - ./data/dovecot/sieve:/etc/dovecot/sieve
        ports:
            - "0.0.0.0:110:110"
            - "0.0.0.0:143:143"
            - "0.0.0.0:993:993"
            - "0.0.0.0:995:995"
            - "0.0.0.0:4190:4190"
        env_file:
            - env

    opendkim:
        build: ./opendkim
        container_name: mx-opendkim
        networks:
            mx.internal.docker:
                aliases:
                    - opendkim.mx.internal.docker
        volumes:
            - ./data/opendkim/keys:/etc/opendkim/keys
        env_file:
            - env

networks:
    mx.internal.docker:
    mx-local.internal.docker:
