Initial commit
This commit is contained in:
116
docker-compose.yaml
Normal file
116
docker-compose.yaml
Normal file
@@ -0,0 +1,116 @@
|
||||
services:
|
||||
# PostgreSQL Database
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB:-estate_platform}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- internal
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
|
||||
# PgBouncer Connection Pooler
|
||||
pgbouncer:
|
||||
image: edoburu/pgbouncer:latest
|
||||
environment:
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-estate_platform}
|
||||
POOL_MODE: transaction
|
||||
MAX_CLIENT_CONN: 1000
|
||||
DEFAULT_POOL_SIZE: 25
|
||||
MIN_POOL_SIZE: 5
|
||||
RESERVE_POOL_SIZE: 10
|
||||
MAX_DB_CONNECTIONS: 50
|
||||
AUTH_TYPE: md5
|
||||
volumes:
|
||||
- ./docker/pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini:ro
|
||||
- ./docker/pgbouncer-userlist.txt:/etc/pgbouncer/userlist.txt:ro
|
||||
networks:
|
||||
- internal
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "psql", "-h", "localhost", "-p", "6432", "-U", "${POSTGRES_USER:-postgres}", "-d", "${POSTGRES_DB:-estate_platform}", "-c", "SELECT 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
|
||||
# Redis Cache
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
command: >
|
||||
redis-server
|
||||
--appendonly yes
|
||||
--requirepass ${REDIS_PASSWORD:-redis_password}
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
networks:
|
||||
- internal
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-redis_password}", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
|
||||
# Next.js Application
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
# Use PgBouncer for database connections
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@pgbouncer:6432/${POSTGRES_DB:-estate_platform}?pgbouncer=true
|
||||
REDIS_URL: redis://:${REDIS_PASSWORD:-redis_password}@redis:6379
|
||||
NODE_ENV: production
|
||||
volumes:
|
||||
- appdata:/app/data
|
||||
networks:
|
||||
- internal
|
||||
depends_on:
|
||||
pgbouncer:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
labels:
|
||||
- coolify.managed=true
|
||||
|
||||
# Nginx Reverse Proxy
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- "${PROXY_PORT:-80}:80"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
networks:
|
||||
- internal
|
||||
depends_on:
|
||||
- web
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
internal:
|
||||
driver: bridge
|
||||
internal: false # Set to true to make it completely isolated (no internet access)
|
||||
|
||||
volumes:
|
||||
appdata:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
Reference in New Issue
Block a user