version: "3.9"

services:
  app:
    image: registry.gitlab.com/dev-initialde/sambaapi:${IMAGE_TAG}
    ports:
      - "9091:9090"
    environment:
      MQTT_BROKER_HOST: mqtt
      MQTT_BROKER_PORT: 1883
      SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/sambataxi
      SPRING_DATASOURCE_USERNAME: samba_user@2024
      SPRING_DATASOURCE_PASSWORD: jydtE6-dodvac-fyhtot
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
    depends_on:
      - mqtt
      - mysql
      - redis
    networks:
      - samba-net
    labels:
      - "monitor=true"
    restart: always

  mysql:
    image: mysql:8.0
    container_name: samba-mysql
    environment:
      MYSQL_ROOT_PASSWORD: rjydtE6-dodvac-fyhtotoot
      MYSQL_DATABASE: sambataxi
      MYSQL_USER: "samba_user@2024"
      MYSQL_PASSWORD: jydtE6-dodvac-fyhtot
    volumes:
      - mysql_data:/var/lib/mysql
    ports:
      - "3307:3306"
    networks:
      - samba-net
    restart: always
    command: --default-authentication-plugin=mysql_native_password

  mqtt:
    image: eclipse-mosquitto
    container_name: mqtt-broker
    restart: unless-stopped
    ports:
      - "1883:1883"
      - "9001:9001"
    volumes:
      - ./mosquitto/config:/mosquitto/config
      - ./mosquitto/data:/mosquitto/data
      - ./mosquitto/log:/mosquitto/log
    networks:
      - samba-net

  redis:
    image: redis:7-alpine
    container_name: samba-cache
    ports:
      - "6380:6379"
    volumes:
      - redis_data:/data
    networks:
      - samba-net
    restart: unless-stopped

volumes:
  mysql_data:
  redis_data:

networks:
  samba-net:
    driver: bridge