version: '3.4'

volumes:
    uploads:
        driver: local
    logs:
        driver: local
    mysql:
        driver: local

networks:
    app_net:
    db_net:

services:
    ospos:
        build:
            context: .
            target: ospos_dev
        container_name: ospos_dev
        restart: always
        depends_on:
          - mysql
        ports:
          - "80:80"
        networks:
          - app_net
          - db_net
        volumes:
          - .:/app
          - uploads:/app/public/uploads
          - logs:/app/application/logs
        environment:
          - PHP_TIMEZONE=UTC
          - MYSQL_USERNAME=admin
          - MYSQL_PASSWORD=pointofsale
          - MYSQL_DB_NAME=ospos
          - MYSQL_HOST_NAME=mysql
          - XDEBUG_CONFIG=remote_host=172.17.0.1

    mysql:
        image: mariadb:10.5
        container_name: mysql
        restart: always
        expose:
          - "3306"
        networks:
          - db_net
        volumes:
          - ./database/database.sql:/docker-entrypoint-initdb.d/database.sql
          - mysql:/var/lib/mysql:rw
        environment:
          - MYSQL_ROOT_PASSWORD=pointofsale
          - MYSQL_DATABASE=ospos
          - MYSQL_USER=admin
          - MYSQL_PASSWORD=pointofsale
