Files
lincodex/deploy/docker/docker-compose.yml
T

260 lines
8.4 KiB
YAML

services:
postgres:
image: postgres:alpine
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.sh:/docker-entrypoint-initdb.d/10-postgres-exporter.sh: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
command:
- mini
- -dir=/data
- -ip=seaweedfs
- -ip.bind=0.0.0.0
- -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
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_TIMEOUT: ${EMAIL_TIMEOUT:-10s}
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:-}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
seaweedfs:
condition: service_healthy
expose:
- "8080"
- "9090"
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
ports:
- "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}