banatie-service/docker-compose.yml

139 lines
3.7 KiB
YAML

services:
app:
build:
context: .
dockerfile: ./apps/api-service/Dockerfile.mono
target: development
container_name: banatie-app
ports:
- "3000:3000"
volumes:
- ./apps/api-service/src:/app/apps/api-service/src
- ./apps/api-service/logs:/app/apps/api-service/logs
- ./packages:/app/packages
networks:
- banatie-network
depends_on:
postgres:
condition: service_healthy
minio:
condition: service_healthy
environment:
- NODE_ENV=development
env_file:
- .env.docker
restart: unless-stopped
postgres:
image: postgres:15-alpine
container_name: banatie-postgres
ports:
- "5434:5432"
volumes:
- ./data/postgres:/var/lib/postgresql/data
- ./scripts/init-db.sql:/docker-entrypoint-initdb.d/01-init.sql
networks:
- banatie-network
environment:
POSTGRES_DB: banatie_db
POSTGRES_USER: banatie_user
POSTGRES_PASSWORD: banatie_secure_password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U banatie_user -d banatie_db"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
# SNMD MinIO Setup - Production Ready
minio:
image: quay.io/minio/minio:latest
container_name: banatie-storage
ports:
- "9000:9000" # S3 API
- "9001:9001" # Console
volumes:
# SNMD: 4 drives for full S3 compatibility and erasure coding
- ./data/storage/drive1:/data1
- ./data/storage/drive2:/data2
- ./data/storage/drive3:/data3
- ./data/storage/drive4:/data4
networks:
- banatie-network
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
MINIO_BROWSER_REDIRECT_URL: http://localhost:9001
MINIO_SERVER_URL: http://localhost:9000
MINIO_DOMAIN: localhost
# CRITICAL: SNMD command for full S3 compatibility
command: server /data{1...4} --console-address ":9001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
storage-init:
image: minio/mc:latest
container_name: banatie-storage-init
networks:
- banatie-network
depends_on:
minio:
condition: service_healthy
entrypoint:
- /bin/sh
- -c
- |
echo 'Setting up MinIO alias...'
mc alias set storage http://minio:9000 $${MINIO_ROOT_USER} $${MINIO_ROOT_PASSWORD}
echo 'Creating main bucket...'
mc mb --ignore-existing storage/banatie
echo 'Creating service user...'
mc admin user add storage banatie_service banatie_service_key_2024
echo 'Attaching readwrite policy to service user...'
mc admin policy attach storage readwrite --user=banatie_service
echo 'Setting up lifecycle policy...'
cat > /tmp/lifecycle.json <<'LIFECYCLE'
{
"Rules": [
{
"ID": "temp-cleanup",
"Status": "Enabled",
"Filter": {
"Prefix": "temp/"
},
"Expiration": {
"Days": 7
}
}
]
}
LIFECYCLE
mc ilm import storage/banatie < /tmp/lifecycle.json
echo 'Storage initialization completed!'
echo 'Bucket: banatie'
echo 'Using presigned URLs for secure access'
echo 'SNMD mode: Full S3 compatibility enabled'
exit 0
restart: "no"
networks:
banatie-network:
driver: bridge
volumes:
postgres-data:
driver: local
storage-data:
driver: local