diff --git a/templates/test-database-detection.yaml b/templates/test-database-detection.yaml index 8a4d35fc3..c63f92821 100644 --- a/templates/test-database-detection.yaml +++ b/templates/test-database-detection.yaml @@ -1,6 +1,7 @@ # Test Compose File for Database Detection Logic # This file contains various services to test the isDatabaseImage() function # and its contextual analysis capabilities +# Service names indicate expected detection: "database-*" or "application-*" version: '3.8' @@ -10,7 +11,7 @@ services: # ============================================================================= # Standard PostgreSQL database - postgres-main: + database-postgres-main: image: postgres:16 environment: - POSTGRES_USER=admin @@ -27,7 +28,7 @@ services: retries: 5 # MySQL database - mysql-main: + database-mysql-main: image: mysql:8.0 environment: - MYSQL_ROOT_PASSWORD=rootpassword @@ -45,7 +46,7 @@ services: retries: 3 # MongoDB database - mongodb-main: + database-mongodb-main: image: mongo:7 environment: - MONGO_INITDB_ROOT_USERNAME=admin @@ -62,7 +63,7 @@ services: retries: 3 # Redis database - redis-main: + database-redis-main: image: redis:7-alpine environment: - REDIS_PASSWORD=redispass @@ -76,110 +77,8 @@ services: timeout: 3s retries: 3 - # ============================================================================= - # APPLICATIONS WITH DATABASE NAMES (should NOT be detected as databases) - # ============================================================================= - - # SuperTokens - authentication app with postgresql in name - supertokens: - image: registry.supertokens.io/supertokens/supertokens-postgresql:latest - depends_on: - postgres-main: - condition: service_healthy - environment: - - SERVICE_FQDN_SUPERTOKENS_3567 - - API_KEYS=test-api-key - - POSTGRESQL_CONNECTION_URI=postgresql://admin:secret123@postgres-main:5432/maindb - ports: - - "3567:3567" - healthcheck: - test: "bash -c 'exec 3<>/dev/tcp/127.0.0.1/3567 && echo -e \"GET /hello HTTP/1.1\\r\\nhost: 127.0.0.1:3567\\r\\nConnection: close\\r\\n\\r\\n\" >&3 && cat <&3 | grep \"Hello\"'" - interval: 10s - timeout: 5s - retries: 5 - - # Metabase - analytics app that uses databases - metabase: - image: metabase/metabase:latest - depends_on: - postgres-main: - condition: service_healthy - environment: - - SERVICE_FQDN_METABASE_3000 - - MB_DB_TYPE=postgres - - MB_DB_HOST=postgres-main - - MB_DB_PORT=5432 - - MB_DB_DBNAME=maindb - - MB_DB_USER=admin - - MB_DB_PASS=secret123 - ports: - - "3000:3000" - healthcheck: - test: ["CMD", "curl", "--fail", "-I", "http://127.0.0.1:3000/api/health"] - interval: 30s - timeout: 10s - retries: 3 - - # NocoDB - no-code database interface - nocodb: - image: nocodb/nocodb:latest - depends_on: - postgres-main: - condition: service_healthy - environment: - - SERVICE_FQDN_NOCODB_8080 - - DATABASE_URL=postgresql://admin:secret123@postgres-main:5432/maindb - - NC_AUTH_JWT_SECRET=your-secret-key - ports: - - "8080:8080" - volumes: - - nocodb-data:/usr/app/data - healthcheck: - test: ["CMD", "curl", "--fail", "http://127.0.0.1:8080/api/v1/health"] - interval: 20s - timeout: 10s - retries: 3 - - # PostgREST - REST API for PostgreSQL - postgrest: - image: postgrest/postgrest:latest - depends_on: - postgres-main: - condition: service_healthy - environment: - - SERVICE_FQDN_POSTGREST_3001 - - PGRST_DB_URI=postgresql://admin:secret123@postgres-main:5432/maindb - - PGRST_DB_SCHEMA=public - - PGRST_DB_ANON_ROLE=web_anon - ports: - - "3001:3000" - healthcheck: - test: ["CMD", "curl", "--fail", "http://127.0.0.1:3000/"] - interval: 10s - timeout: 5s - retries: 3 - - # ============================================================================= - # EDGE CASES AND TRICKY SCENARIOS - # ============================================================================= - - # App with database-like name but no context - fake-postgres-app: - image: mycompany/postgres-client:latest - environment: - - SERVICE_FQDN_POSTGRES_CLIENT_4000 - - APP_NAME=PostgreSQL Client - - API_ENDPOINT=http://api.example.com - ports: - - "4000:4000" - healthcheck: - test: ["CMD", "curl", "--fail", "http://127.0.0.1:4000/health"] - interval: 15s - timeout: 5s - retries: 3 - # Database with non-standard port - postgres-custom-port: + database-postgres-custom-port: image: postgres:15 environment: - POSTGRES_USER=customuser @@ -196,7 +95,7 @@ services: retries: 5 # MySQL variant with different image - mariadb: + database-mariadb: image: mariadb:11 environment: - MARIADB_ROOT_PASSWORD=mariaroot @@ -213,8 +112,168 @@ services: timeout: 5s retries: 3 + # ============================================================================= + # APPLICATIONS WITH DATABASE NAMES (should NOT be detected as databases) + # ============================================================================= + + # SuperTokens - authentication app with postgresql in name + application-supertokens: + image: registry.supertokens.io/supertokens/supertokens-postgresql:latest + depends_on: + database-postgres-main: + condition: service_healthy + environment: + - SERVICE_FQDN_SUPERTOKENS_3567 + - API_KEYS=test-api-key + - POSTGRESQL_CONNECTION_URI=postgresql://admin:secret123@database-postgres-main:5432/maindb + ports: + - "3567:3567" + healthcheck: + test: "bash -c 'exec 3<>/dev/tcp/127.0.0.1/3567 && echo -e \"GET /hello HTTP/1.1\\r\\nhost: 127.0.0.1:3567\\r\\nConnection: close\\r\\n\\r\\n\" >&3 && cat <&3 | grep \"Hello\"'" + interval: 10s + timeout: 5s + retries: 5 + + # Metabase - analytics app that uses databases + application-metabase: + image: metabase/metabase:latest + depends_on: + database-postgres-main: + condition: service_healthy + environment: + - SERVICE_FQDN_METABASE_3000 + - MB_DB_TYPE=postgres + - MB_DB_HOST=database-postgres-main + - MB_DB_PORT=5432 + - MB_DB_DBNAME=maindb + - MB_DB_USER=admin + - MB_DB_PASS=secret123 + ports: + - "3000:3000" + healthcheck: + test: ["CMD", "curl", "--fail", "-I", "http://127.0.0.1:3000/api/health"] + interval: 30s + timeout: 10s + retries: 3 + + # NocoDB - no-code database interface + application-nocodb: + image: nocodb/nocodb:latest + depends_on: + database-postgres-main: + condition: service_healthy + environment: + - SERVICE_FQDN_NOCODB_8080 + - DATABASE_URL=postgresql://admin:secret123@database-postgres-main:5432/maindb + - NC_AUTH_JWT_SECRET=your-secret-key + ports: + - "8080:8080" + volumes: + - nocodb-data:/usr/app/data + healthcheck: + test: ["CMD", "curl", "--fail", "http://127.0.0.1:8080/api/v1/health"] + interval: 20s + timeout: 10s + retries: 3 + + # PostgREST - REST API for PostgreSQL + application-postgrest: + image: postgrest/postgrest:latest + depends_on: + database-postgres-main: + condition: service_healthy + environment: + - SERVICE_FQDN_POSTGREST_3001 + - PGRST_DB_URI=postgresql://admin:secret123@database-postgres-main:5432/maindb + - PGRST_DB_SCHEMA=public + - PGRST_DB_ANON_ROLE=web_anon + ports: + - "3001:3000" + healthcheck: + test: ["CMD", "curl", "--fail", "http://127.0.0.1:3000/"] + interval: 10s + timeout: 5s + retries: 3 + + # Umami - web analytics with postgresql variant + application-umami-postgresql: + image: ghcr.io/umami-software/umami:postgresql-latest + depends_on: + database-postgres-main: + condition: service_healthy + environment: + - SERVICE_FQDN_UMAMI_3002 + - DATABASE_URL=postgres://admin:secret123@database-postgres-main:5432/maindb + - DATABASE_TYPE=postgres + - APP_SECRET=umami-secret + ports: + - "3002:3000" + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3000/api/heartbeat"] + interval: 5s + timeout: 20s + retries: 10 + + # Twenty CRM custom postgres (should be detected as database) + database-twenty-postgres: + image: twentycrm/twenty-postgres:latest + environment: + - POSTGRES_USER=twentyuser + - POSTGRES_PASSWORD=twentypass + - POSTGRES_DB=twenty + ports: + - "5434:5432" + volumes: + - twenty-postgres-data:/bitnami/postgresql + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] + interval: 5s + timeout: 20s + retries: 10 + + # Infisical - secret management with postgres variant + application-infisical-postgres: + image: infisical/infisical:latest-postgres + depends_on: + database-postgres-main: + condition: service_healthy + environment: + - SERVICE_FQDN_INFISICAL_8080 + - SITE_URL=http://localhost:8080 + - NODE_ENV=production + - ENCRYPTION_KEY=infisical-encryption-key + - AUTH_SECRET=infisical-auth-secret + - DB_CONNECTION_URI=postgres://admin:secret123@database-postgres-main:5432/maindb + - REDIS_URL=redis://database-redis-main:6379 + ports: + - "8081:8080" + healthcheck: + test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://127.0.0.1:8080/api/status || exit 1"] + interval: 15s + timeout: 10s + retries: 3 + + # ============================================================================= + # EDGE CASES AND TRICKY SCENARIOS + # ============================================================================= + + # App with database-like name but no context + application-fake-postgres-client: + image: mycompany/postgres-client:latest + environment: + - SERVICE_FQDN_POSTGRES_CLIENT_4000 + - APP_NAME=PostgreSQL Client + - API_ENDPOINT=http://api.example.com + ports: + - "4000:4000" + healthcheck: + test: ["CMD", "curl", "--fail", "http://127.0.0.1:4000/health"] + interval: 15s + timeout: 5s + retries: 3 + # App that connects to external database - web-app-external-db: + application-webapp-external-db: image: node:18-alpine environment: - SERVICE_FQDN_WEBAPP_8000 @@ -231,18 +290,18 @@ services: retries: 3 # Redis-based app (not a database itself) - redis-app: + application-redis-commander: image: redis-commander:latest depends_on: - redis-main: + database-redis-main: condition: service_healthy environment: - SERVICE_FQDN_REDIS_COMMANDER_8081 - - REDIS_HOSTS=local:redis-main:6379 + - REDIS_HOSTS=local:database-redis-main:6379 - HTTP_USER=admin - HTTP_PASSWORD=admin ports: - - "8081:8081" + - "8082:8081" healthcheck: test: ["CMD", "curl", "--fail", "http://127.0.0.1:8081/"] interval: 15s @@ -250,21 +309,21 @@ services: retries: 3 # MongoDB management interface - mongo-express: + application-mongo-express: image: mongo-express:latest depends_on: - mongodb-main: + database-mongodb-main: condition: service_healthy environment: - SERVICE_FQDN_MONGO_EXPRESS_8082 - - ME_CONFIG_MONGODB_SERVER=mongodb-main + - ME_CONFIG_MONGODB_SERVER=database-mongodb-main - ME_CONFIG_MONGODB_PORT=27017 - ME_CONFIG_MONGODB_ADMINUSERNAME=admin - ME_CONFIG_MONGODB_ADMINPASSWORD=password - ME_CONFIG_BASICAUTH_USERNAME=mongouser - ME_CONFIG_BASICAUTH_PASSWORD=mongopass ports: - - "8082:8081" + - "8083:8081" healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://127.0.0.1:8081/"] interval: 20s @@ -276,14 +335,14 @@ services: # ============================================================================= # Nginx web server - nginx: + application-nginx: image: nginx:alpine environment: - SERVICE_FQDN_NGINX_80 - NGINX_HOST=localhost - NGINX_PORT=80 ports: - - "8080:80" + - "8084:80" volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro healthcheck: @@ -293,14 +352,14 @@ services: retries: 3 # Node.js application - node-app: + application-node-app: image: node:18-alpine environment: - SERVICE_FQDN_NODEAPP_3002 - NODE_ENV=production - PORT=3000 ports: - - "3002:3000" + - "3003:3000" command: ["node", "index.js"] healthcheck: test: ["CMD", "curl", "--fail", "http://127.0.0.1:3000/api/health"] @@ -315,4 +374,5 @@ volumes: mariadb-data: mongo-data: redis-data: - nocodb-data: \ No newline at end of file + nocodb-data: + twenty-postgres-data: \ No newline at end of file