diff --git a/.gitignore b/.gitignore index 1fe26d618..967f49a85 100644 --- a/.gitignore +++ b/.gitignore @@ -263,3 +263,4 @@ paket-files/ **/App_Data/IndexBackup **/App_Data/Logs /src/WebApps/**/install-services-core +deployment/.env diff --git a/deployment/.env.template b/deployment/.env.template new file mode 100644 index 000000000..7af5bea9e --- /dev/null +++ b/deployment/.env.template @@ -0,0 +1,28 @@ +# Environment variables for SenseNet Docker Compose configurations +# Copy this file to .env and modify the values as needed + +# Host configuration +COMPUTERNAME=localhost +DOMAIN=localhost + +# Database configuration (for host database scenario) +DATASOURCE=host.docker.internal +SQL_USER=sa +SQL_PASSWORD=SuP3rS3CuR3P4sSw0Rd + +# Certificate password +CERT_PASSWORD=SuP3rS3CuR3P4sSw0Rd + +# RabbitMQ configuration +RABBIT_USER=admin +RABBIT_PASSWORD=SuP3rS3CuR3P4sSw0Rd + +# Volume paths (adjust for your system) +VOLUME_BASE_PATH=./volumes + +# Health check user +HEALTH_CHECK_USER=s3Cur3P4Ss + +# Default admin credentials (change in production) +# Username: admin +# Password: admin \ No newline at end of file diff --git a/deployment/docker-compose.complete-auth.yml b/deployment/docker-compose.complete-auth.yml new file mode 100644 index 000000000..513926b4c --- /dev/null +++ b/deployment/docker-compose.complete-auth.yml @@ -0,0 +1,196 @@ +# Complete SenseNet setup with Search Service, RabbitMQ, Volumes, and SNAuth +# Equivalent to: .\install-sensenet.ps1 -SearchService -UseVolume -UseAuth + +networks: + sensenet: + name: sensenet-complete-auth + driver: bridge + +volumes: + sensenet-sql-data: + name: sensenet-sql-data + sensenet-app-data: + name: sensenet-app-data + sensenet-search-data: + name: sensenet-search-data + sensenet-rabbit-data: + name: sensenet-rabbit-data + +services: + # SQL Server Database with persistent volume + sensenet-insql-cdb-wv-ws-snsql: + image: mcr.microsoft.com/mssql/server:2019-CU12-ubuntu-20.04 + container_name: sensenet-insql-cdb-wv-ws-snsql + environment: + - ACCEPT_EULA=Y + - SA_PASSWORD=SuP3rS3CuR3P4sSw0Rd + - MSSQL_PID=Express + networks: + - sensenet + restart: unless-stopped + volumes: + - sensenet-sql-data:/var/opt/mssql + healthcheck: + test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "SuP3rS3CuR3P4sSw0Rd" -Q "SELECT 1" + interval: 30s + timeout: 10s + retries: 5 + + # Database Initialization + sensenet-db-init: + image: mcr.microsoft.com/mssql/server:2019-CU12-ubuntu-20.04 + container_name: sensenet-db-init + networks: + - sensenet + volumes: + - ./scripts:/scripts:ro + command: > + bash -c " + echo 'Waiting for SQL Server to be ready...'; + until /opt/mssql-tools/bin/sqlcmd -S sensenet-insql-cdb-wv-ws-snsql -U sa -P 'SuP3rS3CuR3P4sSw0Rd' -Q 'SELECT 1' > /dev/null 2>&1; do + echo 'SQL Server is not ready yet... waiting'; + sleep 2; + done; + echo 'SQL Server is ready! Creating database...'; + /opt/mssql-tools/bin/sqlcmd -S sensenet-insql-cdb-wv-ws-snsql -U sa -P 'SuP3rS3CuR3P4sSw0Rd' -Q \"IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'sensenet-insql-cdb-wv-ws-sndb') CREATE DATABASE [sensenet-insql-cdb-wv-ws-sndb]\"; + echo 'Database created successfully!'; + " + depends_on: + sensenet-insql-cdb-wv-ws-snsql: + condition: service_healthy + restart: "no" + + # RabbitMQ for Search Service messaging with persistent volume + sensenet-rabbit: + image: rabbitmq:3-management + container_name: sensenet-rabbit + environment: + - RABBITMQ_DEFAULT_USER=admin + - RABBITMQ_DEFAULT_PASS=SuP3rS3CuR3P4sSw0Rd + ports: + - "51005:15672" # Management UI + - "5672:5672" # AMQP port + networks: + - sensenet + restart: unless-stopped + volumes: + - sensenet-rabbit-data:/var/lib/rabbitmq + healthcheck: + test: rabbitmq-diagnostics -q ping + interval: 30s + timeout: 10s + retries: 5 + + # Custom Authentication Service (SenseNet Auth) with volume + sensenet-insql-cdb-wv-ws-snauth: + image: sensenetcsp/sn-auth:preview + container_name: sensenet-insql-cdb-wv-ws-snauth + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=https://+:443;http://+:80 + - ASPNETCORE_Kestrel__Certificates__Default__Password=SuP3rS3CuR3P4sSw0Rd + - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/snapp.pfx + - Authority__Domain=cnt + - Authority__PublicHost=https://localhost:51077 + - Repository__Url=https://localhost:51076 + - Repository__PublicHost=https://localhost:51076 + - Sensenet__Repository__Authentication__ApiKey=pr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Ted + - JwtSettings__Issuer=https://localhost:51077 + - JwtSettings__Audience=sensenet + - JwtSettings__SecretKey=pr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Ted + - JwtSettings__AuthTokenExpiryMinutes=300 + - JwtSettings__MultiFactorAuthExpiryMinutes=300 + - JwtSettings__TokenExpiryMinutes=300 + - JwtSettings__RefreshTokenExpiryDays=15 + - PasswordRecovery__TokenExpiryMinutes=60 + - Registration__IsEnabled=false + - Recaptcha__SiteKey= + - Recaptcha__SecretKey= + - Application__Url=https://localhost:51077 + - Application__AllowedHosts__0=https://adminui.test.sensenet.com + - Application__AllowedHosts__1=https://localhost:51076 + - Application__AllowedHosts__2=http://sensenet-insql-cdb-wv-ws-snapp + - Sensenet__Repository__InnerUrl=http://sensenet-insql-cdb-wv-ws-snapp + ports: + - "51077:443" + networks: + - sensenet + restart: unless-stopped + volumes: + - ./temp/certificates:/https:ro + depends_on: + - sensenet-db-init + - sensenet-insql-cdb-wv-ws-snsql + - sensenet-rabbit + + # Search Service with persistent volume + sensenet-insql-cdb-wv-ws-snsearch: + image: sensenetcsp/sn-searchservice:preview + container_name: sensenet-insql-cdb-wv-ws-snsearch + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=https://+:443 + - ASPNETCORE_Kestrel__Certificates__Default__Password=SuP3rS3CuR3P4sSw0Rd + - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/snapp.pfx + - ConnectionStrings__SnCrMsSql=Persist Security Info=False;Initial Catalog=sensenet-insql-cdb-wv-ws-sndb;Data Source=sensenet-insql-cdb-wv-ws-snsql;User ID=sa;Password=SuP3rS3CuR3P4sSw0Rd;TrustServerCertificate=true + - RabbitMQ__ServiceUrl=amqp://admin:SuP3rS3CuR3P4sSw0Rd@sensenet-rabbit/ + networks: + - sensenet + restart: unless-stopped + volumes: + - ./temp/certificates:/https:ro + - sensenet-search-data:/app/App_Data + depends_on: + sensenet-db-init: + condition: service_completed_successfully + sensenet-insql-cdb-wv-ws-snsql: + condition: service_healthy + sensenet-rabbit: + condition: service_healthy + + # SenseNet Application with Search Service, persistent volumes, and SNAuth + sensenet-insql-cdb-wv-ws-snapp: + image: sensenetcsp/sn-api-sql:preview + container_name: sensenet-insql-cdb-wv-ws-snapp + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=https://+:443;http://+:80 + - ASPNETCORE_Kestrel__Certificates__Default__Password=SuP3rS3CuR3P4sSw0Rd + - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/snapp.pfx + - sensenet__Container__Name=sensenet-insql-cdb-wv-ws-snapp + - sensenet__apikeys__healthcheckeruser=s3Cur3P4Ss + - sensenet__identityManagement__UserProfilesEnabled=false + - sensenet__authentication__authServerType=SNAuth + - sensenet__authentication__authority=https://localhost:51077 + - sensenet__authentication__repositoryUrl=https://localhost:51076 + - sensenet__authentication__AddJwtCookie=false + - ConnectionStrings__SnCrMsSql=Persist Security Info=False;Initial Catalog=sensenet-insql-cdb-wv-ws-sndb;Data Source=sensenet-insql-cdb-wv-ws-snsql;User ID=sa;Password=SuP3rS3CuR3P4sSw0Rd;TrustServerCertificate=true + - sensenet__authentication__metadatahost=http://sensenet-insql-cdb-wv-ws-snauth + - Authentication__Authority=https://sensenet-insql-cdb-wv-ws-snauth + - Authentication__PublicAuthority=https://localhost:51077 + - sensenet__security__HealthCheckUser=s3Cur3P4Ss + - sensenet__authentication__RepositoryAuthenticationEnabled=true + ports: + - "51076:443" + networks: + - sensenet + restart: unless-stopped + volumes: + - ./temp/certificates:/https:ro + - sensenet-app-data:/app/App_Data + depends_on: + sensenet-db-init: + condition: service_completed_successfully + sensenet-insql-cdb-wv-ws-snsql: + condition: service_healthy + sensenet-insql-cdb-wv-ws-snauth: + condition: service_started + sensenet-rabbit: + condition: service_healthy + sensenet-insql-cdb-wv-ws-snsearch: + condition: service_started + healthcheck: + test: ["CMD", "curl", "-f", "-k", "https://localhost:443"] + interval: 30s + timeout: 10s + retries: 5 \ No newline at end of file diff --git a/deployment/docker-compose.with-auth.yml b/deployment/docker-compose.with-auth.yml new file mode 100644 index 000000000..5b5b2567b --- /dev/null +++ b/deployment/docker-compose.with-auth.yml @@ -0,0 +1,129 @@ +# SenseNet with custom authentication service instead of basic IdentityServer +# Equivalent to: .\install-sensenet.ps1 -UseAuth + +networks: + sensenet: + name: sensenet-auth + driver: bridge + +services: + # SQL Server Database + sensenet-insql-cdb-snsql: + image: mcr.microsoft.com/mssql/server:2019-CU12-ubuntu-20.04 + container_name: sensenet-insql-cdb-snsql + environment: + - ACCEPT_EULA=Y + - SA_PASSWORD=SuP3rS3CuR3P4sSw0Rd + - MSSQL_PID=Express + networks: + - sensenet + restart: unless-stopped + healthcheck: + test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "SuP3rS3CuR3P4sSw0Rd" -Q "SELECT 1" + interval: 30s + timeout: 10s + retries: 5 + + # Database Initialization + sensenet-db-init: + image: mcr.microsoft.com/mssql/server:2019-CU12-ubuntu-20.04 + container_name: sensenet-db-init + networks: + - sensenet + volumes: + - ./scripts:/scripts:ro + command: > + bash -c " + echo 'Waiting for SQL Server to be ready...'; + until /opt/mssql-tools/bin/sqlcmd -S sensenet-insql-cdb-snsql -U sa -P 'SuP3rS3CuR3P4sSw0Rd' -Q 'SELECT 1' > /dev/null 2>&1; do + echo 'SQL Server is not ready yet... waiting'; + sleep 2; + done; + echo 'SQL Server is ready! Creating database...'; + /opt/mssql-tools/bin/sqlcmd -S sensenet-insql-cdb-snsql -U sa -P 'SuP3rS3CuR3P4sSw0Rd' -Q \"IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'sensenet-insql-cdb-sndb') CREATE DATABASE [sensenet-insql-cdb-sndb]\"; + echo 'Database created successfully!'; + " + depends_on: + sensenet-insql-cdb-snsql: + condition: service_healthy + restart: "no" + + # Custom Authentication Service (SenseNet Auth) + sensenet-insql-cdb-snauth: + image: sensenetcsp/sn-auth:preview + container_name: sensenet-insql-cdb-snauth + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=https://+:443;http://+:80 + - ASPNETCORE_Kestrel__Certificates__Default__Password=SuP3rS3CuR3P4sSw0Rd + - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/snapp.pfx + - Authority__Domain=cnt + - Authority__PublicHost=https://localhost:51017 + - Repository__Url=https://localhost:51016 + - Repository__PublicHost=https://localhost:51016 + - Sensenet__Repository__Authentication__ApiKey=pr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Ted + - JwtSettings__Issuer=https://localhost:51017 + - JwtSettings__Audience=sensenet + - JwtSettings__SecretKey=pr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Ted + - JwtSettings__AuthTokenExpiryMinutes=300 + - JwtSettings__MultiFactorAuthExpiryMinutes=300 + - JwtSettings__TokenExpiryMinutes=300 + - JwtSettings__RefreshTokenExpiryDays=15 + - PasswordRecovery__TokenExpiryMinutes=60 + - Registration__IsEnabled=false + - Recaptcha__SiteKey= + - Recaptcha__SecretKey= + - Application__Url=https://localhost:51017 + - Application__AllowedHosts__0=https://adminui.test.sensenet.com + - Application__AllowedHosts__1=https://localhost:51016 + - Application__AllowedHosts__2=http://sensenet-insql-cdb-snapp + - Sensenet__Repository__InnerUrl=http://sensenet-insql-cdb-snapp + ports: + - "51017:443" + networks: + - sensenet + restart: unless-stopped + volumes: + - ./temp/certificates:/https:ro + depends_on: + - sensenet-db-init + - sensenet-insql-cdb-snsql + + # SenseNet Application with Custom Auth + sensenet-insql-cdb-snapp: + image: sensenetcsp/sn-api-sql:preview + container_name: sensenet-insql-cdb-snapp + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=https://+:443;http://+:80 + - ASPNETCORE_Kestrel__Certificates__Default__Password=SuP3rS3CuR3P4sSw0Rd + - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/snapp.pfx + - sensenet__Container__Name=sensenet-insql-cdb-snapp + - sensenet__apikeys__healthcheckeruser=s3Cur3P4Ss + - sensenet__identityManagement__UserProfilesEnabled=false + - sensenet__authentication__authServerType=SNAuth + - sensenet__authentication__authority=https://localhost:51017 + - sensenet__authentication__repositoryUrl=https://localhost:51016 + - sensenet__authentication__AddJwtCookie=false + - ConnectionStrings__SnCrMsSql=Persist Security Info=False;Initial Catalog=sensenet-insql-cdb-sndb;Data Source=sensenet-insql-cdb-snsql;User ID=sa;Password=SuP3rS3CuR3P4sSw0Rd;TrustServerCertificate=true + - sensenet__authentication__metadatahost=http://sensenet-insql-cdb-snauth + - Authentication__Authority=https://sensenet-insql-cdb-snauth + - Authentication__PublicAuthority=https://localhost:51017 + - sensenet__security__HealthCheckUser=s3Cur3P4Ss + - sensenet__authentication__RepositoryAuthenticationEnabled=true + ports: + - "51016:443" + networks: + - sensenet + restart: unless-stopped + volumes: + - ./temp/certificates:/https:ro + depends_on: + - sensenet-db-init + - sensenet-insql-cdb-snsql + - sensenet-insql-cdb-snauth + healthcheck: + test: ["CMD", "curl", "-f", "-k", "https://localhost:443"] + interval: 30s + timeout: 10s + retries: 5 \ No newline at end of file diff --git a/deployment/docker-compose.with-search-auth.yml b/deployment/docker-compose.with-search-auth.yml new file mode 100644 index 000000000..b646dd588 --- /dev/null +++ b/deployment/docker-compose.with-search-auth.yml @@ -0,0 +1,180 @@ +# SenseNet with Search Service, RabbitMQ, and SNAuth +# Equivalent to: .\install-sensenet.ps1 -SearchService -UseAuth + +networks: + sensenet: + name: sensenet-search-auth + driver: bridge + +services: + # SQL Server Database + sensenet-insql-cdb-ws-snsql: + image: mcr.microsoft.com/mssql/server:2019-CU12-ubuntu-20.04 + container_name: sensenet-insql-cdb-ws-snsql + environment: + - ACCEPT_EULA=Y + - SA_PASSWORD=SuP3rS3CuR3P4sSw0Rd + - MSSQL_PID=Express + networks: + - sensenet + restart: unless-stopped + healthcheck: + test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "SuP3rS3CuR3P4sSw0Rd" -Q "SELECT 1" + interval: 30s + timeout: 10s + retries: 5 + + # Database Initialization + sensenet-db-init: + image: mcr.microsoft.com/mssql/server:2019-CU12-ubuntu-20.04 + container_name: sensenet-db-init + networks: + - sensenet + volumes: + - ./scripts:/scripts:ro + command: > + bash -c " + echo 'Waiting for SQL Server to be ready...'; + until /opt/mssql-tools/bin/sqlcmd -S sensenet-insql-cdb-ws-snsql -U sa -P 'SuP3rS3CuR3P4sSw0Rd' -Q 'SELECT 1' > /dev/null 2>&1; do + echo 'SQL Server is not ready yet... waiting'; + sleep 2; + done; + echo 'SQL Server is ready! Creating database...'; + /opt/mssql-tools/bin/sqlcmd -S sensenet-insql-cdb-ws-snsql -U sa -P 'SuP3rS3CuR3P4sSw0Rd' -Q \"IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'sensenet-insql-cdb-ws-sndb') CREATE DATABASE [sensenet-insql-cdb-ws-sndb]\"; + echo 'Database created successfully!'; + " + depends_on: + sensenet-insql-cdb-ws-snsql: + condition: service_healthy + restart: "no" + + # RabbitMQ for Search Service messaging + sensenet-rabbit: + image: rabbitmq:3-management + container_name: sensenet-rabbit + environment: + - RABBITMQ_DEFAULT_USER=admin + - RABBITMQ_DEFAULT_PASS=SuP3rS3CuR3P4sSw0Rd + ports: + - "51005:15672" # Management UI + - "5672:5672" # AMQP port + networks: + - sensenet + restart: unless-stopped + healthcheck: + test: rabbitmq-diagnostics -q ping + interval: 30s + timeout: 10s + retries: 5 + + # Custom Authentication Service (SenseNet Auth) + sensenet-insql-cdb-ws-snauth: + image: sensenetcsp/sn-auth:preview + container_name: sensenet-insql-cdb-ws-snauth + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=https://+:443;http://+:80 + - ASPNETCORE_Kestrel__Certificates__Default__Password=SuP3rS3CuR3P4sSw0Rd + - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/snapp.pfx + - Authority__Domain=cnt + - Authority__PublicHost=https://localhost:51057 + - Repository__Url=https://localhost:51056 + - Repository__PublicHost=https://localhost:51056 + - Sensenet__Repository__Authentication__ApiKey=pr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Ted + - JwtSettings__Issuer=https://localhost:51057 + - JwtSettings__Audience=sensenet + - JwtSettings__SecretKey=pr3Gen3R4Tedpr3Gen3R4Tedpr3Gen3R4Ted + - JwtSettings__AuthTokenExpiryMinutes=300 + - JwtSettings__MultiFactorAuthExpiryMinutes=300 + - JwtSettings__TokenExpiryMinutes=300 + - JwtSettings__RefreshTokenExpiryDays=15 + - PasswordRecovery__TokenExpiryMinutes=60 + - Registration__IsEnabled=false + - Recaptcha__SiteKey= + - Recaptcha__SecretKey= + - Application__Url=https://localhost:51057 + - Application__AllowedHosts__0=https://adminui.test.sensenet.com + - Application__AllowedHosts__1=https://localhost:51056 + - Application__AllowedHosts__2=http://sensenet-insql-cdb-ws-snapp + - Sensenet__Repository__InnerUrl=http://sensenet-insql-cdb-ws-snapp + ports: + - "51057:443" + networks: + - sensenet + restart: unless-stopped + volumes: + - ./temp/certificates:/https:ro + depends_on: + - sensenet-db-init + - sensenet-insql-cdb-ws-snsql + - sensenet-rabbit + + # Search Service + sensenet-insql-cdb-ws-snsearch: + image: sensenetcsp/sn-searchservice:preview + container_name: sensenet-insql-cdb-ws-snsearch + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=https://+:443 + - ASPNETCORE_Kestrel__Certificates__Default__Password=SuP3rS3CuR3P4sSw0Rd + - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/snapp.pfx + - ConnectionStrings__SnCrMsSql=Persist Security Info=False;Initial Catalog=sensenet-insql-cdb-ws-sndb;Data Source=sensenet-insql-cdb-ws-snsql;User ID=sa;Password=SuP3rS3CuR3P4sSw0Rd;TrustServerCertificate=true + - RabbitMQ__ServiceUrl=amqp://admin:SuP3rS3CuR3P4sSw0Rd@sensenet-rabbit/ + networks: + - sensenet + restart: unless-stopped + volumes: + - ./temp/certificates:/https:ro + depends_on: + sensenet-db-init: + condition: service_completed_successfully + sensenet-insql-cdb-ws-snsql: + condition: service_healthy + sensenet-rabbit: + condition: service_healthy + + # SenseNet Application with Search Service and SNAuth + sensenet-insql-cdb-ws-snapp: + image: sensenetcsp/sn-api-sql:preview + container_name: sensenet-insql-cdb-ws-snapp + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=https://+:443;http://+:80 + - ASPNETCORE_Kestrel__Certificates__Default__Password=SuP3rS3CuR3P4sSw0Rd + - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/snapp.pfx + - sensenet__Container__Name=sensenet-insql-cdb-ws-snapp + - sensenet__apikeys__healthcheckeruser=s3Cur3P4Ss + - sensenet__identityManagement__UserProfilesEnabled=false + - sensenet__authentication__authServerType=SNAuth + - sensenet__authentication__authority=https://localhost:51057 + - sensenet__authentication__repositoryUrl=https://localhost:51056 + - sensenet__authentication__AddJwtCookie=false + - ConnectionStrings__SnCrMsSql=Persist Security Info=False;Initial Catalog=sensenet-insql-cdb-ws-sndb;Data Source=sensenet-insql-cdb-ws-snsql;User ID=sa;Password=SuP3rS3CuR3P4sSw0Rd;TrustServerCertificate=true + - sensenet__authentication__metadatahost=http://sensenet-insql-cdb-ws-snauth + - Authentication__Authority=https://sensenet-insql-cdb-ws-snauth + - Authentication__PublicAuthority=https://localhost:51057 + - sensenet__security__HealthCheckUser=s3Cur3P4Ss + - sensenet__authentication__RepositoryAuthenticationEnabled=true + ports: + - "51056:443" + networks: + - sensenet + restart: unless-stopped + volumes: + - ./temp/certificates:/https:ro + depends_on: + sensenet-db-init: + condition: service_completed_successfully + sensenet-insql-cdb-ws-snsql: + condition: service_healthy + sensenet-insql-cdb-ws-snauth: + condition: service_started + sensenet-rabbit: + condition: service_healthy + sensenet-insql-cdb-ws-snsearch: + condition: service_started + healthcheck: + test: ["CMD", "curl", "-f", "-k", "https://localhost:443"] + interval: 30s + timeout: 10s + retries: 5 \ No newline at end of file diff --git a/deployment/scripts/helper-functions.ps1 b/deployment/scripts/helper-functions.ps1 index 9e2772594..9eeee277e 100644 --- a/deployment/scripts/helper-functions.ps1 +++ b/deployment/scripts/helper-functions.ps1 @@ -473,4 +473,73 @@ Function Wait-SnApp { } } Until ($isSnAppAvailable) } +} + +Function Manage-Container { + Param ( + [Parameter(Mandatory=$True)] + [string]$ContainerName, + [Parameter(Mandatory=$True)] + [string[]]$DockerRunParams, + [Parameter(Mandatory=$False)] + [bool]$DryRun=$False + ) + + if ($DryRun) { + Write-Output "DryRun: Would manage container $ContainerName" + return "created" + } + + # Check if container exists + $containerExists = $false + $containerStatus = "" + + try { + $containerStatus = $(docker container inspect -f "{{.State.Status}}" $ContainerName 2>$null) + if ($LASTEXITCODE -eq 0) { + $containerExists = $true + } + } catch { + $containerExists = $false + } + + if ($containerExists) { + Write-Output "Container $ContainerName already exists with status: $containerStatus" + + if ($containerStatus -eq "running") { + Write-Output "Container $ContainerName is already running. Skipping creation." + return "running" + } elseif ($containerStatus -eq "exited") { + Write-Output "Container $ContainerName exists but is stopped. Starting container..." + Invoke-Cli -execFile "docker" -params "start", $ContainerName -DryRun $DryRun + if ($LASTEXITCODE -eq 0) { + Write-Output "Container $ContainerName started successfully." + return "started" + } else { + Write-Error "Failed to start existing container $ContainerName" + return "error" + } + } else { + Write-Output "Container $ContainerName is in state: $containerStatus. Removing and recreating..." + Invoke-Cli -execFile "docker" -params "rm", "-f", $ContainerName -DryRun $DryRun + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to remove container $ContainerName" + return "error" + } + } + } + + # Create new container + Write-Output "Creating new container $ContainerName..." + + # Use Invoke-Cli for proper verbose output and error handling + Invoke-Cli -execFile "docker" -params $DockerRunParams -DryRun $DryRun + + if ($LASTEXITCODE -eq 0) { + Write-Output "Container $ContainerName created successfully." + return "created" + } else { + Write-Error "Failed to create container $ContainerName" + return "error" + } } \ No newline at end of file diff --git a/deployment/scripts/install-identity-server.ps1 b/deployment/scripts/install-identity-server.ps1 index 5ecd7104f..7536e9f62 100644 --- a/deployment/scripts/install-identity-server.ps1 +++ b/deployment/scripts/install-identity-server.ps1 @@ -138,8 +138,15 @@ if ($OpenPort) { $params += "$IdentityDockerImage" -Invoke-Cli -execFile $execFile -params $params -DryRun $DryRun -ErrorAction stop -if (-not $UseVolume) { +# Use the new container management function +$containerResult = Manage-Container -ContainerName $IdentityContainerName -DockerRunParams $params -DryRun $DryRun + +if ($containerResult -eq "error") { + Write-Error "Failed to manage container $IdentityContainerName" + return +} + +if (-not $UseVolume -and ($containerResult -eq "created" -or $containerResult -eq "started")) { if (-not (Test-Path "./temp/certificates/$($CertName)")) { Write-Error "Certificate file missing!" } diff --git a/deployment/scripts/install-sensenet-app.ps1 b/deployment/scripts/install-sensenet-app.ps1 index d609b4205..5cefc999c 100644 --- a/deployment/scripts/install-sensenet-app.ps1 +++ b/deployment/scripts/install-sensenet-app.ps1 @@ -69,8 +69,6 @@ Param ( [string]$SqlUser="", [Parameter(Mandatory=$False)] [string]$SqlPsw="", - [Parameter(Mandatory=$False)] - [string]$HealthCheckUser="qwerty", # Search service parameters [Parameter(Mandatory=$False)] @@ -251,9 +249,15 @@ if ($OpenPort) { $params += "$SensenetDockerImage" -Invoke-Cli -execFile $execFile -params $params -DryRun $DryRun -ErrorAction stop +# Use the new container management function +$containerResult = Manage-Container -ContainerName $SensenetContainerName -DockerRunParams $params -DryRun $DryRun + +if ($containerResult -eq "error") { + Write-Error "Failed to manage container $SensenetContainerName" + return +} -if (-not $UseVolume) { +if (-not $UseVolume -and ($containerResult -eq "created" -or $containerResult -eq "started")) { if (-not (Test-Path "./temp/certificates/$($CertName)")) { Write-Error "Certificate file missing!" } diff --git a/deployment/scripts/install-sql-server.ps1 b/deployment/scripts/install-sql-server.ps1 index 8b8dd4322..3445eed08 100644 --- a/deployment/scripts/install-sql-server.ps1 +++ b/deployment/scripts/install-sql-server.ps1 @@ -112,7 +112,14 @@ if ($UseDbContainer) { } $params += $SqlDockerImage - Invoke-Cli -execFile $execFile -params $params -DryRun $DryRun -ErrorAction stop + + # Use the new container management function + $containerResult = Manage-Container -ContainerName $SqlContainerName -DockerRunParams $params -DryRun $DryRun + + if ($containerResult -eq "error") { + Write-Error "Failed to manage container $SqlContainerName" + return + } # wait for docker container to be started Wait-Container -ContainerName $SqlContainerName -DryRun $DryRun -ErrorAction stop @@ -120,8 +127,10 @@ if ($UseDbContainer) { # wait for sql server to be available Wait-CntDbServer -ContainerName $SqlContainerName -UserName $($SqlUser) -UserPsw $($SqlPsw) -DryRun $DryRun -ErrorAction stop - # create empyt database - Invoke-Cli -execFile "docker" -params "exec", $SqlContainerName, "/opt/mssql-tools/bin/sqlcmd", "-U", "$($SqlUser)", "-P", "$($SqlPsw)", "-Q", "CREATE DATABASE [$($SqlDbName)]" -DryRun $DryRun -ErrorAction stop + # create empty database (only if container was newly created) + if ($containerResult -eq "created") { + Invoke-Cli -execFile "docker" -params "exec", $SqlContainerName, "/opt/mssql-tools/bin/sqlcmd", "-U", "$($SqlUser)", "-P", "$($SqlPsw)", "-Q", "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '$($SqlDbName)') CREATE DATABASE [$($SqlDbName)]" -DryRun $DryRun -ErrorAction stop + } } }