version: '3'
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: grocery-saas-app
    container_name: grocery-saas-app
    restart: unless-stopped
    tty: true
    environment:
      SERVICE_NAME: app
      SERVICE_TAGS: dev
    working_dir: /var/www
    volumes:
      - ./:/var/www
      - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
    networks:
      - grocery-saas-network

  webserver:
    image: nginx:alpine
    container_name: grocery-saas-webserver
    restart: unless-stopped
    tty: true
    ports:
      - "8080:80"
    volumes:
      - ./:/var/www
      - ./nginx/conf.d/:/etc/nginx/conf.d/
    networks:
      - grocery-saas-network
    depends_on:
      - app

  db:
    image: mysql:8.0
    container_name: grocery-saas-db
    restart: unless-stopped
    tty: true
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: grocery_central
      MYSQL_ROOT_PASSWORD: password
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    volumes:
      - dbdata:/var/lib/mysql/
    networks:
      - grocery-saas-network

  redis:
    image: redis:alpine
    container_name: grocery-saas-redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    networks:
      - grocery-saas-network

  queue:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: grocery-saas-queue
    restart: unless-stopped
    command: "php artisan queue:work"
    volumes:
      - ./:/var/www
    networks:
      - grocery-saas-network
    depends_on:
      - app
      - redis
      - db

networks:
  grocery-saas-network:
    driver: bridge

volumes:
  dbdata:
    driver: local
