update docker

This commit is contained in:
Phuoc Nguyen
2025-10-10 17:13:45 +07:00
parent 87c12b9927
commit 8c34460889
5 changed files with 478 additions and 50 deletions

View File

@@ -1,27 +1,6 @@
version: '3.8'
services:
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: retail-pos-postgres
restart: unless-stopped
environment:
POSTGRES_DB: retail_pos
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
networks:
- retail-pos-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cache
redis:
image: redis:7-alpine
@@ -39,67 +18,61 @@ services:
timeout: 5s
retries: 5
# NestJS Application
# NestJS API Application
api:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: retail-pos-api
restart: unless-stopped
ports:
- "3000:3000"
environment:
# Application
NODE_ENV: production
PORT: 3000
API_PREFIX: api
DB_HOST: postgres
DB_PORT: 5432
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_DATABASE: retail_pos
# Database (Aiven PostgreSQL)
DB_HOST: pg-30ed1d6a-renolation.b.aivencloud.com
DB_PORT: 20912
DB_USERNAME: avnadmin
DB_PASSWORD: AVNS_b5AVrZdm2M2donLgXXQ
DB_DATABASE: defaultdb
DB_SSL: "true"
# JWT Configuration
JWT_SECRET: retail-pos-super-secret-key-change-in-production-2025
JWT_EXPIRES_IN: 1d
# Redis Cache
REDIS_HOST: redis
REDIS_PORT: 6379
CACHE_TTL: 300
# CORS
CORS_ORIGIN: http://localhost:3000,capacitor://localhost
# Rate Limiting
THROTTLE_TTL: 60
THROTTLE_LIMIT: 100
# Bcrypt
BCRYPT_ROUNDS: 10
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- retail-pos-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/health"]
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Optional: pgAdmin for database management
pgadmin:
image: dpage/pgadmin4:latest
container_name: retail-pos-pgadmin
restart: unless-stopped
environment:
PGADMIN_DEFAULT_EMAIL: admin@retailpos.com
PGADMIN_DEFAULT_PASSWORD: admin123
ports:
- "5050:80"
depends_on:
- postgres
networks:
- retail-pos-network
profiles:
- tools
volumes:
postgres-data:
driver: local
redis-data:
driver: local