fix(deploy): auto-migrate on boot + seed admin credentials from env
CI/CD / CI · API (dotnet build + test) (push) Successful in 47s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 43s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m5s
CI/CD / CI · Admin Web (tsc) (push) Successful in 35s
CI/CD / CI · Website (tsc) (push) Successful in 46s
CI/CD / CI · Koja (tsc) (push) Successful in 48s
CI/CD / Deploy · all services (push) Successful in 3m36s

- docker-compose.admin.yml: RUN_MIGRATIONS was hardcoded false → now
  uses ${RUN_MIGRATIONS:-true} so migrations run automatically on deploy
- Both compose files: expose Seed__SystemAdminPhone/Username/Password
  env vars so the seeder sets admin credentials without manual SQL
- .env.example: document SEED_ADMIN_* variables

On next deploy: migrations run, Username='admin' is patched on the
existing admin, and password is hashed from SEED_ADMIN_PASSWORD.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-05-31 20:10:56 +03:30
parent a4975cdb2d
commit 255695e8ae
3 changed files with 15 additions and 1 deletions
+8
View File
@@ -68,6 +68,14 @@ REDIS_PORT=6381
# ── Migrations ──────────────────────────────────────────────────────────────── # ── Migrations ────────────────────────────────────────────────────────────────
RUN_MIGRATIONS=true RUN_MIGRATIONS=true
# ── System admin seed (admin panel login) ─────────────────────────────────────
# On every boot the seeder ensures this admin exists with these credentials.
# Username defaults to "admin" if not set. Password is required to enable
# password login — leave blank to force OTP-only login.
SEED_ADMIN_PHONE=09190345606
SEED_ADMIN_USERNAME=admin
SEED_ADMIN_PASSWORD=change-me-strong-admin-password
# ── Payment: ZarinPal ───────────────────────────────────────────────────────── # ── Payment: ZarinPal ─────────────────────────────────────────────────────────
# Get your merchant ID from: https://panel.zarinpal.com → API → MerchantID # Get your merchant ID from: https://panel.zarinpal.com → API → MerchantID
ZARINPAL_MERCHANT_ID= ZARINPAL_MERCHANT_ID=
+4 -1
View File
@@ -28,7 +28,7 @@ services:
environment: environment:
ASPNETCORE_ENVIRONMENT: "${ASPNETCORE_ENVIRONMENT:-Development}" ASPNETCORE_ENVIRONMENT: "${ASPNETCORE_ENVIRONMENT:-Development}"
ASPNETCORE_URLS: http://+:8080 ASPNETCORE_URLS: http://+:8080
RUN_MIGRATIONS: "false" RUN_MIGRATIONS: "${RUN_MIGRATIONS:-true}"
ConnectionStrings__DefaultConnection: "${DB_CONNECTION_STRING:-Host=postgres;Port=5432;Database=meezi;Username=meezi;Password=meezi_local_pass}" ConnectionStrings__DefaultConnection: "${DB_CONNECTION_STRING:-Host=postgres;Port=5432;Database=meezi;Username=meezi;Password=meezi_local_pass}"
ConnectionStrings__Redis: redis:6379 ConnectionStrings__Redis: redis:6379
Jwt__Key: "${JWT_KEY:-dev-jwt-key-CHANGE-THIS-IN-PRODUCTION-min32chars}" Jwt__Key: "${JWT_KEY:-dev-jwt-key-CHANGE-THIS-IN-PRODUCTION-min32chars}"
@@ -36,6 +36,9 @@ services:
Cors__Origins__1: "${CORS_ORIGIN_0:-http://localhost:3101}" Cors__Origins__1: "${CORS_ORIGIN_0:-http://localhost:3101}"
Kavenegar__ApiKey: "${KAVENEGAR_API_KEY:-}" Kavenegar__ApiKey: "${KAVENEGAR_API_KEY:-}"
Kavenegar__SenderNumber: "${KAVENEGAR_SENDER:-90005671}" Kavenegar__SenderNumber: "${KAVENEGAR_SENDER:-90005671}"
Seed__SystemAdminPhone: "${SEED_ADMIN_PHONE:-}"
Seed__SystemAdminUsername: "${SEED_ADMIN_USERNAME:-admin}"
Seed__SystemAdminPassword: "${SEED_ADMIN_PASSWORD:-}"
ports: ports:
- "${ADMIN_API_PORT:-5081}:8080" - "${ADMIN_API_PORT:-5081}:8080"
healthcheck: healthcheck:
+3
View File
@@ -92,6 +92,9 @@ services:
Snappfood__WebhookSecret: "${SNAPPFOOD_WEBHOOK_SECRET:-meezi-dev-snappfood-secret}" Snappfood__WebhookSecret: "${SNAPPFOOD_WEBHOOK_SECRET:-meezi-dev-snappfood-secret}"
ZarinPal__MerchantId: "${ZARINPAL_MERCHANT_ID:-}" ZarinPal__MerchantId: "${ZARINPAL_MERCHANT_ID:-}"
ZarinPal__Sandbox: "${ZARINPAL_SANDBOX:-true}" ZarinPal__Sandbox: "${ZARINPAL_SANDBOX:-true}"
Seed__SystemAdminPhone: "${SEED_ADMIN_PHONE:-}"
Seed__SystemAdminUsername: "${SEED_ADMIN_USERNAME:-admin}"
Seed__SystemAdminPassword: "${SEED_ADMIN_PASSWORD:-}"
ports: ports:
- "${API_PORT:-5080}:8080" - "${API_PORT:-5080}:8080"
volumes: volumes: