This commit is contained in:
Chu Văn Hải committed 2025-12-05 13:37:13 +07:00
commit 39d06135c3
29 files changed
+6840

No files matched your search

+228
View File
@@ -0,0 +1,228 @@
# ============================================================================
# AUTO-GENERATED ENVIRONMENT FILE FOR AUTO-SCALING DEPLOYMENT
# Application: {{ app_name }}
# Environment: {{ deploy_env }}{{ env_tag | default('') }}
# Generated: {{ ansible_date_time.iso8601 }}
# Ansible User: {{ ansible_user_id }}
# ============================================================================
# Application Configuration
NODE_ENV={{ deploy_env }}
APP_NAME={{ app_name }}
APP_VERSION={{ docker_image_tag }}
DEPLOY_ENV={{ deploy_env }}
INSTANCE_ID={{ app_name }}-{{ deploy_env }}
# Port Configuration
PORT={{ final_container_port | default(container_port) | default(3000) }}
HOST=0.0.0.0
# Auto-Scaling Configuration
{% if auto_scaling_config is defined %}
REPLICAS={{ auto_scaling_config.replicas }}
MAX_REPLICAS={{ auto_scaling_config.max_replicas }}
DEPLOYMENT_STRATEGY={{ auto_scaling_config.deployment_strategy }}
BASE_PORT={{ auto_scaling_config.base_port }}
CONTAINER_PORT={{ auto_scaling_config.container_port }}
{% else %}
REPLICAS={{ final_replicas | default(2) }}
MAX_REPLICAS={{ final_max_replicas | default(5) }}
DEPLOYMENT_STRATEGY={{ final_deployment_strategy | default('rolling') }}
BASE_PORT={{ final_app_port | default(3000) }}
CONTAINER_PORT={{ final_container_port | default(3000) }}
{% endif %}
# Framework Configuration
{% if framework is defined %}
FRAMEWORK={{ framework }}
{% endif %}
{% if node_version is defined %}
NODE_VERSION={{ node_version }}
{% endif %}
{% if package_manager is defined %}
PACKAGE_MANAGER={{ package_manager }}
{% endif %}
# Docker Configuration
DOCKER_NETWORK={{ final_docker_network | default(app_name + '-' + deploy_env + '-network') }}
RESTART_POLICY={{ final_restart_policy | default('unless-stopped') }}
MEMORY_LIMIT={{ final_memory_limit | default('1g') }}
CPU_LIMIT={{ final_cpu_limit | default('1.0') }}
# Health Check Configuration
{% if health_check is defined %}
HEALTH_CHECK_PATH={{ health_check.path | default('/health') }}
HEALTH_CHECK_TIMEOUT={{ health_check.timeout | default(10) }}
HEALTH_CHECK_INTERVAL={{ health_check.interval | default(30) }}
HEALTH_CHECK_RETRIES={{ health_check.retries | default(3) }}
{% else %}
HEALTH_CHECK_PATH={{ health_path | default('/health') }}
HEALTH_CHECK_TIMEOUT=10
HEALTH_CHECK_INTERVAL=30
HEALTH_CHECK_RETRIES=3
{% endif %}
# Git Information
{% if git_tag is defined %}
GIT_TAG={{ git_tag }}
{% endif %}
{% if git_sha is defined %}
GIT_COMMIT={{ git_sha }}
{% endif %}
{% if git_branch is defined %}
GIT_BRANCH={{ git_branch }}
{% endif %}
# Build Information
BUILD_DATE={{ ansible_date_time.iso8601 }}
PIPELINE_ID={{ pipeline_id | default('unknown') }}
# Environment-Specific Variables
{% if environment_variables is defined and environment_variables[deploy_env] is defined %}
{% for key, value in environment_variables[deploy_env].items() %}
{{ key }}={{ value }}
{% endfor %}
{% endif %}
# Legacy env_vars support (backward compatibility)
{% if env_vars is defined %}
{% for key, value in env_vars.items() %}
{{ key }}={{ value }}
{% endfor %}
{% endif %}
# Project-Specific Variables
{% if project_env_vars is defined and project_env_vars[deploy_env] is defined %}
{% for key, value in project_env_vars[deploy_env].items() %}
{{ key }}={{ value }}
{% endfor %}
{% endif %}
# Database Configuration (if applicable)
{% if database_config is defined %}
{% for key, value in database_config.items() %}
{{ key | upper }}={{ value }}
{% endfor %}
{% endif %}
# Queue Configuration (if applicable)
{% if queue_config is defined %}
{% for key, value in queue_config.items() %}
{{ key | upper }}={{ value }}
{% endfor %}
{% endif %}
# Monitoring Configuration
{% if monitoring is defined %}
{% if monitoring.enable_metrics %}
ENABLE_METRICS=true
METRICS_PORT={{ monitoring.metrics_port | default(9090) }}
METRICS_PATH={{ monitoring.metrics_path | default('/metrics') }}
{% endif %}
{% if monitoring.enable_tracing %}
ENABLE_TRACING=true
JAEGER_ENDPOINT={{ monitoring.jaeger_endpoint | default('http://jaeger:14268/api/traces') }}
{% endif %}
{% if monitoring.log_aggregation %}
LOG_AGGREGATION=true
LOG_FORMAT={{ monitoring.log_format | default('json') }}
{% endif %}
{% endif %}
# Load Balancer Information
LB_UPSTREAM_NAME={{ app_name }}_{{ deploy_env }}_backend
LB_METHOD={{ nginx_config.load_balancing_method | default('least_conn') }}
# Service Discovery
SERVICE_NAME={{ app_name }}
SERVICE_VERSION={{ docker_image_tag }}
SERVICE_ENVIRONMENT={{ deploy_env }}
# Auto-scaling Metadata for Application
AUTOSCALE_ENABLED=true
AUTOSCALE_TARGET_REPLICAS={{ final_replicas | default(2) }}
AUTOSCALE_MAX_REPLICAS={{ final_max_replicas | default(5) }}
AUTOSCALE_STRATEGY={{ final_deployment_strategy | default('rolling') }}
# Deployment Metadata
DEPLOYMENT_TIMESTAMP={{ ansible_date_time.epoch }}
DEPLOYMENT_USER={{ ansible_user_id }}
DEPLOYMENT_HOST={{ ansible_host }}
# Security Configuration
{% if security_config is defined %}
{% for key, value in security_config.items() %}
{{ key | upper }}={{ value }}
{% endfor %}
{% endif %}
# Feature Flags
{% if feature_flags is defined %}
{% for key, value in feature_flags.items() %}
FEATURE_{{ key | upper }}={{ value }}
{% endfor %}
{% endif %}
# Next.js Specific (if framework is nextjs)
{% if framework == 'nextjs' %}
NEXT_TELEMETRY_DISABLED=1
{% if environment_variables is defined and environment_variables[deploy_env] is defined %}
{% for key, value in environment_variables[deploy_env].items() %}
{% if key.startswith('NEXT_PUBLIC_') %}
{{ key }}={{ value }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
# React Specific (if framework is reactjs)
{% if framework == 'reactjs' or framework == 'reactjs-vite' %}
{% if environment_variables is defined and environment_variables[deploy_env] is defined %}
{% for key, value in environment_variables[deploy_env].items() %}
{% if key.startswith('REACT_APP_') %}
{{ key }}={{ value }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
# NestJS Specific (if framework is nestjs)
{% if framework == 'nestjs' %}
NEST_DEBUG=false
{% if deploy_env == 'development' %}
NEST_DEBUG=true
{% endif %}
{% endif %}
# Express Specific (if framework is expressjs)
{% if framework == 'expressjs' %}
EXPRESS_ENV={{ deploy_env }}
TRUST_PROXY=true
{% endif %}
# Worker Specific (if it's a worker deployment)
{% if env_tag is defined and 'worker' in env_tag %}
WORKER_CONCURRENCY={{ worker_config.concurrency | default(5) }}
WORKER_TIMEOUT={{ worker_config.timeout | default(30000) }}
QUEUE_NAME={{ worker_config.queue_name | default('default') }}
QUEUE_RETRY_ATTEMPTS={{ worker_config.retry_attempts | default(3) }}
{% endif %}
# ============================================================================
# AUTO-SCALING DEPLOYMENT INFORMATION
# ============================================================================
# This file was auto-generated for auto-scaling deployment
# Management script: /home/{{ server_user }}/scripts/manage-{{ app_name }}-{{ deploy_env }}{{ env_tag | default('') }}.sh
#
# Scale command: ./manage-{{ app_name }}-{{ deploy_env }}{{ env_tag | default('') }}.sh scale <replicas>
# Status command: ./manage-{{ app_name }}-{{ deploy_env }}{{ env_tag | default('') }}.sh status
# Health command: ./manage-{{ app_name }}-{{ deploy_env }}{{ env_tag | default('') }}.sh health
# Logs command: ./manage-{{ app_name }}-{{ deploy_env }}{{ env_tag | default('') }}.sh logs
#
# Port Pattern: {{ final_app_port | default(3000) }}{replica_number}
# Current Replicas: {{ final_replicas | default(2) }}
# Max Replicas: {{ final_max_replicas | default(5) }}
# Strategy: {{ final_deployment_strategy | default('rolling') }}
# ============================================================================