feat: Add Docker compose scripts for starting and stopping services with health checks
All checks were successful
Publish Container / publish (push) Successful in 3m14s
All checks were successful
Publish Container / publish (push) Successful in 3m14s
This commit is contained in:
parent
c8c5f0071f
commit
273b8d5a69
3 changed files with 106 additions and 0 deletions
3
.vscode/compose-down.ps1
vendored
Normal file
3
.vscode/compose-down.ps1
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Write-Host "Stopping docker compose (debug)..."
|
||||
docker compose down
|
||||
exit $LASTEXITCODE
|
||||
72
.vscode/compose-up.ps1
vendored
Normal file
72
.vscode/compose-up.ps1
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
param(
|
||||
[int]$TimeoutSeconds = 120
|
||||
)
|
||||
|
||||
Write-Host "Starting docker compose (debug) in detached mode..."
|
||||
docker compose up --build -d
|
||||
$composeExit = $LASTEXITCODE
|
||||
|
||||
$start = [DateTime]::UtcNow
|
||||
$containerSeen = $false
|
||||
while (([DateTime]::UtcNow - $start).TotalSeconds -lt $TimeoutSeconds) {
|
||||
$container = docker ps --filter "name=worktracker-dev" --format "{{.Names}}" 2>$null
|
||||
if ($container -and $container.Trim() -ne "") {
|
||||
if (-not $containerSeen) {
|
||||
Write-Host "Found container: $container"
|
||||
$containerSeen = $true
|
||||
}
|
||||
|
||||
# After container appears, wait a short inner timeout for the app to respond
|
||||
$innerStart = [DateTime]::UtcNow
|
||||
$innerTimeout = 30
|
||||
while (([DateTime]::UtcNow - $innerStart).TotalSeconds -lt $innerTimeout) {
|
||||
try {
|
||||
$resp = Invoke-WebRequest -UseBasicParsing -Uri http://localhost:8002/ -TimeoutSec 2 -ErrorAction Stop
|
||||
if ($resp.StatusCode -ge 200 -and $resp.StatusCode -lt 400) {
|
||||
Write-Host "Application responded (HTTP $($resp.StatusCode)). Ready. Opening browser..."
|
||||
try {
|
||||
Start-Process "http://localhost:8002/"
|
||||
} catch {
|
||||
Write-Host "Failed to open browser: $_"
|
||||
}
|
||||
exit 0
|
||||
}
|
||||
} catch {
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Container started but application did not respond within $innerTimeout seconds. Collecting logs..."
|
||||
break
|
||||
}
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
|
||||
Write-Error "Timed out waiting for container or application to become ready after $TimeoutSeconds seconds. Gathering diagnostics..."
|
||||
|
||||
Write-Host "-- docker compose ps -- (all services) --"
|
||||
try {
|
||||
docker compose ps
|
||||
} catch {
|
||||
Write-Host "(ps failed): $_"
|
||||
}
|
||||
|
||||
Write-Host "-- docker ps -a (filtered) --"
|
||||
try {
|
||||
docker ps -a --filter "name=worktracker-dev"
|
||||
} catch {
|
||||
Write-Host "(docker ps failed): $_"
|
||||
}
|
||||
|
||||
Write-Host "-- docker compose logs (last 200 lines for service 'worktracker') --"
|
||||
try {
|
||||
docker compose logs --no-color --tail 200 worktracker
|
||||
} catch {
|
||||
Write-Host "(logs failed): $_"
|
||||
}
|
||||
|
||||
if ($composeExit -ne 0) {
|
||||
Write-Error "The initial 'docker compose up' returned exit code $composeExit. Check above logs for details."
|
||||
}
|
||||
|
||||
exit 1
|
||||
31
production.env
Normal file
31
production.env
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Production deployment settings for docker-compose.yml
|
||||
|
||||
ASPNETCORE_ENVIRONMENT=Production
|
||||
ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
|
||||
ALLOWED_HOSTS=*
|
||||
USE_HTTPS_REDIRECTION=false
|
||||
|
||||
# Persistent Couchbase Lite database mount
|
||||
WORKTRACKER_DATA_PATH=/mnt/storage/data/worktracker/db
|
||||
COUCHBASELITE_DATABASE_NAME=worktracker
|
||||
|
||||
# Published app port
|
||||
WORKTRACKER_PORT=8002
|
||||
|
||||
# Image reference used by Docker Compose
|
||||
IMAGE_REGISTRY=worktracker
|
||||
IMAGE_TAG=latest
|
||||
|
||||
# Built-in authentication
|
||||
APPAUTH_ENABLED=false
|
||||
APPAUTH_DEFAULT_USERNAME=Admin
|
||||
APPAUTH_DEFAULT_USERID=ADMIN
|
||||
SINGLEUSER_SEED_ON_STARTUP=true
|
||||
SINGLEUSER_USERNAME=admin
|
||||
SINGLEUSER_PASSWORD=disagio-spaghetti-science-adsfg
|
||||
|
||||
# Container healthcheck tuning
|
||||
WORKTRACKER_HEALTHCHECK_INTERVAL=30s
|
||||
WORKTRACKER_HEALTHCHECK_TIMEOUT=5s
|
||||
WORKTRACKER_HEALTHCHECK_START_PERIOD=10s
|
||||
WORKTRACKER_HEALTHCHECK_RETRIES=3
|
||||
Loading…
Add table
Add a link
Reference in a new issue