157 lines
4.6 KiB
YAML
157 lines
4.6 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# MySQL Database
|
|
scriptshare-db:
|
|
image: mysql:8.0
|
|
container_name: scriptshare-db
|
|
restart: unless-stopped
|
|
environment:
|
|
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-ScriptShare_Root_2024_Secure_Password}
|
|
MYSQL_DATABASE: ${DB_NAME:-scriptshare}
|
|
MYSQL_USER: ${DB_USER:-scriptshare_user}
|
|
MYSQL_PASSWORD: ${DB_PASSWORD:-ScriptShare_App_2024_Secure!}
|
|
MYSQL_CHARSET: utf8mb4
|
|
MYSQL_COLLATION: utf8mb4_unicode_ci
|
|
volumes:
|
|
- scriptshare_db_data:/var/lib/mysql
|
|
- ./scripts/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql:ro
|
|
ports:
|
|
- "${DB_PORT:-3306}:3306"
|
|
networks:
|
|
- scriptshare-network
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_ROOT_PASSWORD:-ScriptShare_Root_2024_Secure_Password}"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 5
|
|
start_period: 60s
|
|
command: >
|
|
--default-authentication-plugin=mysql_native_password
|
|
--character-set-server=utf8mb4
|
|
--collation-server=utf8mb4_unicode_ci
|
|
--innodb-file-per-table=1
|
|
--max-connections=200
|
|
|
|
# Backend API
|
|
scriptshare-api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile.api
|
|
container_name: scriptshare-api
|
|
restart: unless-stopped
|
|
environment:
|
|
- NODE_ENV=production
|
|
- DATABASE_URL=mysql://${DB_USER:-scriptshare_user}:${DB_PASSWORD:-ScriptShare_App_2024_Secure!}@scriptshare-db:3306/${DB_NAME:-scriptshare}
|
|
- JWT_SECRET=${JWT_SECRET:-production-super-secret-jwt-key-scriptshare-2024-secure}
|
|
- CORS_ORIGIN=${FRONTEND_URL:-http://localhost}
|
|
- PORT=3000
|
|
- DB_HOST=scriptshare-db
|
|
- DB_PORT=3306
|
|
- DB_USER=${DB_USER:-scriptshare_user}
|
|
- DB_PASSWORD=${DB_PASSWORD:-ScriptShare_App_2024_Secure!}
|
|
- DB_NAME=${DB_NAME:-scriptshare}
|
|
ports:
|
|
- "${API_PORT:-3001}:3000"
|
|
networks:
|
|
- scriptshare-network
|
|
depends_on:
|
|
scriptshare-db:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
volumes:
|
|
- scriptshare_api_logs:/app/logs
|
|
|
|
# Frontend
|
|
scriptshare-frontend:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
args:
|
|
- VITE_APP_NAME=${APP_NAME:-ScriptShare}
|
|
- VITE_APP_URL=${APP_URL:-https://scriptshare.example.com}
|
|
- VITE_ANALYTICS_ENABLED=${ANALYTICS_ENABLED:-false}
|
|
- VITE_API_URL=${API_URL:-http://localhost:3001}
|
|
container_name: scriptshare-frontend
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${FRONTEND_PORT:-80}:80"
|
|
networks:
|
|
- scriptshare-network
|
|
depends_on:
|
|
- scriptshare-api
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost/"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
volumes:
|
|
- scriptshare_frontend_logs:/var/log/nginx
|
|
|
|
# Reverse Proxy (Nginx)
|
|
scriptshare-proxy:
|
|
image: nginx:alpine
|
|
container_name: scriptshare-proxy
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${PROXY_PORT:-8080}:80"
|
|
- "${PROXY_SSL_PORT:-8443}:443"
|
|
volumes:
|
|
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./nginx/conf.d:/etc/nginx/conf.d:ro
|
|
- scriptshare_proxy_logs:/var/log/nginx
|
|
- ${SSL_CERT_PATH:-./certs}:/etc/nginx/certs:ro
|
|
networks:
|
|
- scriptshare-network
|
|
depends_on:
|
|
- scriptshare-frontend
|
|
- scriptshare-api
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
# Redis Cache (Optional)
|
|
scriptshare-redis:
|
|
image: redis:7-alpine
|
|
container_name: scriptshare-redis
|
|
restart: unless-stopped
|
|
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-ScriptShare_Redis_2024}
|
|
ports:
|
|
- "${REDIS_PORT:-6379}:6379"
|
|
volumes:
|
|
- scriptshare_redis_data:/data
|
|
networks:
|
|
- scriptshare-network
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
volumes:
|
|
scriptshare_db_data:
|
|
driver: local
|
|
scriptshare_api_logs:
|
|
driver: local
|
|
scriptshare_frontend_logs:
|
|
driver: local
|
|
scriptshare_proxy_logs:
|
|
driver: local
|
|
scriptshare_redis_data:
|
|
driver: local
|
|
|
|
networks:
|
|
scriptshare-network:
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: 172.20.0.0/16
|