services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: bizpot-backend
    container_name: bizpot-backend
    restart: unless-stopped
    ports:
      - "8000:8000"
    environment:
      - APP_ENV=local
      - APP_DEBUG=true
      - APP_KEY=${APP_KEY}
      - DB_CONNECTION=mysql
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=${DB_DATABASE}
      - DB_USERNAME=${DB_USERNAME}
      - DB_PASSWORD=${DB_PASSWORD}
    volumes:
      - ./:/var/www
      - bizpot-storage:/var/www/storage
    depends_on:
      db:
        condition: service_healthy
    networks:
      - bizpot

  db:
    image: mysql:8.0
    container_name: bizpot-db
    restart: unless-stopped
    environment:
      - MYSQL_DATABASE=${DB_DATABASE}
      - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
    volumes:
      - bizpot-db:/var/lib/mysql
    ports:
      - "3306:3306"
    networks:
      - bizpot
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-p$$MYSQL_ROOT_PASSWORD"]
      interval: 5s
      timeout: 5s
      retries: 30

networks:
  bizpot:
    driver: bridge

volumes:
  bizpot-db:
  bizpot-storage: