From 56552c0e07095daa109edc1dcd2bbf483cd65a2a Mon Sep 17 00:00:00 2001 From: Mauro Servienti Date: Thu, 4 Dec 2025 15:23:17 +0100 Subject: [PATCH] Programmatically register RavenDB license after the server starts instead of using an environment variable (which might be ignored) --- src/ServiceControl.RavenDB/Dockerfile | 1 - .../sc-container-startup.sh | 29 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/ServiceControl.RavenDB/Dockerfile b/src/ServiceControl.RavenDB/Dockerfile index 2d11600e2e..aa2bd4f03e 100644 --- a/src/ServiceControl.RavenDB/Dockerfile +++ b/src/ServiceControl.RavenDB/Dockerfile @@ -10,7 +10,6 @@ RUN chown 999:999 /var/lib/ravendb/data USER ravendb ENV RAVEN_License_Eula_Accepted=true \ - RAVEN_License_Path=/usr/lib/ravendb/servicecontrol-license.json \ RAVEN_Setup_Mode=None LABEL org.opencontainers.image.source=https://github.com/Particular/ServiceControl \ diff --git a/src/ServiceControl.RavenDB/sc-container-startup.sh b/src/ServiceControl.RavenDB/sc-container-startup.sh index 42fc3cb207..351ad81185 100755 --- a/src/ServiceControl.RavenDB/sc-container-startup.sh +++ b/src/ServiceControl.RavenDB/sc-container-startup.sh @@ -7,4 +7,31 @@ if [[ -d "$LEGACY_PATH" ]]; then exit 1 fi -source /usr/lib/ravendb/scripts/run-raven.sh +source /usr/lib/ravendb/scripts/run-raven.sh & +RAVEN_PID=$! + +# Wait for RavenDB to be ready (with retries) +echo "Waiting for RavenDB to start..." +for i in {1..30}; do + if curl -s http://localhost:8080/admin/stats > /dev/null 2>&1; then + echo "RavenDB is ready!" + break + fi + sleep 1 +done + +# Register license +echo "Registering license..." +LICENSE_JSON=$(cat /usr/lib/ravendb/servicecontrol-license.json) +RESPONSE=$(curl -s -w "\n%{http_code}" -X POST http://localhost:8080/admin/license/activate \ + -H "Content-Type: application/json" \ + -d "$LICENSE_JSON") + +HTTP_CODE=$(echo "$RESPONSE" | tail -n1) +if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 204 ]; then + echo "License registered successfully!" +else + echo "Warning: License registration returned HTTP $HTTP_CODE" +fi + +wait $RAVEN_PID \ No newline at end of file