init
This commit is contained in:
@@ -1,53 +1,153 @@
|
||||
version: '3.9'
|
||||
|
||||
# ============================================================================
|
||||
# PostgreSQL Admin Panel - Complete Stack
|
||||
# ============================================================================
|
||||
# Services:
|
||||
# - postgres: PostgreSQL 16 database
|
||||
# - pgadmin: Node.js application
|
||||
#
|
||||
# Usage:
|
||||
# docker-compose up --build # Build and start
|
||||
# docker-compose down # Stop and remove
|
||||
# docker-compose logs -f # View logs
|
||||
# docker-compose ps # Status
|
||||
# ============================================================================
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:16
|
||||
container_name: app_postgres
|
||||
# =========================================================================
|
||||
# PostgreSQL Database Service
|
||||
# =========================================================================
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: pg-admin-postgres
|
||||
restart: unless-stopped
|
||||
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: testdb
|
||||
|
||||
|
||||
# Network Settings
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
- pgadmin-network
|
||||
|
||||
# Environment Configuration
|
||||
environment:
|
||||
# Database initialization
|
||||
POSTGRES_DB: ${DB_NAME:-postgres}
|
||||
POSTGRES_USER: ${DB_USER:-postgres}
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
|
||||
|
||||
# PostgreSQL configuration
|
||||
POSTGRES_INITDB_ARGS: >
|
||||
-c max_connections=200
|
||||
-c shared_buffers=256MB
|
||||
-c effective_cache_size=1GB
|
||||
-c log_statement=all
|
||||
|
||||
# Volume Management
|
||||
volumes:
|
||||
# Persist database files
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
# Health Check
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-postgres}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
|
||||
backend:
|
||||
build: .
|
||||
container_name: app_backend
|
||||
start_period: 10s
|
||||
|
||||
# =========================================================================
|
||||
# PostgreSQL Admin Panel Application
|
||||
# =========================================================================
|
||||
pgadmin:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
# Build arguments
|
||||
args:
|
||||
NODE_ENV: production
|
||||
|
||||
container_name: pg-admin-app
|
||||
restart: unless-stopped
|
||||
|
||||
|
||||
# Network Settings
|
||||
ports:
|
||||
- "3000:3000"
|
||||
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
- pgadmin-network
|
||||
|
||||
# Depends On
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
# Environment Configuration
|
||||
environment:
|
||||
# Application Settings
|
||||
NODE_ENV: ${NODE_ENV:-production}
|
||||
PORT: 3000
|
||||
|
||||
# Database Connection
|
||||
DB_HOST: postgres
|
||||
DB_PORT: 5432
|
||||
DB_NAME: ${DB_NAME:-postgres}
|
||||
DB_USER: ${DB_USER:-postgres}
|
||||
DB_PASSWORD: ${DB_PASSWORD:-postgres}
|
||||
|
||||
# Security
|
||||
SESSION_SECRET: ${SESSION_SECRET:-change-this-in-production-to-random-string}
|
||||
|
||||
# Volume Management (development - can be removed in production)
|
||||
volumes:
|
||||
# Code synchronization
|
||||
- ./public:/app/public:ro
|
||||
- ./src:/app/src:ro
|
||||
# Node modules persistence
|
||||
- /app/node_modules
|
||||
|
||||
# Resource Limits
|
||||
# Uncomment for production to limit resources
|
||||
# deploy:
|
||||
# resources:
|
||||
# limits:
|
||||
# cpus: '1'
|
||||
# memory: 512M
|
||||
# reservations:
|
||||
# cpus: '0.5'
|
||||
# memory: 256M
|
||||
|
||||
# Health Check
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
# Logging Configuration
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# ============================================================================
|
||||
# Volumes Definition
|
||||
# ============================================================================
|
||||
volumes:
|
||||
postgres_data:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
o: bind
|
||||
device: ${PWD}/postgres_data
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Networks Definition
|
||||
# ============================================================================
|
||||
networks:
|
||||
app_network:
|
||||
pgadmin-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.20.0.0/16
|
||||
|
||||
Reference in New Issue
Block a user