feat: add local pki, https ingress and api mtls
This commit is contained in:
+54
-6
@@ -1,11 +1,33 @@
|
||||
name: messenger-lab7
|
||||
|
||||
x-lockdown: &lockdown
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
|
||||
x-otel: &otel
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://otel-collector:4318}
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
|
||||
OTEL_RESOURCE_ATTRIBUTES: ${OTEL_RESOURCE_ATTRIBUTES:-deployment.environment.name=lab}
|
||||
|
||||
services:
|
||||
bootstrap:
|
||||
build:
|
||||
dockerfile_inline: |
|
||||
FROM python:3.12.7-alpine
|
||||
RUN apk add --no-cache openssl
|
||||
ENTRYPOINT ["python", "/work/bootstrap.py"]
|
||||
image: mtusi-messenger-lab7-bootstrap:dev
|
||||
network_mode: none
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
cap_add: [CHOWN, DAC_OVERRIDE, FOWNER]
|
||||
volumes:
|
||||
- ./infra/bootstrap.py:/work/bootstrap.py:ro
|
||||
- pki:/state
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "1.0", memory: 96M}
|
||||
|
||||
secrets-init:
|
||||
image: alpine:3.20.3
|
||||
volumes:
|
||||
@@ -177,12 +199,15 @@ services:
|
||||
OTEL_SERVICE_NAME: messenger-api
|
||||
volumes:
|
||||
- { type: volume, source: secrets, target: /run/secrets, read_only: true, volume: { subpath: api } }
|
||||
- { type: volume, source: pki, target: /run/tls, read_only: true, volume: { subpath: api } }
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 256M }
|
||||
stop_grace_period: 10s
|
||||
depends_on:
|
||||
bootstrap:
|
||||
condition: service_completed_successfully
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
redis:
|
||||
@@ -308,18 +333,25 @@ services:
|
||||
restart: unless-stopped
|
||||
|
||||
lb:
|
||||
<<: *lockdown
|
||||
image: haproxy:3.0.6-alpine
|
||||
user: "1000:1000"
|
||||
ports:
|
||||
- "127.0.0.1:${APP_PORT:-8080}:8080"
|
||||
- "127.0.0.1:${HTTPS_PORT:-8443}:8443"
|
||||
volumes:
|
||||
- ./infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
- {type: volume, source: pki, target: /run/tls, read_only: true, volume: {subpath: lb}}
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8404/"]
|
||||
interval: 3s
|
||||
timeout: 2s
|
||||
retries: 20
|
||||
depends_on:
|
||||
api: {condition: service_started}
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.25", memory: 64M }
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
limits: {cpus: "0.25", memory: 96M}
|
||||
|
||||
otel-collector:
|
||||
image: otel/opentelemetry-collector-contrib:0.115.1@sha256:d2da12c4336a79758826700be9e21ecf4a9f7d945b7f8a58ba55ee3fa45427c8
|
||||
@@ -416,6 +448,21 @@ services:
|
||||
condition: service_started
|
||||
restart: unless-stopped
|
||||
|
||||
checks:
|
||||
<<: *lockdown
|
||||
profiles: [tools]
|
||||
image: mtusi-messenger-lab7-bootstrap:dev
|
||||
entrypoint: [python]
|
||||
working_dir: /work
|
||||
volumes:
|
||||
- .:/work:ro
|
||||
- {type: volume, source: pki, target: /run/tls, read_only: true, volume: {subpath: checks}}
|
||||
depends_on:
|
||||
bootstrap: {condition: service_completed_successfully}
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "0.5", memory: 128M}
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
s3data:
|
||||
@@ -425,6 +472,7 @@ volumes:
|
||||
tempodata:
|
||||
grafanadata:
|
||||
secrets:
|
||||
pki:
|
||||
|
||||
networks:
|
||||
telemetry:
|
||||
|
||||
Reference in New Issue
Block a user