A two-file --env-file dropped the operator file
Browse files at this commit4a2411d2e3066cebc3c514d8ea5aec09b3725a5bParent: 5bb7de4- fix
- a two-file --env-file dropped the operator file
- single channel + env
2 changed files +72 -10
.github/workflows/main.ymlmodified+49 -5
| @@ -376,13 +376,37 @@ jobs: | |||
| 376 | exit 1 | 376 | exit 1 |
| 377 | fi | 377 | fi |
| 378 | chmod 0600 -- "$env_file" | 378 | chmod 0600 -- "$env_file" |
| 379 | - for key in POSTGRES_PASSWORD BUILDER_PASSWORD ZO_ROOT_USER_EMAIL ZO_ROOT_USER_PASSWORD; do | 379 | + for key in POSTGRES_PASSWORD BUILDER_PASSWORD ZO_ROOT_USER_EMAIL ZO_ROOT_USER_PASSWORD AI_SHARED_TOKEN AI_QUIC_ADDR; do |
| 380 | grep -Eq "^${key}=.+" "$env_file" || { | 380 | grep -Eq "^${key}=.+" "$env_file" || { |
| 381 | echo "no non-empty ${key}= line in $env_file — prod must not run on the compose defaults" >&2 | 381 | echo "no non-empty ${key}= line in $env_file — prod must not run on the compose defaults" >&2 |
| 382 | exit 1 | 382 | exit 1 |
| 383 | } | 383 | } |
| 384 | done | 384 | done |
| 385 | 385 | ||
| 386 | + # OPERATOR ORTAMI SURECE ALINIR. podman-compose interpolasyonu ORTAM | ||
| 387 | + # DEGISKENLERINE bakar ve `--env-file` YALNIZ SON dosyayi cozer | ||
| 388 | + # (podman_compose.py:2941-2946, :2559): iki dosyali cagri operator | ||
| 389 | + # dosyasini tamamen dusurur ve stack SESSIZCE compose | ||
| 390 | + # varsayilanlariyla kosar (DATABASE_URL parolasi `hezarfen`, kopru | ||
| 391 | + # tokeni `change-me`) — yukaridaki "bos olamaz" kapisi bunu | ||
| 392 | + # yakalamaz, cunku o dosyayi denetler, compose'un onu kullanip | ||
| 393 | + # kullanmadigini degil (canlida yasandi, 2026-09-17). Bu yuzden | ||
| 394 | + # dosya satir satir okunur: kabuk genisletmesi YOK (deger icindeki | ||
| 395 | + # `$` oldugu gibi kalir), bicim duz KEY=value oldugu icin | ||
| 396 | + # tirnak/`export` aranmaz. | ||
| 397 | + while IFS= read -r satir || [ -n "$satir" ]; do | ||
| 398 | + case "$satir" in ''|'#'*) continue ;; esac | ||
| 399 | + anahtar=${satir%%=*} | ||
| 400 | + deger=${satir#*=} | ||
| 401 | + case "$anahtar" in | ||
| 402 | + ''|*[!A-Za-z0-9_]*) | ||
| 403 | + echo "operator env: gecersiz anahtar adi -- harf/rakam/alt cizgi beklenirdi" >&2 | ||
| 404 | + exit 1 | ||
| 405 | + ;; | ||
| 406 | + esac | ||
| 407 | + export "$anahtar=$deger" | ||
| 408 | + done < "$env_file" | ||
| 409 | + | ||
| 386 | # Rootless podman plus a compose provider; fail with the fix, not | 410 | # Rootless podman plus a compose provider; fail with the fix, not |
| 387 | # a bare command-not-found three steps in. | 411 | # a bare command-not-found three steps in. |
| 388 | command -v podman >/dev/null || { | 412 | command -v podman >/dev/null || { |
| @@ -407,8 +431,10 @@ jobs: | |||
| 407 | printf '%s\n' "$tag" > "$deploy_path/current_tag" | 431 | printf '%s\n' "$tag" > "$deploy_path/current_tag" |
| 408 | 432 | ||
| 409 | # stack.env is deploy-owned (unlike the secrets file): it carries | 433 | # stack.env is deploy-owned (unlike the secrets file): it carries |
| 410 | - # only the image tag, and --env-file order makes it win over the | 434 | + # only the image tag, and it is the ONE `--env-file` compose gets — |
| 411 | - # operator's file for HEZARFEN_TAG. | 435 | + # the operator's values are in the process environment (above). A |
| 436 | + # two-file call would drop the operator file entirely | ||
| 437 | + # (podman_compose.py:2941-2946, :2559). | ||
| 412 | printf 'HEZARFEN_TAG=%s\n' "$tag" > "$deploy_path/stack.env" | 438 | printf 'HEZARFEN_TAG=%s\n' "$tag" > "$deploy_path/stack.env" |
| 413 | 439 | ||
| 414 | # The freshly extracted bundle: compose file and unit are | 440 | # The freshly extracted bundle: compose file and unit are |
| @@ -420,7 +446,7 @@ jobs: | |||
| 420 | rm -f -- "$deploy_path/hezarfen_backend.tar.gz" | 446 | rm -f -- "$deploy_path/hezarfen_backend.tar.gz" |
| 421 | 447 | ||
| 422 | compose_up() { | 448 | compose_up() { |
| 423 | - podman compose --env-file "$env_file" --env-file "$deploy_path/stack.env" up -d --no-build | 449 | + podman compose --env-file "$deploy_path/stack.env" up -d --no-build |
| 424 | } | 450 | } |
| 425 | rollback() { | 451 | rollback() { |
| 426 | if [ -f "$deploy_path/previous_tag" ]; then | 452 | if [ -f "$deploy_path/previous_tag" ]; then |
| @@ -433,7 +459,7 @@ jobs: | |||
| 433 | # First deploy: nothing to roll back to, so stop the | 459 | # First deploy: nothing to roll back to, so stop the |
| 434 | # half-brought-up stack. Plain down — the volumes hold the | 460 | # half-brought-up stack. Plain down — the volumes hold the |
| 435 | # operator's data and postgres's first-boot password. | 461 | # operator's data and postgres's first-boot password. |
| 436 | - podman compose --env-file "$env_file" --env-file "$deploy_path/stack.env" down | 462 | + podman compose --env-file "$deploy_path/stack.env" down |
| 437 | echo 'first deploy failed; stack stopped, volumes kept' >&2 | 463 | echo 'first deploy failed; stack stopped, volumes kept' >&2 |
| 438 | fi | 464 | fi |
| 439 | } | 465 | } |
| @@ -488,6 +514,24 @@ jobs: | |||
| 488 | exit 1 | 514 | exit 1 |
| 489 | ;; | 515 | ;; |
| 490 | esac | 516 | esac |
| 517 | + # OPERATOR SIRLARI KONTEYNERDE MI -- bu iddia olmadan iki dosyali | ||
| 518 | + # `--env-file` sinifi sessizce geri gelebilir: stack compose | ||
| 519 | + # varsayilanlariyla ayaga kalkar ve hicbir sey kirmizi olmaz. En | ||
| 520 | + # guclu hal: konteynerin ortamindaki DEGER, operator dosyasindaki | ||
| 521 | + # DEGERLE birebir ayni olmali. Deger YAZDIRILMAZ. | ||
| 522 | + container_env=$(podman inspect -f '{{range .Config.Env}}{{println .}}{{end}}' "$container") | ||
| 523 | + for cift in "AI_SHARED_TOKEN=$AI_SHARED_TOKEN" "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" "AI_QUIC_ADDR=$AI_QUIC_ADDR" "BUILDER_USERNAME=$BUILDER_USERNAME"; do | ||
| 524 | + ad=${cift%%=*} | ||
| 525 | + case "$container_env" in | ||
| 526 | + *"$cift"*) ;; | ||
| 527 | + *) | ||
| 528 | + echo "container env: $ad operator dosyasindaki degeri TASIMIYOR -- operator env compose'a ulasmamis; rolling back" >&2 | ||
| 529 | + rollback | ||
| 530 | + exit 1 | ||
| 531 | + ;; | ||
| 532 | + esac | ||
| 533 | + done | ||
| 534 | + echo 'ok: operator sirlari konteynerde (AI_SHARED_TOKEN / POSTGRES_PASSWORD / AI_QUIC_ADDR / BUILDER_USERNAME birebir)' | ||
| 491 | echo 'hezarfen_backend_compose is up' | 535 | echo 'hezarfen_backend_compose is up' |
| 492 | REMOTE | 536 | REMOTE |
| 493 | 537 | ||
deploy/hezarfen_backend_compose.servicemodified+23 -5
| @@ -36,11 +36,29 @@ Wants=network-online.target | |||
| 36 | Type=oneshot | 36 | Type=oneshot |
| 37 | RemainAfterExit=yes | 37 | RemainAfterExit=yes |
| 38 | WorkingDirectory=%h/hezarfen_backend | 38 | WorkingDirectory=%h/hezarfen_backend |
| 39 | -# Later --env-file wins for duplicate keys: the operator's secrets file | 39 | +# ORTAM IKI KANALDAN GELIR -- bu bir tercih degil, saglayicinin siniridir: |
| 40 | -# first, the deploy-owned stack.env (HEZARFEN_TAG) second. | 40 | +# * operatorun ayar dosyasi -> `EnvironmentFile=` (systemd dosyayi unit'in |
| 41 | -ExecStart=/usr/bin/podman compose --env-file %h/hezarfen_backend/hezarfen_backend.env --env-file %h/hezarfen_backend/stack.env up -d --no-build | 41 | +# ORTAMINA koyar; compose interpolasyonu ORTAM DEGISKENLERINE bakar) |
| 42 | -# No -v: named volumes must survive stop. | 42 | +# * deploy sahipli stack.env (HEZARFEN_TAG) -> tek `--env-file` |
| 43 | -ExecStop=/usr/bin/podman compose down | 43 | +# |
| 44 | +# NEDEN: `podman compose --env-file A --env-file B` bu saglayicida A'yi HIC | ||
| 45 | +# OKUMAZ. `--env-file` tek degerli bir argumandir (podman_compose.py:2941-2946) | ||
| 46 | +# ve yalniz SON dosya cozulur (:2559 `dotenv_path = os.path.realpath(args.env_file)`). | ||
| 47 | +# Iki dosyali eski cagri operator dosyasini tamamen dusuruyordu: stack compose | ||
| 48 | +# varsayilanlariyla kosuyordu (`DATABASE_URL` parolasi `hezarfen`, kopru tokeni | ||
| 49 | +# `change-me`) ve dosyadaki degerler HIC okunmuyordu -- deploy'un | ||
| 50 | +# "POSTGRES_PASSWORD bos olamaz" kapisi dosyayi denetlerken compose onu | ||
| 51 | +# kullanmadigi icin bu sessiz kaliyordu (canlida yasandi, 2026-09-17). Docker | ||
| 52 | +# Compose v2'nin "sonraki dosya cakisan anahtarda kazanir" davranisi bu | ||
| 53 | +# saglayici icin GECERLI DEGIL. Ortam degiskeni --env-file degerlerini EZER | ||
| 54 | +# (:2562), yani iki kanal cakismaz. | ||
| 55 | +EnvironmentFile=%h/hezarfen_backend/hezarfen_backend.env | ||
| 56 | +# Tek --env-file: yalniz deploy sahipli stack.env (HEZARFEN_TAG). | ||
| 57 | +ExecStart=/usr/bin/podman compose --env-file %h/hezarfen_backend/stack.env up -d --no-build | ||
| 58 | +# No -v: named volumes must survive stop. (`EnvironmentFile=` yukarida oldugu | ||
| 59 | +# icin burada da gerekli degiskenler ortamdadir; saglayici eksik env dosyasini | ||
| 60 | +# bos sozluk sayar -- podman_compose.py:2247-2250.) | ||
| 61 | +ExecStop=/usr/bin/podman compose --env-file %h/hezarfen_backend/stack.env down | ||
| 44 | TimeoutStartSec=180 | 62 | TimeoutStartSec=180 |
| 45 | 63 | ||
| 46 | [Install] | 64 | [Install] |