From 09030e65785c5bf22db353360e6aef9f7e9ff1a5 Mon Sep 17 00:00:00 2001 From: febux Date: Mon, 14 Sep 2026 03:09:30 +0300 Subject: [PATCH] Update contract-check.nomad.hcl --- deploy/nomad/contract-check.nomad.hcl | 93 ++++++++++++++------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/deploy/nomad/contract-check.nomad.hcl b/deploy/nomad/contract-check.nomad.hcl index 72a3cd3..7e8b223 100644 --- a/deploy/nomad/contract-check.nomad.hcl +++ b/deploy/nomad/contract-check.nomad.hcl @@ -5,10 +5,12 @@ # docker0 host gateway 172.17.0.1 and the host-published ports # (15432/17379/5672/9000). The nginx edge cascade is unchanged. # -# Env: the compose .env file (~/DealDocumentScreening/.env on the VPS) is -# bind-mounted into every container at /secrets/.env and sourced before the -# app starts. Shell parameter substitution rewrites compose hostnames -# (postgres, redis, rabbitmq, minio) to 172.17.0.1 + published ports. +# Env: a dedicated .env.nomad (copy of compose .env with hostnames rewritten +# to 172.17.0.1 + published ports) is bind-mounted at /secrets/.env and +# sourced before the app starts. Create it once on the VPS: +# cp ~/DealDocumentScreening/.env ~/DealDocumentScreening/.env.nomad +# # edit: @postgres:5432 → @172.17.0.1:15432, @redis:6379 → @172.17.0.1:17379, +# # @rabbitmq:5672 → @172.17.0.1:5672, http://minio:9000 → http://172.17.0.1:9000 # # Image tag uses ${IMAGE_TAG}, rendered by envsubst at submit time. # Registry auth: host-level `docker login` on the VPS (README §5). @@ -66,7 +68,6 @@ job "contract-check" { } } - # One-shot migrations before the API starts. task "migrate" { lifecycle { hook = "prestart" @@ -80,11 +81,11 @@ job "contract-check" { args = ["-c", "set -a; . /secrets/.env; set +a; exec alembic upgrade head"] mounts = [ { - type = "bind" - target = "/secrets/.env" - source = "/root/DealDocumentScreening/.env" - read_only = true - }, + type = "bind" + target = "/secrets/.env" + source = "/root/DealDocumentScreening/.env.nomad" + readonly = true + } ] } @@ -100,15 +101,15 @@ job "contract-check" { config { image = "p2gnl.mu-dungeon.xyz/admin-git/contract-check-api:${IMAGE_TAG}" command = "sh" - args = ["-c", "set -a; . /secrets/.env; set +a; export DATABASE_URL=$${DATABASE_URL/@postgres:/@172.17.0.1:15432:}; export REDIS_URL=$${REDIS_URL/@redis:/@172.17.0.1:17379:}; export RABBITMQ_URL=$${RABBITMQ_URL/@rabbitmq:/@172.17.0.1:5672:}; export S3_ENDPOINT_URL=http://172.17.0.1:9000; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.api"] + args = ["-c", "set -a; . /secrets/.env; set +a; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.api"] ports = ["http"] mounts = [ { - type = "bind" - target = "/secrets/.env" - source = "/root/DealDocumentScreening/.env" - read_only = true - }, + type = "bind" + target = "/secrets/.env" + source = "/root/DealDocumentScreening/.env.nomad" + readonly = true + } ] } @@ -144,14 +145,14 @@ job "contract-check" { config { image = "p2gnl.mu-dungeon.xyz/admin-git/contract-check-worker-extract:${IMAGE_TAG}" command = "sh" - args = ["-c", "set -a; . /secrets/.env; set +a; export DATABASE_URL=$${DATABASE_URL/@postgres:/@172.17.0.1:15432:}; export RABBITMQ_URL=$${RABBITMQ_URL/@rabbitmq:/@172.17.0.1:5672:}; export S3_ENDPOINT_URL=http://172.17.0.1:9000; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_extract"] + args = ["-c", "set -a; . /secrets/.env; set +a; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_extract"] mounts = [ { - type = "bind" - target = "/secrets/.env" - source = "/root/DealDocumentScreening/.env" - read_only = true - }, + type = "bind" + target = "/secrets/.env" + source = "/root/DealDocumentScreening/.env.nomad" + readonly = true + } ] } @@ -185,14 +186,14 @@ job "contract-check" { config { image = "p2gnl.mu-dungeon.xyz/admin-git/contract-check-worker-analyze:${IMAGE_TAG}" command = "sh" - args = ["-c", "set -a; . /secrets/.env; set +a; export DATABASE_URL=$${DATABASE_URL/@postgres:/@172.17.0.1:15432:}; export RABBITMQ_URL=$${RABBITMQ_URL/@rabbitmq:/@172.17.0.1:5672:}; export S3_ENDPOINT_URL=http://172.17.0.1:9000; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_analyze"] + args = ["-c", "set -a; . /secrets/.env; set +a; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_analyze"] mounts = [ { - type = "bind" - target = "/secrets/.env" - source = "/root/DealDocumentScreening/.env" - read_only = true - }, + type = "bind" + target = "/secrets/.env" + source = "/root/DealDocumentScreening/.env.nomad" + readonly = true + } ] } @@ -226,14 +227,14 @@ job "contract-check" { config { image = "p2gnl.mu-dungeon.xyz/admin-git/contract-check-worker-prescreen:${IMAGE_TAG}" command = "sh" - args = ["-c", "set -a; . /secrets/.env; set +a; export DATABASE_URL=$${DATABASE_URL/@postgres:/@172.17.0.1:15432:}; export RABBITMQ_URL=$${RABBITMQ_URL/@rabbitmq:/@172.17.0.1:5672:}; export S3_ENDPOINT_URL=http://172.17.0.1:9000; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_prescreen"] + args = ["-c", "set -a; . /secrets/.env; set +a; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_prescreen"] mounts = [ { - type = "bind" - target = "/secrets/.env" - source = "/root/DealDocumentScreening/.env" - read_only = true - }, + type = "bind" + target = "/secrets/.env" + source = "/root/DealDocumentScreening/.env.nomad" + readonly = true + } ] } @@ -267,14 +268,14 @@ job "contract-check" { config { image = "p2gnl.mu-dungeon.xyz/admin-git/contract-check-worker-billing:${IMAGE_TAG}" command = "sh" - args = ["-c", "set -a; . /secrets/.env; set +a; export DATABASE_URL=$${DATABASE_URL/@postgres:/@172.17.0.1:15432:}; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_billing"] + args = ["-c", "set -a; . /secrets/.env; set +a; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_billing"] mounts = [ { - type = "bind" - target = "/secrets/.env" - source = "/root/DealDocumentScreening/.env" - read_only = true - }, + type = "bind" + target = "/secrets/.env" + source = "/root/DealDocumentScreening/.env.nomad" + readonly = true + } ] } @@ -308,14 +309,14 @@ job "contract-check" { config { image = "p2gnl.mu-dungeon.xyz/admin-git/contract-check-worker-notify:${IMAGE_TAG}" command = "sh" - args = ["-c", "set -a; . /secrets/.env; set +a; export DATABASE_URL=$${DATABASE_URL/@postgres:/@172.17.0.1:15432:}; export RABBITMQ_URL=$${RABBITMQ_URL/@rabbitmq:/@172.17.0.1:5672:}; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_notify"] + args = ["-c", "set -a; . /secrets/.env; set +a; export APP_VERSION=${IMAGE_TAG}; exec python -m src.contract_check.worker_notify"] mounts = [ { - type = "bind" - target = "/secrets/.env" - source = "/root/DealDocumentScreening/.env" - read_only = true - }, + type = "bind" + target = "/secrets/.env" + source = "/root/DealDocumentScreening/.env.nomad" + readonly = true + } ] }