services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: bytechef
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    volumes:
      - bytechef_db:/var/lib/postgresql/data

  mariadb:
    image: mariadb:11.8
    # Make every VECTOR INDEX created without an explicit DISTANCE use cosine,
    # so it matches the Cosine distance type of the ByteChef connection.
    command: ["--mhnsw-default-distance=cosine"]
    environment:
      MARIADB_ROOT_PASSWORD: root
      MARIADB_DATABASE: knowledge
      MARIADB_USER: bytechef
      MARIADB_PASSWORD: bytechef
    ports:
      - "3307:3306"
    volumes:
      - mariadb_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 10

  bytechef:
    image: docker.bytechef.io/bytechef/bytechef:latest
    depends_on:
      postgres:
        condition: service_started
      mariadb:
        condition: service_healthy
    environment:
      BYTECHEF_DATASOURCE_URL: jdbc:postgresql://postgres:5432/bytechef
      BYTECHEF_DATASOURCE_USERNAME: postgres
      BYTECHEF_DATASOURCE_PASSWORD: postgres
      BYTECHEF_SECURITY_REMEMBER_ME_KEY: change-me-to-a-long-random-string
    volumes:
      - ~/.bytechef:/root/.bytechef
    ports:
      - "8080:8080"

volumes:
  bytechef_db:
  mariadb_data:
