version: "3.8"

services:
  app:
    build:
      args:
        user: metacargo
        uid: 1000
      context: ./
      dockerfile: Dockerfile
    container_name: app
    restart: unless-stopped
    working_dir: /var/www/
    volumes:
      - ./:/var/www/
    networks:
      - metacargo_network

  nginx:
    image: nginx:alpine
    container_name: nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./:/var/www/
      - ./docker/nginx/:/etc/nginx/conf.d/
    networks:
      - metacargo_network

  # redis
  redis:
    image: redis:7.2
    command: redis-server --requirepass ${REDIS_PASSWORD}
    ports:
      - "6382:6379"
    networks:
      - metacargo_network

  #queue
  queue:
    build:
      args:
        user: metacargo
        uid: 1000
      context: ./
      dockerfile: Dockerfile
    restart: always
    command: "php artisan queue:work --tries=1 --timeout=30"
    volumes:
      - ./:/var/www
    depends_on:
      - redis
    networks:
      - metacargo_network

  #horizon
  horizon:
    build:
      args:
        user: metacargo
        uid: 1000
      context: ./
      dockerfile: Dockerfile
    restart: always
    command: "php artisan horizon"
    volumes:
      - ./:/var/www
    depends_on:
      - redis
    networks:
      - metacargo_network

  mysql:
    image: mysql:5.7.22
    container_name: mysql
    restart: unless-stopped
    ports:
      - "3377:3306"
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_USER: ${DB_USERNAME}
    volumes:
      - ./.docker/mysql/dbdata:/var/lib/mysql
    networks:
      - metacargo_network

networks:
  metacargo_network:
    driver: bridge
