services: postgres: image: postgres:16.4-alpine environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 5s timeout: 5s retries: 5 redis: image: valkey/valkey:8.0-alpine command: valkey-server --appendonly yes --save 60 1 volumes: - redis_data:/data healthcheck: test: ["CMD", "valkey-cli", "ping"] interval: 5s timeout: 5s retries: 5 s3: image: chrislusf/seaweedfs:3.80 command: - server - -dir=/data - -s3 - -s3.port=8333 - -master.volumeSizeLimitMB=64 - -volume.max=100 volumes: - s3data:/data healthcheck: test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8333/healthz"] interval: 10s timeout: 5s retries: 15 start_period: 120s deploy: resources: limits: cpus: '1.0' memory: 1G restart: unless-stopped s3-init: image: amazon/aws-cli:2.15.0 depends_on: s3: condition: service_healthy environment: - AWS_ACCESS_KEY_ID=${S3_INIT_ACCESS_KEY} - AWS_SECRET_ACCESS_KEY=${S3_INIT_SECRET_KEY} - AWS_REGION=${S3_REGION} entrypoint: > /bin/sh -c " aws --endpoint-url http://s3:8333 s3 mb s3://${S3_BUCKET_NAME} 2>/dev/null || echo 'Bucket already exists, skipping creation' aws --endpoint-url http://s3:8333 s3api put-bucket-acl --bucket ${S3_BUCKET_NAME} --acl private echo 'Bucket ${S3_BUCKET_NAME} is ready and private' " restart: "no" api: build: context: . dockerfile: Dockerfile environment: - DATABASE_URL=${DATABASE_URL} - REDIS_URL=${REDIS_URL} - SECRET_SESSION_KEY=${SECRET_SESSION_KEY} - SESSION_TTL_SECONDS=${SESSION_TTL_SECONDS} - S3_ENDPOINT=${S3_ENDPOINT} - S3_ACCESS_KEY=${S3_API_ACCESS_KEY} - S3_SECRET_KEY=${S3_API_SECRET_KEY} - S3_BUCKET_NAME=${S3_BUCKET_NAME} - S3_REGION=${S3_REGION} expose: - "8080" volumes: - ./alembic/versions:/app/alembic/versions - ./app:/app/app read_only: true tmpfs: - /tmp:size=15M depends_on: postgres: condition: service_healthy redis: condition: service_healthy s3-init: condition: service_completed_successfully stop_grace_period: 30s healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health/live"] interval: 10s timeout: 5s retries: 3 start_period: 10s deploy: resources: limits: cpus: '0.5' memory: 256M nginx: image: nginx:1.25-alpine ports: - "8080:8080" volumes: - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro depends_on: api: condition: service_healthy restart: unless-stopped volumes: postgres_data: redis_data: s3data: