66 lines
1.8 KiB
YAML
66 lines
1.8 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:15 # Using PostgreSQL 15
|
|
container_name: postgres
|
|
restart: always # Ensures PostgreSQL restarts automatically
|
|
environment:
|
|
# Environment variables for authentication
|
|
- POSTGRES_USER=${POSTGRES_USER:-postgres} # Default: postgres
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password} # Default: password
|
|
- POSTGRES_DB=${POSTGRES_DB:-postgres} # Default: postgres
|
|
- PGDATA=/var/lib/postgresql/data/pgdata
|
|
volumes:
|
|
# Persistent data storage
|
|
- postgres_data:/var/lib/postgresql/data # Database files
|
|
- ./config/postgres.conf:/etc/postgresql/postgresql.conf # Configuration file
|
|
- ./init:/docker-entrypoint-initdb.d # Initialization scripts
|
|
ports:
|
|
- "5432:5432" # Expose PostgreSQL port
|
|
command: postgres -c config_file=/etc/postgresql/postgresql.conf
|
|
healthcheck:
|
|
# Regular health checks
|
|
test:
|
|
[
|
|
"CMD-SHELL",
|
|
"pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-postgres}",
|
|
]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 30s
|
|
networks:
|
|
- postgres_network
|
|
ulimits:
|
|
# Increase file descriptor limits for production
|
|
nofile:
|
|
soft: 64000
|
|
hard: 64000
|
|
logging:
|
|
# Log rotation to prevent disk space issues
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "200m"
|
|
max-file: "10"
|
|
|
|
services:
|
|
chat2db:
|
|
image: chat2db/chat2db:latest
|
|
container_name: chat2db
|
|
ports:
|
|
- "8001:10824"
|
|
networks:
|
|
- postgres_network
|
|
volumes:
|
|
- chat2db_data:/root/.chat2db
|
|
restart: unless-stopped
|
|
tty: true
|
|
|
|
volumes:
|
|
chat2db_data:
|
|
postgres_data: # Persistent volume for database files
|
|
driver: local
|
|
|
|
networks:
|
|
postgres_network:
|
|
driver: bridge
|