# Development Environment for Construct Agentic Testing
#
# Use this for:
# - Running the agent in a sandboxed environment
# - Testing dangerous commands safely
# - Developing new skills/integrations
#
# Usage:
#   cd dev && ./cli.sh up
#   or from root: ./dev/cli.sh up
name: construct-dev
services:
  # ── The Agent (Development Image) ──
  # Builds from source using the 'dev' stage of the root Dockerfile
  construct-dev:
    build:
      context: ..
      dockerfile: Dockerfile
      target: dev
    container_name: construct-dev
    restart: unless-stopped
    environment:
      - CONSTRUCT_GATEWAY_PORT=42617
      - SANDBOX_HOST=construct-sandbox
    secrets:
      - source: construct_env
        target: construct_env
    entrypoint: ["/bin/bash", "-lc"]
    command:
      - |
        if [ -f /run/secrets/construct_env ]; then
          set -a
          . /run/secrets/construct_env
          set +a
        fi
        exec construct gateway start --port "${CONSTRUCT_GATEWAY_PORT:-42617}" --host "[::]"
    volumes:
      # Mount single config file (avoids shadowing other files in .construct)
      - ../target/.construct/config.toml:/construct-data/.construct/config.toml
      # Mount shared workspace
      - ../playground:/construct-data/workspace
    ports:
      - "127.0.0.1:42617:42617"
    networks:
      - dev-net

  # ── The Sandbox (Ubuntu Environment) ──
  # A fully loaded Ubuntu environment for the agent to play in.
  sandbox:
    build:
      context: sandbox # Context relative to dev/
      dockerfile: Dockerfile
    container_name: construct-sandbox
    hostname: dev-box
    command: ["tail", "-f", "/dev/null"]
    working_dir: /home/developer/workspace
    user: developer
    environment:
      - TERM=xterm-256color
      - SHELL=/bin/bash
    volumes:
      - ../playground:/home/developer/workspace # Mount local playground
    networks:
      - dev-net

networks:
  dev-net:
    driver: bridge

secrets:
  construct_env:
    file: ../.env
