179 lines
5.7 KiB
YAML
179 lines
5.7 KiB
YAML
name: suman-prod
|
|
|
|
services:
|
|
# ==========================================
|
|
# 1. PostgreSQL Baza Podataka
|
|
# ==========================================
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
container_name: suman_prod_postgres
|
|
restart: always
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-suman_prod_user}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-suman_prod_secure_pass_123}
|
|
POSTGRES_DB: ${POSTGRES_DB:-suman_prod_db}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-suman_prod_user} -d ${POSTGRES_DB:-suman_prod_db}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- suman_network
|
|
|
|
# ==========================================
|
|
# 2. Redis Cache & Queue
|
|
# ==========================================
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: suman_prod_redis
|
|
restart: always
|
|
command: >
|
|
sh -c '
|
|
if [ -n "$$REDIS_PASSWORD" ]; then
|
|
redis-server --appendonly yes --requirepass "$$REDIS_PASSWORD"
|
|
else
|
|
redis-server --appendonly yes
|
|
fi
|
|
'
|
|
environment:
|
|
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: >
|
|
sh -c '
|
|
if [ -n "$$REDIS_PASSWORD" ]; then
|
|
redis-cli -a "$$REDIS_PASSWORD" ping
|
|
else
|
|
redis-cli ping
|
|
fi
|
|
'
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- suman_network
|
|
|
|
# ==========================================
|
|
# 3. Medusa v2 Backend (API & Admin)
|
|
# ==========================================
|
|
backend:
|
|
build:
|
|
context: .
|
|
dockerfile: apps/backend/Dockerfile
|
|
container_name: suman_prod_backend
|
|
restart: always
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
environment:
|
|
NODE_ENV: production
|
|
PORT: 9000
|
|
DATABASE_URL: postgres://${POSTGRES_USER:-suman_prod_user}:${POSTGRES_PASSWORD:-suman_prod_secure_pass_123}@postgres:5432/${POSTGRES_DB:-suman_prod_db}
|
|
REDIS_URL: redis://${REDIS_PASSWORD:+:${REDIS_PASSWORD}@}redis:6379
|
|
JWT_SECRET: ${JWT_SECRET:-suman_prod_super_secret_jwt_key_32_chars_min}
|
|
COOKIE_SECRET: ${COOKIE_SECRET:-suman_prod_super_secret_cookie_key_32_chars}
|
|
STORE_CORS: ${STORE_CORS:-http://localhost:8000,http://localhost:8002,https://suman.ba,https://suman.hr}
|
|
ADMIN_CORS: ${ADMIN_CORS:-http://localhost:9000,https://admin.suman.ba,https://suman.ba}
|
|
AUTH_CORS: ${AUTH_CORS:-http://localhost:9000,http://localhost:8000,http://localhost:8002,https://suman.ba,https://suman.hr}
|
|
MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://localhost:9000}
|
|
volumes:
|
|
- backend_uploads:/app/apps/backend/uploads
|
|
ports:
|
|
- "${BACKEND_PORT:-9000}:9000"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "curl -f http://localhost:9000/health || exit 1"]
|
|
interval: 15s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 20s
|
|
networks:
|
|
- suman_network
|
|
|
|
# ==========================================
|
|
# 4. Storefront Bosna i Hercegovina (Next.js)
|
|
# ==========================================
|
|
storefront-bosna:
|
|
build:
|
|
context: .
|
|
dockerfile: apps/suman-bosna/Dockerfile
|
|
args:
|
|
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
|
|
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_BA:-}
|
|
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_BA_BASE_URL:-http://localhost:8000}
|
|
NEXT_PUBLIC_DEFAULT_REGION: ba
|
|
container_name: suman_prod_storefront_bosna
|
|
restart: always
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
environment:
|
|
NODE_ENV: production
|
|
PORT: 8000
|
|
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
|
|
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_BA:-}
|
|
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_BA_BASE_URL:-http://localhost:8000}
|
|
NEXT_PUBLIC_DEFAULT_REGION: ba
|
|
ports:
|
|
- "${STOREFRONT_BA_PORT:-8000}:8000"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "curl -f http://localhost:8000/ || exit 1"]
|
|
interval: 15s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 15s
|
|
networks:
|
|
- suman_network
|
|
|
|
# ==========================================
|
|
# 5. Storefront Hrvatska (Next.js)
|
|
# ==========================================
|
|
storefront-hrvatska:
|
|
build:
|
|
context: .
|
|
dockerfile: apps/suman-hrvatska/Dockerfile
|
|
args:
|
|
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
|
|
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_HR:-}
|
|
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_HR_BASE_URL:-http://localhost:8002}
|
|
NEXT_PUBLIC_DEFAULT_REGION: hr
|
|
container_name: suman_prod_storefront_hrvatska
|
|
restart: always
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
environment:
|
|
NODE_ENV: production
|
|
PORT: 8002
|
|
NEXT_PUBLIC_MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL:-http://backend:9000}
|
|
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY: ${MEDUSA_PUBLISHABLE_KEY_HR:-}
|
|
NEXT_PUBLIC_BASE_URL: ${STOREFRONT_HR_BASE_URL:-http://localhost:8002}
|
|
NEXT_PUBLIC_DEFAULT_REGION: hr
|
|
ports:
|
|
- "${STOREFRONT_HR_PORT:-8002}:8002"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "curl -f http://localhost:8002/ || exit 1"]
|
|
interval: 15s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 15s
|
|
networks:
|
|
- suman_network
|
|
|
|
volumes:
|
|
postgres_data:
|
|
name: suman_prod_pgdata
|
|
redis_data:
|
|
name: suman_prod_redisdata
|
|
backend_uploads:
|
|
name: suman_prod_uploads
|
|
|
|
networks:
|
|
suman_network:
|
|
name: suman_prod_network
|
|
driver: bridge
|