x-env: &default-env TZ: ${TZ} PUID: "1000" PGID: "1000" # Configuration DNS et réseau pour 4NK_IA_back x-4nk-ia-extra-hosts: &x-4nk-ia-extra-hosts extra_hosts: - "4nk-ia-api.local:172.23.0.10" - "4nk-ia-worker.local:172.23.0.11" - "4nk-ia-postgres.local:172.23.0.12" - "4nk-ia-redis.local:172.23.0.13" - "4nk-ia-minio.local:172.23.0.14" - "4nk-ia-ollama.local:172.23.0.15" - "4nk-ia-anythingllm.local:172.23.0.16" - "4nk-ia-neo4j.local:172.23.0.17" - "4nk-ia-opensearch.local:172.23.0.18" services: # ==================== SERVICES DE BASE ==================== postgres: <<: *x-4nk-ia-extra-hosts image: postgres:16 container_name: 4nk-ia-postgres.local hostname: 4nk-ia-postgres.local environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} volumes: - pgdata:/var/lib/postgresql/data ports: - "5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 10s timeout: 5s retries: 5 restart: unless-stopped profiles: ["production", "development"] dns: - 172.23.0.1 # Gateway Docker pour accéder à dnsmasq networks: 4nk_ia_network: ipv4_address: 172.23.0.12 postgres-test: image: postgres:16 container_name: 4nk-ia-postgres-test.local hostname: 4nk-ia-postgres-test.local environment: POSTGRES_USER: test_notariat POSTGRES_PASSWORD: test_pwd POSTGRES_DB: test_notariat volumes: - pgdata_test:/var/lib/postgresql/data ports: - "5433:5432" restart: unless-stopped profiles: ["test"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.22 redis: <<: *x-4nk-ia-extra-hosts image: redis:7 container_name: 4nk-ia-redis.local hostname: 4nk-ia-redis.local command: ["redis-server", "--appendonly", "yes"] volumes: - redis:/data ports: - "6379:6379" restart: unless-stopped profiles: ["production", "development"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.13 redis-test: image: redis:7 container_name: 4nk-ia-redis-test.local hostname: 4nk-ia-redis-test.local command: ["redis-server", "--appendonly", "yes"] volumes: - redis_test:/data ports: - "6380:6379" restart: unless-stopped profiles: ["test"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.23 minio: <<: *x-4nk-ia-extra-hosts image: minio/minio:latest container_name: 4nk-ia-minio.local hostname: 4nk-ia-minio.local command: server /data --console-address ":9001" environment: MINIO_ROOT_USER: ${MINIO_ROOT_USER} MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD} volumes: - minio:/data ports: - "9000:9000" - "9001:9001" restart: unless-stopped profiles: ["production", "development"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.14 minio-test: image: minio/minio:latest container_name: 4nk-ia-minio-test.local hostname: 4nk-ia-minio-test.local command: server /data --console-address ":9001" environment: MINIO_ROOT_USER: test_minio MINIO_ROOT_PASSWORD: test_minio_pwd volumes: - minio_test:/data ports: - "9002:9000" - "9003:9001" restart: unless-stopped profiles: ["test"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.24 # ==================== SERVICES IA ET RAG ==================== ollama: <<: *x-4nk-ia-extra-hosts image: ollama/ollama:latest container_name: 4nk-ia-ollama.local hostname: 4nk-ia-ollama.local volumes: - ollama:/root/.ollama ports: - "11435:11434" # Port modifié pour éviter les conflits environment: - OLLAMA_HOST=0.0.0.0 restart: unless-stopped profiles: ["production", "development"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.15 ollama-test: image: ollama/ollama:latest container_name: 4nk-ia-ollama-test.local hostname: 4nk-ia-ollama-test.local volumes: - ollama_test:/root/.ollama ports: - "11436:11434" environment: - OLLAMA_HOST=0.0.0.0 restart: unless-stopped profiles: ["test"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.25 anythingsqlite: <<: *x-4nk-ia-extra-hosts image: mintplexlabs/anythingllm:latest container_name: 4nk-ia-anythingllm.local hostname: 4nk-ia-anythingllm.local environment: - DISABLE_AUTH=true - STORAGE_DIR=/app/server/storage depends_on: - ollama ports: - "3001:3001" volumes: - anythingllm:/app/server/storage restart: unless-stopped profiles: ["production", "development"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.16 anythingsqlite-test: image: mintplexlabs/anythingllm:latest container_name: 4nk-ia-anythingllm-test.local hostname: 4nk-ia-anythingllm-test.local environment: - DISABLE_AUTH=true - STORAGE_DIR=/app/server/storage depends_on: - ollama-test ports: - "3002:3001" volumes: - anythingllm_test:/app/server/storage restart: unless-stopped profiles: ["test"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.26 # ==================== SERVICES DE DONNÉES ==================== neo4j: <<: *x-4nk-ia-extra-hosts image: neo4j:5 container_name: 4nk-ia-neo4j.local hostname: 4nk-ia-neo4j.local environment: - NEO4J_AUTH=${NEO4J_AUTH} volumes: - neo4j:/data ports: - "7474:7474" - "7687:7687" restart: unless-stopped profiles: ["production", "development"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.17 opensearch: <<: *x-4nk-ia-extra-hosts image: opensearchproject/opensearch:2.14.0 container_name: 4nk-ia-opensearch.local hostname: 4nk-ia-opensearch.local environment: - discovery.type=single-node - OPENSEARCH_INITIAL_ADMIN_PASSWORD=OpenSearch2025! ulimits: memlock: soft: -1 hard: -1 volumes: - opensearch:/usr/share/opensearch/data ports: - "9200:9200" restart: unless-stopped profiles: ["production", "development"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.18 # ==================== SERVICES APPLICATIFS ==================== host-api: <<: *x-4nk-ia-extra-hosts build: context: ./docker/host-api dockerfile: Dockerfile container_name: 4nk-ia-api.local hostname: 4nk-ia-api.local labels: - logging=promtail - project=4nk_ia_back env_file: ./.env environment: <<: *default-env DATABASE_URL: postgresql+psycopg://$POSTGRES_USER:$POSTGRES_PASSWORD@4nk-ia-postgres.local:5432/$POSTGRES_DB REDIS_URL: redis://4nk-ia-redis.local:6379/0 MINIO_ENDPOINT: 4nk-ia-minio.local:9000 MINIO_BUCKET: ${MINIO_BUCKET} ANYLLM_BASE_URL: http://4nk-ia-anythingllm.local:3001 ANYLLM_API_KEY: ${ANYLLM_API_KEY} OLLAMA_BASE_URL: http://4nk-ia-ollama.local:11434 OPENSEARCH_URL: http://4nk-ia-opensearch.local:9200 NEO4J_URL: bolt://4nk-ia-neo4j.local:7687 NEO4J_AUTH: ${NEO4J_AUTH} # Configuration de l'API API_HOST: 0.0.0.0 API_PORT: 8000 API_WORKERS: 4 LOG_LEVEL: ${LOG_LEVEL:-INFO} LOG_FORMAT: ${LOG_FORMAT:-json} # Sécurité SECRET_KEY: ${SECRET_KEY:-your_secret_key_here} ACCESS_TOKEN_EXPIRE_MINUTES: ${ACCESS_TOKEN_EXPIRE_MINUTES:-30} volumes: - ./services/host_api:/app - ./ops/seed:/seed:ro - ./ops/seed/schemas:/schemas:ro - api_logs:/app/logs ports: - "8001:8000" # Port externe 8001 pour éviter les conflits depends_on: postgres: condition: service_healthy redis: condition: service_started minio: condition: service_started healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/api/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s restart: unless-stopped profiles: ["production"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.10 host-api-dev: <<: *x-4nk-ia-extra-hosts build: context: ./docker/host-api dockerfile: Dockerfile container_name: 4nk-ia-api-dev.local hostname: 4nk-ia-api-dev.local volumes: - ./services/host_api:/app - ./ops/seed:/seed:ro environment: - DEBUG=true - LOG_LEVEL=debug - DATABASE_URL=postgresql+psycopg://notariat:notariat_pwd@4nk-ia-postgres.local:5432/notariat - REDIS_URL=redis://4nk-ia-redis.local:6379/0 ports: - "8000:8000" # Port de développement command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] depends_on: - postgres - redis - minio restart: unless-stopped profiles: ["development"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.30 worker: <<: *x-4nk-ia-extra-hosts build: context: ./ dockerfile: docker/worker/Dockerfile container_name: 4nk-ia-worker.local hostname: 4nk-ia-worker.local labels: - logging=promtail - project=4nk_ia_back env_file: ./.env environment: <<: *default-env DATABASE_URL: postgresql+psycopg://$POSTGRES_USER:$POSTGRES_PASSWORD@4nk-ia-postgres.local:5432/$POSTGRES_DB REDIS_URL: redis://4nk-ia-redis.local:6379/0 MINIO_ENDPOINT: 4nk-ia-minio.local:9000 MINIO_BUCKET: ${MINIO_BUCKET} ANYLLM_BASE_URL: http://4nk-ia-anythingllm.local:3001 ANYLLM_API_KEY: ${ANYLLM_API_KEY} OLLAMA_BASE_URL: http://4nk-ia-ollama.local:11434 OPENSEARCH_URL: http://4nk-ia-opensearch.local:9200 NEO4J_URL: bolt://4nk-ia-neo4j.local:7687 NEO4J_AUTH: ${NEO4J_AUTH} volumes: - ./services/worker:/app - ./ops/seed:/seed:ro depends_on: - host-api restart: unless-stopped profiles: ["production"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.11 worker-dev: <<: *x-4nk-ia-extra-hosts build: context: ./docker/worker container_name: 4nk-ia-worker-dev.local hostname: 4nk-ia-worker-dev.local volumes: - ./services/worker:/app - ./ops/seed:/seed:ro environment: - DEBUG=true - LOG_LEVEL=debug - DATABASE_URL=postgresql+psycopg://notariat:notariat_pwd@4nk-ia-postgres.local:5432/notariat - REDIS_URL=redis://4nk-ia-redis.local:6379/0 command: ["celery", "-A", "worker", "worker", "--loglevel=debug"] depends_on: - host-api-dev restart: unless-stopped profiles: ["development"] dns: - 172.23.0.1 networks: 4nk_ia_network: ipv4_address: 172.23.0.31 volumes: # Volumes de production/développement pgdata: redis: minio: ollama: neo4j: opensearch: anythingllm: api_logs: # Volumes de test pgdata_test: redis_test: minio_test: ollama_test: anythingllm_test: networks: 4nk_ia_network: driver: bridge ipam: config: - subnet: 172.23.0.0/16 gateway: 172.23.0.1