version: '3'

services:
    client:
        build:
            context: .
            dockerfile: ./conf-dev/angular-cli.dockerfile
        ports:
            - 4200:4200
        working_dir: /project
        volumes:
            - ./client:/project
        command: ng serve --host=0.0.0.0 --disable-host-check --port 4200
    server:
        build:
            context: .
            dockerfile: ./conf-dev/php-dev.dockerfile
        working_dir: /project
        environment:
            docker: "true"
            DISPLAY_ERROR_DETAILS: "true"
            DATABASE_DEV_MODE: 1
            DATABASE_CO_DRIVER: "pdo_pgsql"
            DATABASE_CO_HOST: "db"
            DATABASE_CO_PORT: 5432
            DATABASE_CO_DBNAME: "anis_metamodel"
            DATABASE_CO_USER: "postgres"
            DATABASE_CO_PASSWORD: "postgres"
            DATA_PATH: "/data"
            LOGGER_NAME: "anis-metamodel"
            LOGGER_PATH: "php://stderr"
            LOGGER_LEVEL: "debug"
            TOKEN_ENABLED: 0
            TOKEN_PUBLIC_KEY_FILE: /mnt/public_key
            TOKEN_ADMIN_ROLE: anis_admin
        ports:
            - 8080:80
        volumes:
            - ./server:/project
            - ./conf-dev/dev-php.ini:/usr/local/etc/php/conf.d/dev-php.ini
            - ./conf-dev/vhost.conf:/etc/apache2/sites-available/000-default.conf
            - ./conf-dev/init-keycloak.sh:/mnt/init-keycloak.sh
            - ./conf-dev/create-db.sh:/mnt/create-db.sh
            - ./conf-dev/public_key:/mnt/public_key
            - ./data:/data
    keycloak:
        image: jboss/keycloak
        environment:
            DB_VENDOR: POSTGRES
            DB_ADDR: db
            DB_DATABASE: keycloakdb
            DB_USER: keycloak
            DB_PASSWORD: keycloak
            DB_SCHEMA: public
            KEYCLOAK_USER: admin
            KEYCLOAK_PASSWORD: admin
            KEYCLOAK_IMPORT: /tmp/keycloak-anis-realm.json
        ports:
            - 8180:8180
        volumes:
            - ./conf-dev/keycloak-anis-realm.json:/tmp/keycloak-anis-realm.json
        command: -b 0.0.0.0 -Djboss.http.port=8180
    db:
        image: postgres
        environment:
            POSTGRES_PASSWORD: "postgres"
        volumes:
            - pgdata:/var/lib/postgresql/data
            - ./conf-dev/data_test.sql:/sql/data_test.sql
            - ./conf-dev/init-postgres.sh:/docker-entrypoint-initdb.d/init-postgres.sh
    mailer:
        image: djfarrelly/maildev
        ports:
            - 1080:80
volumes:
    pgdata: