services:
  app:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: licitacao_app
    working_dir: /var/www
    volumes:
      - ./:/var/www
    depends_on:
      db:
        condition: service_started

  web:
    image: nginx:alpine
    container_name: licitacao_web
    ports:
      - "8000:80"
    volumes:
      - ./:/var/www
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      app:
        condition: service_started

  node:
    image: node:20-alpine
    container_name: licitacao_node
    working_dir: /var/www
    volumes:
      - ./:/var/www
    ports:
      - "5173:5173"
    environment:
      VITE_DEV_SERVER_HOST: localhost
      VITE_DEV_SERVER_PORT: 5173
    command: sh -lc "npm install && npm run dev -- --host 0.0.0.0 --port 5173 --strictPort"
    depends_on:
      app:
        condition: service_started

  db:
    image: mysql:8.0
    container_name: licitacao_db
    environment:
      MYSQL_DATABASE: licitacao
      MYSQL_USER: licitacao
      MYSQL_PASSWORD: licitacao
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "3306:3306"
    volumes:
      - dbdata:/var/lib/mysql

volumes:
  dbdata:
