From 0e8815f3b968fff08973bc2ad7704dee170413eb Mon Sep 17 00:00:00 2001 From: adityamparikh Date: Mon, 9 Mar 2026 23:26:39 -0400 Subject: [PATCH] feat(config): enable Docker Compose auto-start in HTTP mode only Spring Boot Docker Compose integration now starts automatically when running locally with the HTTP profile (PROFILES=http ./gradlew bootRun). In STDIO mode, Docker Compose is explicitly disabled because STDIO requires a clean stdout channel and container management is not useful for that transport. The Jib container image already disables Docker Compose via SPRING_DOCKER_COMPOSE_ENABLED=false; an expanded comment explains why. Also updates all documentation to prefer the PROFILES environment variable over the --spring.profiles.active flag for consistency with the runtime configuration approach used by Docker and the JAR launcher. Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: adityamparikh --- build.gradle.kts | 6 ++++++ dev-docs/DEVELOPMENT.md | 7 +++++-- dev-docs/TROUBLESHOOTING.md | 4 ++-- docs/AUTH0_SETUP.md | 10 +--------- src/main/resources/application-http.properties | 3 +++ src/main/resources/application-stdio.properties | 3 +++ 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 496f8cc..a0bc4cf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -414,6 +414,12 @@ jib { environment = mapOf( // Disable Spring Boot Docker Compose support when running in container + // Docker Compose integration is disabled in the container image. + // It is only useful for local development (HTTP profile) where + // the host has Docker and a compose.yaml. Inside a container, + // Docker Compose cannot start sibling containers without a + // Docker socket mount, so it must be turned off. + // The application-stdio.properties also disables it for STDIO mode. "SPRING_DOCKER_COMPOSE_ENABLED" to "false", ) diff --git a/dev-docs/DEVELOPMENT.md b/dev-docs/DEVELOPMENT.md index 5ccc4c1..a9624c1 100644 --- a/dev-docs/DEVELOPMENT.md +++ b/dev-docs/DEVELOPMENT.md @@ -65,9 +65,12 @@ java -jar build/libs/solr-mcp-1.0.0-SNAPSHOT.jar #### HTTP Mode ```bash -./gradlew bootRun --args='--spring.profiles.active=http' +PROFILES=http ./gradlew bootRun ``` +Spring Boot Docker Compose will automatically start the services declared in `compose.yaml` +(Solr, ZooKeeper, and optionally LGTM for observability) before the application starts. + The server will start on http://localhost:8080 ### Environment Variables @@ -131,7 +134,7 @@ The [MCP Inspector](https://github.com/modelcontextprotocol/inspector) provides ```bash # Start the server in HTTP mode -./gradlew bootRun --args='--spring.profiles.active=http' +PROFILES=http ./gradlew bootRun # In another terminal, start MCP Inspector npx @modelcontextprotocol/inspector diff --git a/dev-docs/TROUBLESHOOTING.md b/dev-docs/TROUBLESHOOTING.md index c18f232..2e14db4 100644 --- a/dev-docs/TROUBLESHOOTING.md +++ b/dev-docs/TROUBLESHOOTING.md @@ -275,7 +275,7 @@ rm -rf .gradle 1. **Verify server is running in HTTP mode** ```bash - ./gradlew bootRun --args='--spring.profiles.active=http' + PROFILES=http ./gradlew bootRun ``` 2. **Check port is correct** @@ -408,7 +408,7 @@ If you're still having issues: ./gradlew bootRun 2>&1 | tee server.log # HTTP mode - Spring Boot logging -./gradlew bootRun --args='--spring.profiles.active=http' +PROFILES=http ./gradlew bootRun ``` ### Solr Logs diff --git a/docs/AUTH0_SETUP.md b/docs/AUTH0_SETUP.md index 1672621..4d1027d 100644 --- a/docs/AUTH0_SETUP.md +++ b/docs/AUTH0_SETUP.md @@ -287,15 +287,7 @@ OAUTH2_ISSUER_URI=https://your-tenant.auth0.com/ The application must run in `http` profile to enable OAuth2 security: ```bash -# Option 1: Using environment variable -export PROFILES=http -./gradlew bootRun - -# Option 2: Using Spring Boot argument -./gradlew bootRun --args='--spring.profiles.active=http' - -# Option 3: Using Gradle property -./gradlew bootRun -Dspring.profiles.active=http +PROFILES=http ./gradlew bootRun ``` ### Application Configuration Details diff --git a/src/main/resources/application-http.properties b/src/main/resources/application-http.properties index ac30dfc..d5dc693 100644 --- a/src/main/resources/application-http.properties +++ b/src/main/resources/application-http.properties @@ -2,6 +2,9 @@ spring.main.web-application-type=servlet spring.ai.mcp.server.type=sync spring.ai.mcp.server.protocol=stateless spring.ai.mcp.server.stdio=false +# Docker Compose integration: automatically start Solr and other services on bootRun. +# Spring Boot detects compose.yaml and starts declared services before the application context. +spring.docker.compose.enabled=true # OAuth2 Security Configuration # Configure the issuer URI for your OAuth2 authorization server # For Auth0: https:///.well-known/openid-configuration diff --git a/src/main/resources/application-stdio.properties b/src/main/resources/application-stdio.properties index f72e9e8..b8864df 100644 --- a/src/main/resources/application-stdio.properties +++ b/src/main/resources/application-stdio.properties @@ -7,3 +7,6 @@ spring.ai.mcp.server.stdio=true spring.autoconfigure.exclude=\ org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration +# Docker Compose integration is only useful in HTTP mode for local development. +# Disable it in STDIO mode to avoid startup delays and unexpected container management. +spring.docker.compose.enabled=false