124 lines
4.1 KiB
YAML
124 lines
4.1 KiB
YAML
services:
|
|
api1:
|
|
build: .
|
|
image: mtusi-messenger-api:4.0.0
|
|
environment: &api-env
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:?Create a local .env first}@db:5432/${POSTGRES_DB:-messenger}
|
|
CACHE_URL: redis://redis:6379/0
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
S3_ENDPOINT: http://minio:9000
|
|
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
|
S3_ACCESS_KEY: ${S3_ACCESS_KEY:?Create local S3 credentials}
|
|
S3_SECRET_KEY: ${S3_SECRET_KEY:?Create local S3 credentials}
|
|
depends_on:
|
|
migrate: {condition: service_completed_successfully}
|
|
s3-bootstrap: {condition: service_completed_successfully}
|
|
db: {condition: service_started}
|
|
redis: {condition: service_started}
|
|
mem_limit: 512m
|
|
cpus: 1.0
|
|
stop_grace_period: 15s
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3)"]
|
|
interval: 5s
|
|
timeout: 4s
|
|
retries: 5
|
|
start_period: 15s
|
|
|
|
api2:
|
|
build: .
|
|
image: mtusi-messenger-api:4.0.0
|
|
environment: *api-env
|
|
depends_on:
|
|
migrate: {condition: service_completed_successfully}
|
|
s3-bootstrap: {condition: service_completed_successfully}
|
|
db: {condition: service_started}
|
|
redis: {condition: service_started}
|
|
mem_limit: 512m
|
|
cpus: 1.0
|
|
stop_grace_period: 15s
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3)"]
|
|
interval: 5s
|
|
timeout: 4s
|
|
retries: 5
|
|
start_period: 15s
|
|
|
|
migrate:
|
|
build: .
|
|
image: mtusi-messenger-api:4.0.0
|
|
command: ["alembic", "upgrade", "head"]
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:?Create a local .env first}@db:5432/${POSTGRES_DB:-messenger}
|
|
depends_on:
|
|
db: {condition: service_started}
|
|
restart: "no"
|
|
|
|
lb:
|
|
image: nginx:1.27.5-alpine
|
|
ports:
|
|
- "${APP_PORT:-8080}:8080"
|
|
volumes:
|
|
- ./infra/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
|
depends_on: [api1, api2]
|
|
mem_limit: 128m
|
|
cpus: 0.5
|
|
restart: unless-stopped
|
|
|
|
db:
|
|
image: postgres:16.4-alpine
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Create a local .env first}
|
|
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
|
volumes: ["postgres_data:/var/lib/postgresql/data"]
|
|
mem_limit: 1g
|
|
cpus: 1.0
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7.4.2-alpine
|
|
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "always"]
|
|
volumes: ["redis_data:/data"]
|
|
mem_limit: 256m
|
|
cpus: 0.5
|
|
restart: unless-stopped
|
|
|
|
minio:
|
|
image: dappros/minio:RELEASE.2025-09-07T16-13-09Z
|
|
command: ["server", "/data", "--address", ":9000", "--console-address", ":9001"]
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:?Create local MinIO credentials}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:?Create local MinIO credentials}
|
|
volumes: ["minio_data:/data"]
|
|
expose: ["9000"]
|
|
mem_limit: 768m
|
|
cpus: 1.0
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:9000/minio/health/ready"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
|
|
s3-bootstrap:
|
|
image: ghcr.io/golithus/mc:RELEASE.2025-08-13T08-35-41Z@sha256:dde55ccc0bc9e65dc582c8e652d652eea1438c6e60d774524f4da15d7b26a900
|
|
entrypoint: ["/bin/sh", "/bootstrap.sh"]
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:?Create local MinIO credentials}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:?Create local MinIO credentials}
|
|
S3_ACCESS_KEY: ${S3_ACCESS_KEY:?Create local S3 credentials}
|
|
S3_SECRET_KEY: ${S3_SECRET_KEY:?Create local S3 credentials}
|
|
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
|
volumes: ["./infra/minio-bootstrap.sh:/bootstrap.sh:ro"]
|
|
depends_on:
|
|
minio: {condition: service_healthy}
|
|
restart: "no"
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
minio_data:
|