services:
  caddy:
    image: caddy:2-alpine
    container_name: ml-smoke-caddy
    environment:
      - FETCHML_DOMAIN=localhost
    ports:
      - "8080:80"
    volumes:
      - ${FETCHML_REPO_ROOT:-..}/deployments/Caddyfile.prod.smoke:/etc/caddy/Caddyfile:ro
      - ${FETCHML_REPO_ROOT:-..}/data/prod-smoke/caddy/data:/data
      - ${FETCHML_REPO_ROOT:-..}/data/prod-smoke/caddy/config:/config
    networks:
      - default
    depends_on:
      - api-server

  redis:
    image: redis:7-alpine
    user: "999:999"
    restart: unless-stopped
    expose:
      - "6379"
    volumes:
      - ${FETCHML_REPO_ROOT:-..}/data/prod-smoke/redis:/data
    command: redis-server --appendonly yes
    healthcheck:
      test: [ "CMD", "redis-cli", "ping" ]
      interval: 10s
      timeout: 5s
      retries: 10

  api-server:
    build:
      context: ${FETCHML_REPO_ROOT:-..}
      dockerfile: build/docker/simple.Dockerfile
    user: "0:0"
    restart: unless-stopped
    expose:
      - "9101"
    depends_on:
      redis:
        condition: service_healthy
    volumes:
      - ${FETCHML_REPO_ROOT:-..}/data/prod-smoke/experiments:/data/experiments
      - ${FETCHML_REPO_ROOT:-..}/data/prod-smoke/active:/data/active
      - ${FETCHML_REPO_ROOT:-..}/data/prod-smoke/logs:/logs
      - ${FETCHML_REPO_ROOT:-..}/configs/api/dev.yaml:/app/configs/api/dev.yaml:ro
    command: ["/bin/sh", "-c", "mkdir -p /data/experiments /data/active/datasets /data/active/snapshots && exec /usr/local/bin/api-server -config /app/configs/api/dev.yaml"]
    environment:
      - LOG_LEVEL=info
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:9101/health" ]
      interval: 10s
      timeout: 5s
      retries: 10

  ssh-test-server:
    image: linuxserver/openssh-server:latest
    container_name: ml-ssh-test
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/New_York
      - PUBLIC_KEY_FILE=/tmp/test_key.pub
      - USER_NAME=test
      - PASSWORD_ACCESS=false
    volumes:
      - ${FETCHML_REPO_ROOT:-..}/deployments/test_keys:/tmp:ro
      - ${FETCHML_REPO_ROOT:-..}/bin/tui-linux:/usr/local/bin/tui:ro
      - ${FETCHML_REPO_ROOT:-..}/deployments/tui-test-config.toml:/config/.ml/config.toml:ro
    ports:
      - "2222:2222"
    networks:
      - default
    depends_on:
      - caddy
      - api-server

networks:
  default:
    name: ml-prod-smoke-network

