services:
  app:
    build: ./backend
    container_name: craft_app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - ./backend:/var/www
    environment:
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=crafts_db
      - DB_USERNAME=root
      - DB_PASSWORD=root
    networks:
      - app-network
    ports:
      - "9000:80"

  db:
    image: mysql:8.0
    container_name: mysql_db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: crafts_db
    ports:
      - "3308:3306"
    volumes:
      - dbdata:/var/lib/mysql
    networks:
      - app-network

  frontend:
    build: ./frontend
    container_name: react_frontend
    restart: unless-stopped
    ports:
      - "3001:80"
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

volumes:
  dbdata: