forked from mtusi2026/mtusi2026lab7
lab7: локальная PKI (public-ca для ingress, internal-ca для сервисов), HTTPS ingress на 8443, без открытого 8080
This commit is contained in:
+18
-12
@@ -21,7 +21,7 @@
|
||||
# every service gets only the secrets it needs. Only the LB publishes ports (loopback only).
|
||||
# Networks: `edge` (lb <-> api); internal (no route outside): `data` (postgres/valkey),
|
||||
# `storage` (s3), `queue` (broker). The API is NOT on `queue`: it never talks to the broker.
|
||||
name: mtusi-lab6
|
||||
name: ${COMPOSE_PROJECT_NAME:-mtusi-lab7}
|
||||
|
||||
x-api-env: &api-env
|
||||
APP_ENV: ${APP_ENV:-lab}
|
||||
@@ -231,7 +231,7 @@ services:
|
||||
context: .
|
||||
args:
|
||||
BUILD_REVISION: ${BUILD_REVISION:-dev}
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab7}
|
||||
command: ["python", "-m", "messenger.migrate"]
|
||||
environment:
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
@@ -250,7 +250,7 @@ services:
|
||||
# One-shot, idempotent S3 bootstrap: both buckets, sentinel object, verification of the access
|
||||
# model (private buckets, least-privilege keys). The ONLY holder of the admin key pair besides s3.
|
||||
s3-init:
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab7}
|
||||
command: ["python", "-m", "messenger.s3_bootstrap"]
|
||||
environment:
|
||||
S3_ENDPOINT: ${S3_ENDPOINT:-http://s3:8333}
|
||||
@@ -292,7 +292,7 @@ services:
|
||||
context: .
|
||||
args:
|
||||
BUILD_REVISION: ${BUILD_REVISION:-dev}
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab7}
|
||||
environment:
|
||||
<<: [*api-env, *otel-env]
|
||||
OTEL_SERVICE_NAME: messenger-api
|
||||
@@ -340,13 +340,15 @@ services:
|
||||
image: haproxy:3.2.26-alpine@sha256:254e6370f01cd654e0744edf607c67f33777c1b6a9dc0d4b28bcba7171460122
|
||||
volumes:
|
||||
- ./infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
secrets:
|
||||
- source: pki_ingress_pem # public-ca leaf + key, SAN localhost/127.0.0.1/::1
|
||||
target: ingress.pem
|
||||
ports:
|
||||
# The ONLY public entry point, on the loopback interfaces only. Both IPv4 and IPv6:
|
||||
# The ONLY public entry point: HTTPS, on the loopback interfaces only. Both IPv4 and IPv6:
|
||||
# on Windows `localhost` resolves to ::1 first, and a refused ::1 connection costs ~2 s
|
||||
# per request before the fallback to 127.0.0.1 (measured in lab 3: 2.0 s vs 0.007 s).
|
||||
- "127.0.0.1:${APP_PUBLISH_PORT:-8080}:8080"
|
||||
- "[::1]:${APP_PUBLISH_PORT:-8080}:8080"
|
||||
- "127.0.0.1:${LB_STATS_PORT:-8404}:8404" # local status page (UP/DOWN of replicas)
|
||||
- "127.0.0.1:${APP_PUBLISH_PORT:-8443}:8443"
|
||||
- "[::1]:${APP_PUBLISH_PORT:-8443}:8443"
|
||||
healthcheck:
|
||||
# Config is valid and the process answers; whether any API is ready is the LB's own job.
|
||||
test: ["CMD-SHELL", "haproxy -c -q -f /usr/local/etc/haproxy/haproxy.cfg && wget -q -O /dev/null http://127.0.0.1:8404/"]
|
||||
@@ -365,7 +367,7 @@ services:
|
||||
# Lab 5: outbox relay + lease reaper (src/messenger/relay.py). One process; a second one would
|
||||
# be safe (SKIP LOCKED) but is not needed. Database + broker only, no S3 keys.
|
||||
relay:
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab7}
|
||||
command: ["python", "-m", "messenger.relay"]
|
||||
environment:
|
||||
<<: [*pipeline-env, *otel-env]
|
||||
@@ -399,7 +401,7 @@ services:
|
||||
# Lab 5: image worker (src/messenger/worker.py). Scalable (`--scale worker=2`): competing
|
||||
# consumers of one queue; the database lease decides who works on a job.
|
||||
worker:
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab7}
|
||||
command: ["python", "-m", "messenger.worker"]
|
||||
environment:
|
||||
<<: [*pipeline-env, *otel-env]
|
||||
@@ -452,7 +454,7 @@ services:
|
||||
# S3 auditor key: Read + List, no Write). On demand: docker compose run --rm auditor
|
||||
auditor:
|
||||
profiles: ["tools"]
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab7}
|
||||
entrypoint: ["python", "-m", "messenger.audit"]
|
||||
command: []
|
||||
environment:
|
||||
@@ -487,7 +489,7 @@ services:
|
||||
# docker compose run --rm jobctl replay <attachment_id> --operator alice --reason "..."
|
||||
jobctl:
|
||||
profiles: ["tools"]
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab7}
|
||||
entrypoint: ["python", "-m", "messenger.jobctl"]
|
||||
command: []
|
||||
environment:
|
||||
@@ -681,3 +683,7 @@ secrets:
|
||||
file: ./secrets/broker_url_worker
|
||||
grafana_admin_password:
|
||||
file: ./secrets/grafana_admin_password
|
||||
# Lab 7 PKI (scripts/init_pki.py). Each service mounts only its own certificate/key and the CA it
|
||||
# verifies peers with; the CA private keys are mounted nowhere.
|
||||
pki_ingress_pem:
|
||||
file: ./secrets/pki/ingress.pem
|
||||
|
||||
Reference in New Issue
Block a user