version: '3.8' services: postgres: image: postgres:16-alpine container_name: realtime-collab-db env_file: - .env environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data - ./backend/scripts/init.sql:/docker-entrypoint-initdb.d/init.sql command: postgres -c shared_buffers=128MB -c max_connections=50 healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 10s timeout: 5s retries: 5 redis: image: redis:7-alpine container_name: realtime-collab-redis command: ["redis-server", "--appendonly", "yes", "--maxmemory", "64mb", "--maxmemory-policy", "allkeys-lru"] ports: - "6379:6379" volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 3s retries: 5 backend: build: context: ./backend dockerfile: Dockerfile container_name: realtime-collab-backend env_file: - ./backend/.env ports: - "8080:8080" depends_on: postgres: condition: service_healthy redis: condition: service_healthy restart: unless-stopped volumes: postgres_data: redis_data: