version: '3'
services:

  php:
    build: 
      context: ./
      dockerfile: Dockerfile
    image: dcaventures/crm-connect:latest
    # volumes:
    #   - ./app:/var/www/html/
    ports:
      - "8181:80"
    environment:
      - APP_BASE_URL=http://localhost:8181/
      - APP_DB_HOSTNAME=database
      - APP_DB_USERNAME=root
      - APP_DB_PASSWORD=1234
      - APP_DB_NAME=crmcon
      - CI_ENV=production
      - APP_ENC_KEY=19ce261d2e714150e6e6259295ff88f4
      - HUB_TOKEN=fPG6X79gqe07NIZl0StZF0EAYNp3Zmpn
      - CONTAINER_ROLE=app

    depends_on:
      - database
    networks:
      crm_network:
    links:
      - database

  migration:
    image: dcaventures/crm-connect:latest
    command:
      [
        "/wait-for/wait-for.sh",
        "database:3306",
        "--",
        "php",
        "/var/www/html/index.php"
      ]
    links:
      - database
    depends_on:
      - database
    environment:
      - APP_BASE_URL=http://localhost:8181/
      - APP_DB_HOSTNAME=database
      - APP_DB_USERNAME=root
      - APP_DB_PASSWORD=1234
      - APP_DB_NAME=crmcon
      - CI_ENV=production
      - APP_ENC_KEY=19ce261d2e714150e6e6259295ff88f4
      - HUB_TOKEN=fPG6X79gqe07NIZl0StZF0EAYNp3Zmpn   
      - CONTAINER_ROLE=migrator

  database:
    image: mysql:5.7
    networks:
      crm_network:
    ports:
      - 3306:3306
    environment:
      - PHP_ENABLE_XDEBUG=0
      - MYSQL_HOST=database
      - MYSQL_PORT=3306
      - MYSQL_DATABASE=crmcon
      - MYSQL_USER=crmcon
      - MYSQL_PASSWORD=1234
      - MYSQL_ROOT_PASSWORD=1234
      - PMA_HOST=database
    volumes:
    - ./mysql/data:/var/lib/mysql:rw
    # - ./mysql/crmconne_devstaging.sql:/docker-entrypoint-initdb.d/crmconne_devstaging.sql:ro

  phpmyadmin:
    depends_on:
      - database
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - '8282:80'
    environment:
      - PHP_ENABLE_XDEBUG=0
      - MYSQL_HOST=database
      - MYSQL_PORT=3306
      - MYSQL_DATABASE=crmcon
      - MYSQL_USER=crmcon
      - MYSQL_PASSWORD=1234
      - MYSQL_ROOT_PASSWORD=1234
      - PMA_HOST=database
      - UPLOAD_LIMIT=300M
    networks:
      crm_network:
    links:
      - database
networks:
  crm_network: