346 lines
13 KiB
YAML
346 lines
13 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:alpine
|
|
# Terse error logging leaves out DETAIL, HINT, QUERY, and CONTEXT. The
|
|
# DETAIL of a unique or foreign key violation quotes the key value, such
|
|
# as an email address, and the container logs go to Loki.
|
|
command: ["postgres", "-c", "log_error_verbosity=terse"]
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB:?Set POSTGRES_DB in the root .env file}
|
|
POSTGRES_USER: ${POSTGRES_USER:?Set POSTGRES_USER in the root .env file}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in the root .env file}
|
|
POSTGRES_EXPORTER_USER: ${POSTGRES_EXPORTER_USER:-}
|
|
POSTGRES_EXPORTER_PASSWORD: ${POSTGRES_EXPORTER_PASSWORD:-}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql
|
|
- ./initdb/10-postgres-exporter.sql:/docker-entrypoint-initdb.d/10-postgres-exporter.sql:ro
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: 10m
|
|
max-file: "3"
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "1.0"
|
|
memory: 2G
|
|
|
|
redis:
|
|
image: redis:alpine
|
|
environment:
|
|
REDIS_PASSWORD: ${REDIS_PASSWORD:?Set REDIS_PASSWORD in the root .env file}
|
|
command:
|
|
- /bin/sh
|
|
- -ec
|
|
- |
|
|
exec docker-entrypoint.sh redis-server \
|
|
--requirepass "$${REDIS_PASSWORD}" \
|
|
--maxmemory 128mb --maxmemory-policy allkeys-lru \
|
|
--save "" --appendonly no
|
|
tmpfs:
|
|
- /data:size=16m,mode=1777
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "test \"$$(REDISCLI_AUTH=\"$${REDIS_PASSWORD}\" redis-cli ping)\" = PONG"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: 10m
|
|
max-file: "3"
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.5"
|
|
memory: 256M
|
|
|
|
seaweedfs:
|
|
image: chrislusf/seaweedfs:latest
|
|
# The storage network is the primary boundary: besides S3, mini serves
|
|
# unauthenticated gRPC (master, filer, volume, S3), an admin server, and
|
|
# HTTP APIs that ignore S3 credentials, so only the backend and the
|
|
# monitoring Prometheus may join it. S3 requires the access key below;
|
|
# -s3.iam=false only removes the IAM management API. As defense in depth,
|
|
# each start sets fresh random JWT keys that never leave the container
|
|
# (filer and volume HTTP requests need a token), and -whiteList limits
|
|
# master and volume HTTP to in-container callers. "@" is the peer of the
|
|
# local gRPC sockets that mini uses between its components.
|
|
entrypoint:
|
|
- /bin/sh
|
|
- -ec
|
|
- |
|
|
for name in WEED_JWT_SIGNING_KEY WEED_JWT_SIGNING_READ_KEY WEED_JWT_FILER_SIGNING_KEY WEED_JWT_FILER_SIGNING_READ_KEY; do
|
|
export "$$name=$$(head -c 32 /dev/urandom | base64)"
|
|
done
|
|
exec /entrypoint.sh "$$@"
|
|
- seaweedfs
|
|
command:
|
|
- mini
|
|
- -dir=/data
|
|
- -ip=127.0.0.1
|
|
- -ip.bind=0.0.0.0
|
|
- -whiteList=127.0.0.1,@
|
|
- -webdav=false
|
|
- -admin.ui=false
|
|
- -s3.iam=false
|
|
- -s3.port.iceberg=0
|
|
- -s3.port.lance=0
|
|
- -s3.autoCreateBucket=false
|
|
- -s3.allowDeleteBucketNotEmpty=false
|
|
- -master.telemetry=false
|
|
- -metricsPort=9327
|
|
environment:
|
|
AWS_ACCESS_KEY_ID: ${SEAWEEDFS_ACCESS_KEY:?Set SEAWEEDFS_ACCESS_KEY in the root .env file}
|
|
AWS_SECRET_ACCESS_KEY: ${SEAWEEDFS_SECRET_KEY:?Set SEAWEEDFS_SECRET_KEY in the root .env file}
|
|
S3_BUCKET: ${SEAWEEDFS_BUCKET:?Set SEAWEEDFS_BUCKET in the root .env file}
|
|
volumes:
|
|
- seaweedfs_data:/data
|
|
networks:
|
|
- storage
|
|
expose:
|
|
- "8333"
|
|
- "9327"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:9333/cluster/healthz >/dev/null && nc -z 127.0.0.1 8333"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
start_period: 15s
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: 10m
|
|
max-file: "3"
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "1.0"
|
|
memory: 1G
|
|
|
|
kafka:
|
|
image: apache/kafka:latest
|
|
environment:
|
|
# Setting any KAFKA_* property disables the image's default
|
|
# server.properties, so every required broker setting is listed here.
|
|
CLUSTER_ID: ${KAFKA_CLUSTER_ID:?Set KAFKA_CLUSTER_ID in the root .env file}
|
|
KAFKA_NODE_ID: "1"
|
|
KAFKA_PROCESS_ROLES: broker,controller
|
|
# The controller listener stays on container loopback; only the
|
|
# client listener is reachable on the Compose network.
|
|
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,CONTROLLER://127.0.0.1:9093
|
|
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
|
|
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT
|
|
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
|
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
|
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@127.0.0.1:9093
|
|
KAFKA_LOG_DIRS: /var/lib/kafka/data
|
|
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
|
|
KAFKA_NUM_PARTITIONS: "1"
|
|
KAFKA_DEFAULT_REPLICATION_FACTOR: "1"
|
|
KAFKA_MIN_INSYNC_REPLICAS: "1"
|
|
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
|
|
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: "1"
|
|
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: "1"
|
|
KAFKA_SHARE_COORDINATOR_STATE_TOPIC_REPLICATION_FACTOR: "1"
|
|
KAFKA_SHARE_COORDINATOR_STATE_TOPIC_MIN_ISR: "1"
|
|
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: "0"
|
|
KAFKA_LOG_RETENTION_HOURS: "168"
|
|
KAFKA_LOG_RETENTION_BYTES: "1073741824"
|
|
KAFKA_LOG_SEGMENT_BYTES: "134217728"
|
|
KAFKA_HEAP_OPTS: -Xms256m -Xmx512m
|
|
# An empty value lets the image enable an unauthenticated JMX agent with
|
|
# an RMI port on all container interfaces. This non-empty value opens no
|
|
# JMX port; metrics export is not configured yet.
|
|
KAFKA_JMX_OPTS: -Djava.rmi.server.hostname=127.0.0.1
|
|
volumes:
|
|
- kafka_data:/var/lib/kafka/data
|
|
# The image declares these paths as volumes for TLS material and config
|
|
# overrides. Neither is used here; tmpfs avoids an anonymous volume per
|
|
# container recreation.
|
|
tmpfs:
|
|
- /etc/kafka/secrets:size=1m,mode=0755
|
|
- /mnt/shared/config:size=1m,mode=0755
|
|
expose:
|
|
- "9092"
|
|
healthcheck:
|
|
# CLI tools inherit KAFKA_HEAP_OPTS, so the probe gets its own small heap
|
|
# to stay inside the container memory limit next to the broker.
|
|
test: ["CMD-SHELL", "KAFKA_HEAP_OPTS='-Xms32m -Xmx64m' /opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092 >/dev/null 2>&1"]
|
|
interval: 15s
|
|
timeout: 10s
|
|
retries: 10
|
|
start_period: 30s
|
|
# Allow a controlled shutdown so the next start skips log recovery.
|
|
stop_grace_period: 30s
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: 10m
|
|
max-file: "3"
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "1.0"
|
|
memory: 1G
|
|
|
|
backend:
|
|
build:
|
|
context: ../../backend
|
|
dockerfile: Dockerfile
|
|
environment:
|
|
DATABASE_URL: postgres://${POSTGRES_USER:?Set POSTGRES_USER}:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:?Set POSTGRES_DB}?sslmode=disable
|
|
REDIS_ADDR: redis:6379
|
|
REDIS_PASSWORD: ${REDIS_PASSWORD:?Set REDIS_PASSWORD in the root .env file}
|
|
REDIS_DB: "0"
|
|
REDIS_TIMEOUT: 1s
|
|
SEAWEEDFS_ENDPOINT: http://seaweedfs:8333
|
|
SEAWEEDFS_ACCESS_KEY: ${SEAWEEDFS_ACCESS_KEY:?Set SEAWEEDFS_ACCESS_KEY in the root .env file}
|
|
SEAWEEDFS_SECRET_KEY: ${SEAWEEDFS_SECRET_KEY:?Set SEAWEEDFS_SECRET_KEY in the root .env file}
|
|
SEAWEEDFS_BUCKET: ${SEAWEEDFS_BUCKET:?Set SEAWEEDFS_BUCKET in the root .env file}
|
|
SEAWEEDFS_REGION: us-east-1
|
|
SEAWEEDFS_TIMEOUT: 10s
|
|
KAFKA_BROKERS: kafka:9092
|
|
EMAIL_PROVIDER: ${EMAIL_PROVIDER:?Set EMAIL_PROVIDER to resend, smtp, or disabled in the root .env file}
|
|
EMAIL_FROM: ${EMAIL_FROM:?Set EMAIL_FROM in the root .env file}
|
|
EMAIL_ACCOUNT: ${EMAIL_ACCOUNT:-default}
|
|
EMAIL_TIMEOUT: ${EMAIL_TIMEOUT:-10s}
|
|
# Empty means unset: the backend applies the Resend Free defaults for
|
|
# resend and refuses to start smtp without stated limits.
|
|
EMAIL_QUOTA_DAILY: ${EMAIL_QUOTA_DAILY:-}
|
|
EMAIL_QUOTA_MONTHLY: ${EMAIL_QUOTA_MONTHLY:-}
|
|
# Empty means a fifth of the matching quota limit (see .env.example).
|
|
EMAIL_SERVICE_RESERVE_DAILY: ${EMAIL_SERVICE_RESERVE_DAILY:-}
|
|
EMAIL_SERVICE_RESERVE_MONTHLY: ${EMAIL_SERVICE_RESERVE_MONTHLY:-}
|
|
APP_PUBLIC_URL: ${APP_PUBLIC_URL:?Set APP_PUBLIC_URL in the root .env file}
|
|
RESEND_API_KEY: ${RESEND_API_KEY:-}
|
|
SMTP_HOST: ${SMTP_HOST:-}
|
|
SMTP_PORT: ${SMTP_PORT:-}
|
|
SMTP_USERNAME: ${SMTP_USERNAME:-}
|
|
SMTP_PASSWORD: ${SMTP_PASSWORD:-}
|
|
SMTP_TLS_MODE: ${SMTP_TLS_MODE:-}
|
|
# Argon2id derivations that may run at once, 64 MiB each (1 to 4).
|
|
PASSWORD_HASH_CONCURRENCY: ${PASSWORD_HASH_CONCURRENCY:-1}
|
|
# Required: keys idempotency records, rate limits, and session CSRF tokens.
|
|
# Generate with: openssl rand -base64 48
|
|
IDENTITY_KEY_SECRET: ${IDENTITY_KEY_SECRET:?set IDENTITY_KEY_SECRET in .env (openssl rand -base64 48)}
|
|
VERIFICATION_MAIL_MIN_INTERVAL: ${VERIFICATION_MAIL_MIN_INTERVAL:-1m}
|
|
VERIFICATION_MAIL_DAILY_LIMIT: ${VERIFICATION_MAIL_DAILY_LIMIT:-5}
|
|
IDENTITY_CLIENT_HOURLY_LIMIT: ${IDENTITY_CLIENT_HOURLY_LIMIT:-30}
|
|
IDENTITY_LOGIN_EMAIL_HOURLY_LIMIT: ${IDENTITY_LOGIN_EMAIL_HOURLY_LIMIT:-10}
|
|
IDENTITY_SESSION_IDLE_TIMEOUT: ${IDENTITY_SESSION_IDLE_TIMEOUT:-24h}
|
|
IDENTITY_SESSION_ABSOLUTE_LIFETIME: ${IDENTITY_SESSION_ABSOLUTE_LIFETIME:-168h}
|
|
ASSESSMENT_DEMO_CATEGORIES_ENABLED: ${ASSESSMENT_DEMO_CATEGORIES_ENABLED:-false}
|
|
# Proxies whose X-Forwarded-For is believed: only the frontend container,
|
|
# which has a fixed address on the pinned app network below. Other
|
|
# containers of that network (Prometheus, exporters, Alloy) are not
|
|
# trusted. The frontend Nginx already replaces the header with the
|
|
# client address it resolved behind the edge.
|
|
TRUSTED_PROXY_CIDRS: ${TRUSTED_PROXY_CIDRS:-${APP_FRONTEND_IP:-172.29.79.10}/32}
|
|
# Soft Go heap limit at about 78% of the 768M container limit below; the
|
|
# rest covers goroutine stacks, runtime metadata, and non-heap memory.
|
|
# Change both together.
|
|
GOMEMLIMIT: 600MiB
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
seaweedfs:
|
|
condition: service_healthy
|
|
networks:
|
|
- default
|
|
- storage
|
|
expose:
|
|
- "8080"
|
|
- "9090"
|
|
# Shutdown budget with the defaults (see docs/en/DEPLOY.md):
|
|
# - in parallel: the HTTP shutdown (SHUTDOWN_TIMEOUT, 10s), the relay
|
|
# pass (10s plus a 5s rollback), and each event consumer
|
|
# (CONSUMER_SHUTDOWN_GRACE 5s, a 5s rollback, CONSUMER_COMMIT_TIMEOUT
|
|
# 5s): 15s;
|
|
# - then the consumers leave their groups in parallel (commit timeout
|
|
# plus 2s) and the clients close (about 1s): 8s.
|
|
# About 23s in total; 30s leaves a margin so Docker does not kill the
|
|
# process while a pass or a consumer transaction is committing.
|
|
stop_grace_period: 30s
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: 10m
|
|
max-file: "3"
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "1.0"
|
|
memory: 768M
|
|
|
|
frontend:
|
|
build:
|
|
context: ../..
|
|
dockerfile: frontend/Dockerfile
|
|
depends_on:
|
|
backend:
|
|
condition: service_started
|
|
networks:
|
|
default:
|
|
ipv4_address: ${APP_FRONTEND_IP:-172.29.79.10}
|
|
ports:
|
|
# Loopback by default. On the app host behind the edge proxy,
|
|
# APP_HTTP_BIND is the tunnel address (see docs/en/DEPLOY.md); never
|
|
# set it to 0.0.0.0, because Docker publishing bypasses ufw.
|
|
- "${APP_HTTP_BIND:-127.0.0.1}:${APP_HTTP_PORT:-8080}:8080"
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/healthz"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: 10m
|
|
max-file: "3"
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.5"
|
|
memory: 256M
|
|
|
|
volumes:
|
|
postgres_data:
|
|
name: ${APP_PROJECT:-app}_postgres_data
|
|
seaweedfs_data:
|
|
name: ${APP_PROJECT:-app}_seaweedfs_data
|
|
kafka_data:
|
|
name: ${APP_PROJECT:-app}_kafka_data
|
|
|
|
networks:
|
|
default:
|
|
name: ${APP_NETWORK:-app_default}
|
|
# Pinned so that the frontend container, the only trusted proxy of the
|
|
# backend, has a known address. Change APP_SUBNET and APP_FRONTEND_IP
|
|
# together when the range collides with a route or another Docker network;
|
|
# a network that already exists with another subnet must be recreated
|
|
# (make -C deploy down, then up).
|
|
ipam:
|
|
config:
|
|
- subnet: ${APP_SUBNET:-172.29.79.0/24}
|
|
# Only SeaweedFS, the backend, and the monitoring Prometheus join it.
|
|
storage:
|
|
name: ${APP_STORAGE_NETWORK:-${APP_PROJECT:-app}_storage}
|
|
internal: true
|