services:
  api:
    build:
        context: ./packages/api
        dockerfile: Dockerfile
        target: development
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgresql://root:root@dbapi:5432/api_db_dev?ssl=false
    entrypoint: [
      "yarn", "dev"
    ]
    depends_on:
       - dbapi
    volumes:
      - ./packages/api:/app
      - node_modules:/app/node_modules

  mail:
      image: mailhog/mailhog
      ports:
        - "8825:8025"
  dbapi:
    image: postgres:13.3-alpine
    environment:
      - POSTGRES_USER=root
      - POSTGRES_PASSWORD=root
      - POSTGRES_DB=api_db_dev
    ports:
      - 5431:5432
    restart: unless-stopped
  db:
    image: mysql:8.0
    command: ['--sql_mode=', '--default-authentication-plugin=mysql_native_password']
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: dev_db
  web:
    build:
      dockerfile: Dockerfile
      context: ./packages/plugin
      args:
        COMPOSER_TOKEN: $COMPOSER_TOKEN
    ports:
      - "8081:80"
    command: [ "--start","web:"]
    environment:
      DEBUG: 1
      WP_ENV: 'development'
      SMTP_HOST: mailhog
      SMTP_PORT: 1025
      DB_URL: "mysql://root:root@db/dev_db"
      WP_ADMIN_USER: root
      WP_ADMIN_PASS: root
      FINGERPRINT_MASTER_API_URL: http://api:3000
    depends_on:
      - db
    volumes:
      - ./packages/plugin:/usr/src/app
      - ./packages/plugin/docker:/docker-entrypoint-init
      - ./../s3-uploads:/s3-uploads

volumes:
  node_modules:
