version: "3.9"

services:
    maildev:
        image: maildev/maildev
        command:
            [
                node,
                bin/maildev,
                --web,
                "80",
                --smtp,
                "25",
                -v,
                --hide-extensions=STARTTLS,
            ]

    mongo:
        image: mongo

    tibi-server:
        image: registry.webmakers.de/tibi/tibi-server
        environment:
            DB_DIAL: mongodb://mongo
            API_PORT: 8080
            MAIL_HOST: maildev:25
        depends_on:
            - maildev
            - mongo
        volumes:
            - ./:/workdir

    liveserver:
        image: node
        command: yarn run -- live-server --no-browser --port=80 --ignore='*' --entry-file=spa.html --no-css-inject --proxy=/api:http://tibi-server:8080/api/v1/_/einfo_test dist
        depends_on:
            - tibi-server
        volumes:
            - ./:/workdir
        working_dir: /workdir

    cypress:
        #image: cypress/base
        image: cypress/browsers:node14.17.0-chrome91-ff89
        environment:
            FORCE_COLOR: "true"
            CYPRESS_BASE_URL: http://liveserver
            CYPRESS_CI: "true"
            CYPRESS_mongodbUri: mongodb://mongo
            CYPRESS_tibiApiUrl: http://tibi-server:8080/api/v1
            CYPRESS_projectApiConfig: /workdir/api/config.yml
            #DISPLAY: host.docker.internal:0.0
            DISPLAY: $DISPLAY
            LIBGL_ALWAYS_INDIRECT: 1
        command: sh ./scripts/cy-command.docker.sh $CY_COMMAND
        #command: yarn cy:$CY_COMMAND
        depends_on:
            - liveserver
        volumes:
            - ./:/workdir
            - ~/.cache:/home/node/.cache
            - $HOME/.Xauthority:$HOME/.Xauthority
            - /tmp/.X11-unix:/tmp/.X11-unix
        working_dir: /workdir
        user: $CURRENT_UID
