/ docker-compose.test.yml
docker-compose.test.yml
 1  # =============================================================================
 2  # Test-Only Docker Compose Override
 3  # =============================================================================
 4  #
 5  # This file adds test-specific configuration to the production Docker setup.
 6  # It is used ONLY when running tests via: ./run.sh test
 7  #
 8  # Usage:
 9  #   docker compose -f docker-compose.yml -f docker-compose.test.yml <command>
10  #
11  # What this does:
12  #   1. Mounts the test sudoers file to a staging location (/config/test/)
13  #   2. Uses entrypoint-test.sh to copy and set correct permissions (440, root:root)
14  #   3. Sets AG3NTUM_TEST_MODE=true environment variable
15  #
16  # SECURITY:
17  #   - Test sudoers rules are NOT baked into the Docker image
18  #   - They are only active when explicitly using this override
19  #   - Production deployments should NEVER include this file
20  #   - entrypoint-test.sh validates sudoers syntax before installing
21  #
22  # =============================================================================
23  
24  services:
25    ag3ntum-api:
26      # Additional volumes for test configuration
27      # Mount test sudoers to staging area - entrypoint-test.sh will copy with correct permissions
28      volumes:
29        - ./config/test/sudoers-test:/config/test/sudoers-test:ro
30        - ./entrypoint-test.sh:/entrypoint-test.sh:ro
31  
32      # Run as root initially to install test sudoers, then entrypoint drops to ag3ntum_api
33      user: root
34  
35      # Override entrypoint to install test sudoers before starting
36      entrypoint: ["/bin/bash", "/entrypoint-test.sh"]
37      # The test entrypoint installs sudoers as root, then execs uvicorn as ag3ntum_api
38      command: ["/opt/venv/bin/uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "40080", "--workers", "4"]
39  
40      # Test-specific environment variables
41      environment:
42        AG3NTUM_TEST_MODE: "true"