networks:
  app-network:

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: nest-app
    restart: always
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: "mysql://appuser:apppassword@db:3306/painel-lt-principal"
    depends_on:
      - db
    volumes:
      - .:/usr/src/app
      - /usr/src/app/node_modules
    command: ["sh", "-c", "npx prisma generate && npm run start:dev"]
    networks:
      - app-network

  db:
    image: mysql:8.0
    container_name: mysql-db
    restart: always
    ports:
      - "3308:3306"
    environment:
      MYSQL_DATABASE: painel-lt-principal
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_USER: appuser
      MYSQL_PASSWORD: apppassword
      MYSQL_ROOT_HOST: "%"
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - app-network

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    restart: always
    ports:
      - "8080:80"
    environment:
      PMA_HOST: db
    depends_on:
      - db
    networks:
      - app-network

volumes:
  db_data:
