ops: add PKI and HTTPS ingress

This commit is contained in:
2026-11-04 23:05:11 +03:00
parent 951e554e06
commit 58c9bb027b
26 changed files with 572 additions and 56 deletions
+84 -24
View File
@@ -10,6 +10,20 @@ x-telemetry-environment: &telemetry-environment
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=${DEPLOYMENT_ENVIRONMENT},service.version=${SERVICE_VERSION}
services:
security-bootstrap:
image: alpine:3.24.2
entrypoint: ["/bin/sh", "/install.sh"]
volumes:
- ./.runtime/security:/source:ro
- ./infra/pki/install.sh:/install.sh:ro
- api_security:/target/api
- nginx_security:/target/nginx
- prometheus_security:/target/prometheus
- client_security:/target/client
healthcheck:
disable: true
restart: "no"
postgres:
image: postgres:17.6-alpine3.22
environment:
@@ -123,7 +137,7 @@ services:
networks: [data]
migrate:
image: ${API_IMAGE:-mtusi-messenger:lab6}
image: ${API_IMAGE:-mtusi-messenger:lab7}
command: ["/app/messenger", "migrate"]
environment:
MESSENGER_CONFIG_PATH: /etc/messenger/messenger.yaml
@@ -142,13 +156,14 @@ services:
api:
build: .
image: ${API_IMAGE:-mtusi-messenger:lab6}
image: ${API_IMAGE:-mtusi-messenger:lab7}
environment:
<<: *telemetry-environment
OTEL_SERVICE_NAME: messenger-api
MESSENGER_CONFIG_PATH: /etc/messenger/messenger.yaml
APP_HOST: ${APP_HOST}
APP_PORT: ${APP_PORT}
APP_HEALTH_ADDRESS: ${APP_HEALTH_ADDRESS}
DATABASE_URL: ${DATABASE_URL}
CACHE_URL: ${CACHE_URL}
SWAGGER_PORT: ${SWAGGER_PORT}
@@ -159,9 +174,13 @@ services:
S3_SECRET_KEY: ${S3_SECRET_KEY}
volumes:
- *messenger-config-volume
- api_security:/run/security:ro
expose:
- "8080"
- "8443"
- "9091"
depends_on:
security-bootstrap:
condition: service_completed_successfully
migrate:
condition: service_completed_successfully
valkey:
@@ -169,7 +188,7 @@ services:
s3-bootstrap:
condition: service_completed_successfully
healthcheck:
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:${APP_PORT}/health/ready || exit 1"]
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:8082/health/ready || exit 1"]
interval: 2s
timeout: 1s
start_period: 5s
@@ -180,10 +199,10 @@ services:
mem_limit: ${API_MEMORY}
stop_grace_period: 8s
restart: unless-stopped
networks: [application, data]
networks: [application, data, monitoring]
dispatcher:
image: ${API_IMAGE:-mtusi-messenger:lab6}
image: ${API_IMAGE:-mtusi-messenger:lab7}
command: ["/app/messenger", "dispatch"]
environment:
<<: *telemetry-environment
@@ -211,7 +230,7 @@ services:
networks: [data, monitoring]
worker:
image: ${API_IMAGE:-mtusi-messenger:lab6}
image: ${API_IMAGE:-mtusi-messenger:lab7}
command: ["/app/messenger", "worker"]
environment:
<<: *telemetry-environment
@@ -250,10 +269,14 @@ services:
build:
context: .
target: loadbalancer
image: ${NGINX_IMAGE:-mtusi-nginx:lab6}
image: ${NGINX_IMAGE:-mtusi-nginx:lab7}
ports:
- "${API_BIND_ADDRESS}:8080"
- "${API_BIND_ADDRESS}:8443"
volumes:
- nginx_security:/run/security:ro
depends_on:
security-bootstrap:
condition: service_completed_successfully
api:
condition: service_healthy
healthcheck:
@@ -266,11 +289,29 @@ services:
restart: unless-stopped
networks: [edge, application, monitoring]
security-tests:
profiles: ["security"]
build:
context: .
target: security-test
environment:
PUBLIC_TLS_HOST: nginx
PUBLIC_TLS_PORT: "8443"
API_TLS_ADDRESS: api:8443
METRICS_TLS_ADDRESS: api:9091
SECURITY_DIR: /src/.runtime/security
volumes:
- ./.runtime/security:/src/.runtime/security:ro
depends_on:
nginx:
condition: service_healthy
networks: [edge, application]
swagger:
build:
context: .
target: swagger
image: ${SWAGGER_IMAGE:-mtusi-swagger:lab6}
image: ${SWAGGER_IMAGE:-mtusi-swagger:lab7}
ports:
- "${SWAGGER_BIND_ADDRESS}:8080"
depends_on:
@@ -300,7 +341,7 @@ services:
lab5-experiment:
profiles: ["experiments"]
image: ${API_IMAGE:-mtusi-messenger:lab6}
image: ${API_IMAGE:-mtusi-messenger:lab7}
command: ["/app/lab5experiment"]
environment:
MESSENGER_CONFIG_PATH: /etc/messenger/messenger.yaml
@@ -313,6 +354,7 @@ services:
BROKER_URL: ${BROKER_URL}
volumes:
- *messenger-config-volume
- client_security:/run/security:ro
depends_on:
migrate:
condition: service_completed_successfully
@@ -386,7 +428,7 @@ services:
build:
context: .
target: prometheus
image: ${PROMETHEUS_IMAGE:-mtusi-prometheus:lab6}
image: ${PROMETHEUS_IMAGE:-mtusi-prometheus:lab7}
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
@@ -394,6 +436,7 @@ services:
- --web.enable-remote-write-receiver
volumes:
- prometheus_data:/prometheus
- prometheus_security:/run/security:ro
ports:
- "${PROMETHEUS_BIND_ADDRESS}:9090"
healthcheck:
@@ -402,17 +445,30 @@ services:
timeout: 3s
retries: 20
depends_on:
- api
- nginx-exporter
- postgres-exporter
- valkey-exporter
- redis-broker-exporter
- dispatcher
- worker
- s3
- otel-collector
- loki
- tempo
security-bootstrap:
condition: service_completed_successfully
api:
condition: service_healthy
nginx-exporter:
condition: service_started
postgres-exporter:
condition: service_started
valkey-exporter:
condition: service_started
redis-broker-exporter:
condition: service_started
dispatcher:
condition: service_healthy
worker:
condition: service_healthy
s3:
condition: service_healthy
otel-collector:
condition: service_healthy
loki:
condition: service_healthy
tempo:
condition: service_healthy
cpus: ${PROMETHEUS_CPUS}
mem_limit: ${PROMETHEUS_MEMORY}
restart: unless-stopped
@@ -422,7 +478,7 @@ services:
build:
context: .
target: grafana
image: ${GRAFANA_IMAGE:-mtusi-grafana:lab6}
image: ${GRAFANA_IMAGE:-mtusi-grafana:lab7}
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD}
@@ -507,6 +563,10 @@ services:
networks: [application, data, monitoring]
volumes:
api_security:
nginx_security:
prometheus_security:
client_security:
postgres_data:
valkey_data:
redis_broker_data: