services:
  my-service-production:
    container_name: my-service-production
    build:
      target: production
      context: .
      args:
        - PORT=${PORT:-3000}
    ports:
      - "${PORT:-3000}:${PORT:-3000}"
    deploy:
      resources:
        limits:
          cpus: "1"
          memory: "512m"
        reservations:
          cpus: "0.25"
          memory: "256m"

  my-service-dev:
    container_name: my-service-dev
    restart: unless-stopped
    env_file: .env
    build:
      target: dev
      context: .
      args:
        - PORT=${PORT:-3000}
    ports:
      - "${PORT:-3000}:${PORT:-3000}"
      - "9229:9229"
    volumes:
      - ./src:/app/src
    deploy:
      resources:
        limits:
          cpus: "1"
          memory: "512m"
        reservations:
          cpus: "0.25"
          memory: "256m"

  k6:
    image: ghcr.io/grafana/xk6-dashboard:0.7.2
    container_name: k6
    volumes:
      - ./tests/performance:/tests/performance
      - ./k6-results:/home/k6
    ports:
      - "5665:5665"
    environment:
      BASE_URL: "http://host.docker.internal:3000"
      K6_WEB_DASHBOARD_EXPORT: "report.html"
      K6_WEB_DASHBOARD_PERIOD: "1s"
      K6_WEB_DASHBOARD_OPEN: "true"
    command: [
      "run",
      "--out",
      "web-dashboard",
      "/tests/performance/contexts/users/get-users.mjs"
    ]
