# Docker Compose for Development (Workspace Feature)
# This runs alongside docker-compose.yml on different ports

services:
  # Redis for Dev
  redis-dev:
    image: redis:7-alpine
    container_name: admister-redis-dev
    ports:
      - "6380:6379"
    volumes:
      - redis-data-dev:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 3s
      retries: 3
    networks:
      - admister-network-dev

  # Backend API for Dev
  api-dev:
    build:
      context: ./server
      dockerfile: Dockerfile
    container_name: admister-api-dev
    ports:
      - "3007:3001"
    environment:
      - NODE_ENV=development
      - PORT=3001
      - REDIS_HOST=redis-dev
      - REDIS_PORT=6379
      - DB_FILENAME=app-dev.db
      - FRONTEND_URL=http://localhost:3006
    env_file:
      - ./server/.env
    volumes:
      - ./server/uploads:/app/uploads
      - ./server/database:/app/database
    depends_on:
      redis-dev:
        condition: service_healthy
    networks:
      - admister-network-dev

  # Frontend (Next.js) for Dev
  web-dev:
    build:
      context: ./client
      dockerfile: Dockerfile
      args:
        NEXT_PUBLIC_API_URL: http://localhost:3007/api
    container_name: admister-web-dev
    ports:
      - "3006:3000"
    environment:
      - NODE_ENV=development
      - NEXT_PUBLIC_API_URL=http://localhost:3007/api
    depends_on:
      - api-dev
    networks:
      - admister-network-dev

networks:
  admister-network-dev:
    driver: bridge

volumes:
  redis-data-dev:
