services:
  backend:
    build: 
      context: ../backend
      dockerfile: ../docker/Dockerfile.backend
    container_name: bamort-backend
    ports:
      - "8182:8180"
    environment:
      - GO_ENV=production
      - CGO_ENABLED=1
      - DATABASE_TYPE=${DATABASE_TYPE:-mysql}
      - DATABASE_URL=${MARIADB_USER:-bamort}:${MARIADB_PASSWORD:-secure_user_password}@tcp(mariadb:3306)/${MARIADB_DATABASE:-bamort}?charset=utf8mb4&parseTime=True&loc=Local
      - BASE_URL=${BASE_URL:-https://bamort.trokan.de}
      - API_PORT=${API_PORT:-8180}
    depends_on:
      mariadb:
        condition: service_healthy
    working_dir: /app
    volumes:
      - ./templates:/app/templates
    restart: unless-stopped

  frontend:
    build:
      context: ../frontend
      dockerfile: ../docker/Dockerfile.frontend
      args:
        VITE_API_URL: ${API_URL:-https://bamort-api.trokan.de}
        VITE_BASE_URL: ${BASE_URL:-https://bamort.trokan.de}
        VITE_API_PORT: ${API_PORT:-443}
    container_name: bamort-frontend
    ports:
      - "8181:80"
    environment:
      - NODE_ENV=production
      - VITE_API_URL=${API_URL:-https://bamort.trokan.de:8180}
      - VITE_BASE_URL=${BASE_URL:-https://bamort.trokan.de}
      - VITE_API_PORT=${API_PORT:-8180}
    depends_on:
      - backend
    restart: unless-stopped

  mariadb:
    image: mariadb:11.4
    container_name: bamort-mariadb
    restart: unless-stopped
    #ports:
    #  - "3306:3306"
    environment:
      MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-secure_root_password}
      MARIADB_DATABASE: ${MARIADB_DATABASE:-bamort}
      MARIADB_USER: ${MARIADB_USER:-bamort}
      MARIADB_PASSWORD: ${MARIADB_PASSWORD:-secure_user_password}
      MARIADB_CHARSET: utf8mb4
      MARIADB_COLLATION: utf8mb4_unicode_ci
    volumes:
      - ./bamort-db:/var/lib/mysql
      - ./init-db:/docker-entrypoint-initdb.d
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      start_period: 20s
      timeout: 10s
      retries: 3

  # phpMyAdmin - Database Management (commented out for production)
  # Uncomment the following section if you need database management in production
  # phpmyadmin:
  #   image: phpmyadmin/phpmyadmin:5.2
  #   container_name: bamort-phpmyadmin
  #   restart: unless-stopped
  #   ports:
  #     - "8081:80"
  #   environment:
  #     PMA_HOST: mariadb
  #     PMA_PORT: 3306
  #     PMA_USER: root
  #     PMA_PASSWORD: ${MARIADB_ROOT_PASSWORD:-secure_root_password}
  #     MYSQL_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-secure_root_password}
  #     PMA_ARBITRARY: 1
  #   depends_on:
  #     mariadb:
  #       condition: service_healthy

#volumes:
#  db_data:
