version: '3.8'

services:

  mysql:
    image: mysql:8.0
    container_name: mysql-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 1234
      MYSQL_DATABASE: mf_db
    ports:
      - "3307:3306"
    volumes:
      - ./mysql-data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-p1234"]
      interval: 10s
      timeout: 5s
      retries: 5


  backend:
    build:
      context: ../memberflow-api
      dockerfile: ../docker/Dockerfile-api
    container_name: memberflow-backend
    depends_on:
      mysql:
        condition: service_healthy
    ports:
      - "8080:8080"
    environment:
      SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/mf_db?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
      SPRING_DATASOURCE_USERNAME: root
      SPRING_DATASOURCE_PASSWORD: 1234
      JWT_SECRET: c2VjdXJlc2VjdXJlc2VjdXJlc2VjdXJlMTIzNDU2
      JWT_EXPIRATION: 7200000



  frontend:
    build:
      context: ..
      dockerfile: docker/Dockerfile-front
    container_name: memberflow-frontend
    depends_on:
      - backend
    ports:
      - "3000:80"