feat(docker): multi-stage Dockerfiles with npmmirror registry
Rewrites dashboard and finder Dockerfiles to use a clean multi-stage build (deps → builder → runner) that installs npm packages inside Alpine Linux, avoiding the SWC musl binary issue when building from Windows host. Uses registry.npmmirror.com for reliable installs from restricted networks (Iran). - docker/api/Dockerfile: .NET 10 multi-stage build - docker/web/Dockerfile: Node 20-alpine multi-stage, npmmirror - docker/finder/Dockerfile: Node 20-alpine multi-stage, npmmirror - docker/website/Dockerfile: marketing website build - scripts/: PowerShell helper scripts for local dev Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# Checks host ports from .env (or defaults) before docker compose up.
|
||||
param(
|
||||
[string]$EnvFile = ".env"
|
||||
)
|
||||
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location $root
|
||||
|
||||
$defaults = @{
|
||||
WEB_PORT = 3101
|
||||
API_PORT = 5080
|
||||
POSTGRES_PORT = 5434
|
||||
REDIS_PORT = 6381
|
||||
}
|
||||
|
||||
$ports = @{}
|
||||
foreach ($key in $defaults.Keys) { $ports[$key] = $defaults[$key] }
|
||||
|
||||
if (Test-Path $EnvFile) {
|
||||
Get-Content $EnvFile | ForEach-Object {
|
||||
if ($_ -match '^\s*([A-Z_]+)\s*=\s*(\d+)\s*$') {
|
||||
$ports[$Matches[1]] = [int]$Matches[2]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Meezi port check (from $EnvFile or defaults):" -ForegroundColor Cyan
|
||||
$blocked = @()
|
||||
|
||||
foreach ($name in @("WEB_PORT", "API_PORT", "POSTGRES_PORT", "REDIS_PORT")) {
|
||||
$port = $ports[$name]
|
||||
$listener = Get-NetTCPConnection -LocalPort $port -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if ($listener) {
|
||||
Write-Host " [IN USE] $name = $port" -ForegroundColor Red
|
||||
$blocked += $port
|
||||
}
|
||||
else {
|
||||
Write-Host " [OK] $name = $port" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
if ($blocked.Count -gt 0) {
|
||||
Write-Host ""
|
||||
Write-Host "Some ports are busy. Edit .env (copy from .env.example) and pick free ports, then re-run." -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "All ports available. Run: docker compose up -d --build" -ForegroundColor Green
|
||||
exit 0
|
||||
@@ -0,0 +1,39 @@
|
||||
# Pull base images then start the full Meezi stack in Docker.
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Root = Split-Path -Parent $PSScriptRoot
|
||||
Push-Location $Root
|
||||
|
||||
$images = @(
|
||||
"mcr.microsoft.com/dotnet/sdk:10.0",
|
||||
"mcr.microsoft.com/dotnet/aspnet:10.0",
|
||||
"postgres:16-alpine",
|
||||
"redis:7-alpine",
|
||||
"node:20-alpine"
|
||||
)
|
||||
|
||||
Write-Host "Pulling base images (use VPN if pulls time out)..." -ForegroundColor Cyan
|
||||
foreach ($img in $images) {
|
||||
Write-Host " pull $img"
|
||||
docker pull $img
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Failed to pull $img. Enable VPN or configure a registry mirror (see docs/DOCKER.md)." -ForegroundColor Red
|
||||
Pop-Location
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Building and starting all services..." -ForegroundColor Cyan
|
||||
docker compose up -d --build
|
||||
$code = $LASTEXITCODE
|
||||
Pop-Location
|
||||
if ($code -ne 0) { exit $code }
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Meezi is starting:" -ForegroundColor Green
|
||||
Write-Host " Dashboard http://localhost:3101/fa/login"
|
||||
Write-Host " API http://localhost:5080/swagger"
|
||||
Write-Host " Health http://localhost:5080/health"
|
||||
Write-Host ""
|
||||
Write-Host " docker compose ps"
|
||||
Write-Host " docker compose logs -f api"
|
||||
@@ -0,0 +1,19 @@
|
||||
# Start Postgres + Redis in Docker, API + Dashboard on the host (no MCR image pull).
|
||||
# Use when: docker build fails on mcr.microsoft.com / dotnet base images.
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Root = Split-Path -Parent $PSScriptRoot
|
||||
|
||||
Write-Host "Starting Postgres + Redis..." -ForegroundColor Cyan
|
||||
Push-Location $Root
|
||||
docker compose up -d postgres redis
|
||||
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
|
||||
Pop-Location
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Infra ready. In two terminals run:" -ForegroundColor Green
|
||||
Write-Host " API: cd src/Meezi.API; `$env:RUN_MIGRATIONS='true'; dotnet run"
|
||||
Write-Host " Dashboard: cd web/dashboard; npm run dev"
|
||||
Write-Host ""
|
||||
Write-Host " Login: http://localhost:3101/fa/login (demo OTP: 09121234567)"
|
||||
Write-Host " API: http://localhost:5080/swagger"
|
||||
Reference in New Issue
Block a user